From 0871bffae307e0553e0c5186336189e8b55cf6a6 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 15 Feb 2009 08:01:00 -0800 Subject: Version abc90215 --- Makefile | 2 +- abc.dsp | 3695 ----------------------------------- abc.dsw | 29 - abc.rc | 5 +- abcexe.dsp | 102 + abclib.dsp | 1126 +++++++++-- abclib.dsw | 29 - abcspace.dsw | 44 + abctestlib.dsp | 102 - abctestlib.dsw | 29 - demo.c | 181 -- src/aig/aig/aig.h | 39 +- src/aig/aig/aigCanon.c | 14 +- src/aig/aig/aigCuts.c | 16 +- src/aig/aig/aigDup.c | 12 +- src/aig/aig/aigFanout.c | 6 +- src/aig/aig/aigFrames.c | 4 +- src/aig/aig/aigInter.c | 6 +- src/aig/aig/aigMan.c | 30 +- src/aig/aig/aigMem.c | 80 +- src/aig/aig/aigOrder.c | 6 +- src/aig/aig/aigPart.c | 42 +- src/aig/aig/aigPartReg.c | 22 +- src/aig/aig/aigPartSat.c | 8 +- src/aig/aig/aigRepr.c | 8 +- src/aig/aig/aigRet.c | 20 +- src/aig/aig/aigScl.c | 11 +- src/aig/aig/aigTable.c | 8 +- src/aig/aig/aigTsim.c | 8 +- src/aig/aig/aigUtil.c | 38 +- src/aig/bar/bar.c | 5 +- src/aig/bar/bar.h | 8 +- src/aig/bbr/bbr.h | 8 +- src/aig/bbr/bbrCex.c | 8 +- src/aig/bbr/bbrImage.c | 78 +- src/aig/bbr/bbrReach.c | 26 +- src/aig/bdc/bdc.h | 16 +- src/aig/bdc/bdcCore.c | 26 +- src/aig/bdc/bdcInt.h | 8 +- src/aig/cec/cec.c | 48 + src/aig/cec/cec.h | 22 +- src/aig/cec/cecAig.c | 151 -- src/aig/cec/cecClass.c | 841 ++++++-- src/aig/cec/cecCnf.c | 328 ---- src/aig/cec/cecCore.c | 234 +-- src/aig/cec/cecInt.h | 221 +-- src/aig/cec/cecMan.c | 175 +- src/aig/cec/cecPat.c | 493 +++++ src/aig/cec/cecSat.c | 250 --- src/aig/cec/cecSim.c | 459 ----- src/aig/cec/cecSolve.c | 537 +++++ src/aig/cec/cecStatus.c | 187 -- src/aig/cec/module.make | 9 +- src/aig/cec2/cec.h | 104 + src/aig/cec2/cecAig.c | 168 ++ src/aig/cec2/cecClass.c | 571 ++++++ src/aig/cec2/cecCnf.c | 328 ++++ src/aig/cec2/cecCore.c | 245 +++ src/aig/cec2/cecInt.h | 208 ++ src/aig/cec2/cecMan.c | 59 + src/aig/cec2/cecSat.c | 250 +++ src/aig/cec2/cecSat2.c | 284 +++ src/aig/cec2/cecSim.c | 447 +++++ src/aig/cec2/cecStatus.c | 187 ++ src/aig/cec2/cecSweep.c | 582 ++++++ src/aig/cec2/module.make | 9 + src/aig/cgt/cgt.h | 8 +- src/aig/cgt/cgtCore.c | 2 +- src/aig/cgt/cgtDecide.c | 4 +- src/aig/cgt/cgtInt.h | 8 +- src/aig/cgt/cgtMan.c | 22 +- src/aig/cgt/cgtSat.c | 2 +- src/aig/cnf/cnf.h | 8 +- src/aig/cnf/cnfCore.c | 10 +- src/aig/cnf/cnfData.c | 6 +- src/aig/cnf/cnfMan.c | 40 +- src/aig/cnf/cnfMap.c | 4 +- src/aig/cnf/cnfWrite.c | 24 +- src/aig/csw/csw.h | 8 +- src/aig/csw/cswCut.c | 2 +- src/aig/csw/cswInt.h | 8 +- src/aig/csw/cswMan.c | 32 +- src/aig/dar/dar.h | 9 +- src/aig/dar/darCore.c | 23 +- src/aig/dar/darCut.c | 17 +- src/aig/dar/darData.c | 4 +- src/aig/dar/darInt.h | 12 +- src/aig/dar/darLib.c | 58 +- src/aig/dar/darMan.c | 21 +- src/aig/dar/darPrec.c | 32 +- src/aig/dar/darRefact.c | 12 +- src/aig/dar/darScript.c | 8 +- src/aig/dch/dch.h | 8 +- src/aig/dch/dchChoice.c | 6 +- src/aig/dch/dchClass.c | 24 +- src/aig/dch/dchCnf.c | 4 +- src/aig/dch/dchCore.c | 2 +- src/aig/dch/dchInt.h | 8 +- src/aig/dch/dchMan.c | 32 +- src/aig/dch/dchSat.c | 4 +- src/aig/dch/dchSweep.c | 2 +- src/aig/deco/deco.h | 22 +- src/aig/fra/fra.h | 16 +- src/aig/fra/fraBmc.c | 28 +- src/aig/fra/fraCec.c | 36 +- src/aig/fra/fraClass.c | 36 +- src/aig/fra/fraClau.c | 20 +- src/aig/fra/fraClaus.c | 78 +- src/aig/fra/fraCnf.c | 4 +- src/aig/fra/fraHot.c | 2 +- src/aig/fra/fraImp.c | 33 +- src/aig/fra/fraInd.c | 18 +- src/aig/fra/fraIndVer.c | 2 +- src/aig/fra/fraLcr.c | 38 +- src/aig/fra/fraMan.c | 46 +- src/aig/fra/fraPart.c | 20 +- src/aig/fra/fraSat.c | 14 +- src/aig/fra/fraSec.c | 60 +- src/aig/fra/fraSim.c | 13 +- src/aig/fsim/fsim.h | 8 +- src/aig/fsim/fsimFront.c | 30 +- src/aig/fsim/fsimInt.h | 8 +- src/aig/fsim/fsimMan.c | 30 +- src/aig/fsim/fsimSim.c | 41 +- src/aig/fsim/fsimSwitch.c | 553 ------ src/aig/fsim/fsimTsim.c | 22 +- src/aig/gia/gia.c | 47 + src/aig/gia/gia.h | 423 ++++ src/aig/gia/giaAig.c | 214 ++ src/aig/gia/giaAiger.c | 553 ++++++ src/aig/gia/giaCof.c | 688 +++++++ src/aig/gia/giaConstr.c | 47 + src/aig/gia/giaDfs.c | 243 +++ src/aig/gia/giaDup.c | 698 +++++++ src/aig/gia/giaFanout.c | 197 ++ src/aig/gia/giaForce.c | 164 ++ src/aig/gia/giaFrames.c | 346 ++++ src/aig/gia/giaFront.c | 248 +++ src/aig/gia/giaGlitch.c | 743 +++++++ src/aig/gia/giaHash.c | 541 +++++ src/aig/gia/giaLogic.c | 725 +++++++ src/aig/gia/giaMan.c | 203 ++ src/aig/gia/giaProp.c | 171 ++ src/aig/gia/giaSat.c | 421 ++++ src/aig/gia/giaScl.c | 240 +++ src/aig/gia/giaSim.c | 437 +++++ src/aig/gia/giaSolver.c | 490 +++++ src/aig/gia/giaSolver_cnf.c | 103 + src/aig/gia/giaSwitch.c | 673 +++++++ src/aig/gia/giaTsim.c | 708 +++++++ src/aig/gia/giaUtil.c | 518 +++++ src/aig/gia/module.make | 19 + src/aig/hop/cudd2.h | 8 +- src/aig/hop/hop.h | 34 +- src/aig/hop/hopDfs.c | 8 +- src/aig/hop/hopMan.c | 12 +- src/aig/hop/hopMem.c | 6 +- src/aig/hop/hopObj.c | 2 +- src/aig/hop/hopTable.c | 6 +- src/aig/hop/hopUtil.c | 24 +- src/aig/int/int.h | 8 +- src/aig/int/intContain.c | 4 +- src/aig/int/intCore.c | 4 +- src/aig/int/intCtrex.c | 8 +- src/aig/int/intDup.c | 4 +- src/aig/int/intInt.h | 8 +- src/aig/int/intM114.c | 6 +- src/aig/int/intMan.c | 18 +- src/aig/int/intUtil.c | 8 +- src/aig/ioa/ioa.h | 8 +- src/aig/ioa/ioaReadAig.c | 7 +- src/aig/ioa/ioaWriteAig.c | 12 +- src/aig/ivy/attr.h | 8 +- src/aig/ivy/ivy.h | 18 +- src/aig/ivy/ivyCut.c | 2 +- src/aig/ivy/ivyCutTrav.c | 2 +- src/aig/ivy/ivyFastMap.c | 10 +- src/aig/ivy/ivyFraig.c | 112 +- src/aig/ivy/ivyHaig.c | 2 +- src/aig/ivy/ivyMan.c | 16 +- src/aig/ivy/ivyMem.c | 6 +- src/aig/ivy/ivyObj.c | 2 +- src/aig/ivy/ivyResyn.c | 28 +- src/aig/ivy/ivySeq.c | 2 +- src/aig/ivy/ivyTable.c | 6 +- src/aig/kit/cloud.c | 34 +- src/aig/kit/cloud.h | 39 +- src/aig/kit/kit.h | 33 +- src/aig/kit/kitDsd.c | 42 +- src/aig/kit/kitFactor.c | 2 +- src/aig/kit/kitGraph.c | 14 +- src/aig/kit/kitSop.c | 6 +- src/aig/mem/mem.c | 81 +- src/aig/mfx/mfx.h | 8 +- src/aig/mfx/mfxCore.c | 4 +- src/aig/mfx/mfxInt.h | 8 +- src/aig/mfx/mfxInter.c | 4 +- src/aig/mfx/mfxMan.c | 18 +- src/aig/mfx/mfxResub.c | 2 +- src/aig/mfx/mfxSat.c | 2 +- src/aig/ntl/ntl.h | 19 +- src/aig/ntl/ntlFraig.c | 10 +- src/aig/ntl/ntlMan.c | 18 +- src/aig/ntl/ntlMap.c | 4 +- src/aig/ntl/ntlReadBlif.c | 26 +- src/aig/ntl/ntlTable.c | 12 +- src/aig/ntl/ntlTime.c | 2 +- src/aig/ntl/ntlUtil.c | 6 +- src/aig/ntl/ntlWriteBlif.c | 12 +- src/aig/nwk/nwk.h | 21 +- src/aig/nwk/nwkBidec.c | 2 +- src/aig/nwk/nwkFlow.c | 4 +- src/aig/nwk/nwkMan.c | 16 +- src/aig/nwk/nwkMap.c | 4 +- src/aig/nwk/nwkMerge.c | 38 +- src/aig/nwk/nwkMerge.h | 8 +- src/aig/nwk/nwkSpeedup.c | 6 +- src/aig/nwk/nwkTiming.c | 4 +- src/aig/nwk2/nwk.h | 8 +- src/aig/nwk2/nwkMerge.h | 8 +- src/aig/rwt/rwt.h | 16 +- src/aig/rwt/rwtDec.c | 2 +- src/aig/rwt/rwtMan.c | 38 +- src/aig/rwt/rwtUtil.c | 4 +- src/aig/saig/saig.h | 10 +- src/aig/saig/saigAbs.c | 26 +- src/aig/saig/saigBmc.c | 14 +- src/aig/saig/saigBmc2.c | 12 +- src/aig/saig/saigHaig.c | 24 +- src/aig/saig/saigInd.c | 4 +- src/aig/saig/saigIoa.c | 4 +- src/aig/saig/saigMiter.c | 18 +- src/aig/saig/saigPhase.c | 12 +- src/aig/saig/saigRetFwd.c | 8 +- src/aig/saig/saigRetMin.c | 8 +- src/aig/saig/saigSimExt.c | 2 +- src/aig/saig/saigSimFast.c | 27 +- src/aig/saig/saigSimMv.c | 48 +- src/aig/saig/saigSimSeq.c | 32 +- src/aig/saig/saigStrSim.c | 16 +- src/aig/saig/saigSwitch.c | 34 +- src/aig/saig/saigSynch.c | 12 +- src/aig/saig/saigTrans.c | 8 +- src/aig/saig/saigWnd.c | 4 +- src/aig/ssw/ssw.h | 8 +- src/aig/ssw/sswAig.c | 4 +- src/aig/ssw/sswBmc.c | 4 +- src/aig/ssw/sswClass.c | 38 +- src/aig/ssw/sswCnf.c | 8 +- src/aig/ssw/sswCore.c | 6 +- src/aig/ssw/sswInt.h | 8 +- src/aig/ssw/sswIslands.c | 2 +- src/aig/ssw/sswMan.c | 34 +- src/aig/ssw/sswPairs.c | 16 +- src/aig/ssw/sswPart.c | 4 +- src/aig/ssw/sswSat.c | 4 +- src/aig/ssw/sswSemi.c | 10 +- src/aig/ssw/sswSim.c | 10 +- src/aig/tim/tim.c | 18 +- src/aig/tim/tim.h | 8 +- src/base/abc/abc.h | 49 +- src/base/abc/abcAig.c | 32 +- src/base/abc/abcBlifMv.c | 32 +- src/base/abc/abcCheck.c | 6 +- src/base/abc/abcDfs.c | 57 +- src/base/abc/abcFanio.c | 6 +- src/base/abc/abcFunc.c | 4 +- src/base/abc/abcLatch.c | 6 +- src/base/abc/abcLib.c | 6 +- src/base/abc/abcMinBase.c | 10 +- src/base/abc/abcNames.c | 6 +- src/base/abc/abcNtk.c | 46 +- src/base/abc/abcObj.c | 12 +- src/base/abc/abcRefs.c | 8 +- src/base/abc/abcShow.c | 2 +- src/base/abc/abcSop.c | 6 +- src/base/abc/abcUtil.c | 42 +- src/base/abci/abc.c | 1577 ++++++++++++++- src/base/abci/abcAbc8.c | 8 +- src/base/abci/abcAttach.c | 24 +- src/base/abci/abcAuto.c | 12 +- src/base/abci/abcBalance.c | 8 +- src/base/abci/abcBidec.c | 2 +- src/base/abci/abcBmc.c | 2 +- src/base/abci/abcCas.c | 8 +- src/base/abci/abcClpBdd.c | 6 +- src/base/abci/abcCut.c | 6 +- src/base/abci/abcDar.c | 227 ++- src/base/abci/abcDebug.c | 4 +- src/base/abci/abcDelay.c | 35 +- src/base/abci/abcDsd.c | 20 +- src/base/abci/abcFraig.c | 4 +- src/base/abci/abcFxu.c | 10 +- src/base/abci/abcHaig.c | 9 +- src/base/abci/abcIf.c | 14 +- src/base/abci/abcIvy.c | 14 +- src/base/abci/abcLut.c | 10 +- src/base/abci/abcMap.c | 2 +- src/base/abci/abcMeasure.c | 4 +- src/base/abci/abcMerge.c | 4 +- src/base/abci/abcMiter.c | 4 +- src/base/abci/abcMv.c | 6 +- src/base/abci/abcNtbdd.c | 2 +- src/base/abci/abcOdc.c | 42 +- src/base/abci/abcPart.c | 40 +- src/base/abci/abcPrint.c | 192 +- src/base/abci/abcProve.c | 20 +- src/base/abci/abcQbf.c | 6 +- src/base/abci/abcQuant.c | 7 +- src/base/abci/abcReach.c | 22 +- src/base/abci/abcRec.c | 34 +- src/base/abci/abcReconv.c | 4 +- src/base/abci/abcRefactor.c | 24 +- src/base/abci/abcReorder.c | 4 +- src/base/abci/abcRestruct.c | 26 +- src/base/abci/abcResub.c | 30 +- src/base/abci/abcRewrite.c | 2 +- src/base/abci/abcRr.c | 50 +- src/base/abci/abcSat.c | 68 +- src/base/abci/abcSense.c | 2 +- src/base/abci/abcStrash.c | 4 +- src/base/abci/abcSweep.c | 4 +- src/base/abci/abcSymm.c | 12 +- src/base/abci/abcTiming.c | 16 +- src/base/abci/abcUnate.c | 6 +- src/base/abci/abcUnreach.c | 16 +- src/base/abci/abcVerify.c | 62 +- src/base/abci/abcXsim.c | 6 +- src/base/abci/module.make | 1 - src/base/cmd/cmd.c | 24 +- src/base/cmd/cmd.h | 19 +- src/base/cmd/cmdAlias.c | 8 +- src/base/cmd/cmdApi.c | 2 +- src/base/cmd/cmdFlag.c | 6 +- src/base/cmd/cmdUtils.c | 39 +- src/base/io/io.c | 4 +- src/base/io/ioAbc.h | 8 +- src/base/io/ioReadAiger.c | 23 +- src/base/io/ioReadBaf.c | 8 +- src/base/io/ioReadBlif.c | 30 +- src/base/io/ioReadBlifAig.c | 20 +- src/base/io/ioReadBlifMv.c | 108 +- src/base/io/ioReadDsd.c | 6 +- src/base/io/ioReadEdif.c | 2 +- src/base/io/ioReadEqn.c | 2 +- src/base/io/ioReadPla.c | 4 +- src/base/io/ioUtil.c | 4 +- src/base/io/ioWriteAiger.c | 34 +- src/base/io/ioWriteBaf.c | 16 +- src/base/io/ioWriteBlif.c | 2 +- src/base/io/ioWriteBlifMv.c | 2 +- src/base/io/ioWriteBook.c | 15 +- src/base/io/ioWriteCnf.c | 2 +- src/base/io/ioWritePla.c | 20 +- src/base/io/ioWriteVerilog.c | 2 +- src/base/main/libSupport.c | 15 +- src/base/main/main.c | 10 +- src/base/main/main.h | 27 +- src/base/main/mainFrame.c | 4 +- src/base/main/mainInt.h | 13 +- src/base/main/mainUtils.c | 28 +- src/base/seq/seq.h | 8 +- src/base/seq/seqInt.h | 8 +- src/base/ver/ver.h | 8 +- src/base/ver/verCore.c | 32 +- src/base/ver/verFormula.c | 8 +- src/base/ver/verStream.c | 8 +- src/bdd/cas/cas.h | 8 +- src/bdd/cas/casCore.c | 4 +- src/bdd/cas/casDec.c | 24 +- src/bdd/cudd/cuddAPI.c | 22 +- src/bdd/cudd/cuddAddWalsh.c | 22 +- src/bdd/cudd/cuddAnneal.c | 6 +- src/bdd/cudd/cuddApa.c | 66 +- src/bdd/cudd/cuddApprox.c | 46 +- src/bdd/cudd/cuddBddCorr.c | 32 +- src/bdd/cudd/cuddCache.c | 16 +- src/bdd/cudd/cuddCompose.c | 26 +- src/bdd/cudd/cuddDecomp.c | 154 +- src/bdd/cudd/cuddExact.c | 42 +- src/bdd/cudd/cuddExport.c | 24 +- src/bdd/cudd/cuddGenCof.c | 22 +- src/bdd/cudd/cuddGenetic.c | 72 +- src/bdd/cudd/cuddGroup.c | 18 +- src/bdd/cudd/cuddHarwell.c | 68 +- src/bdd/cudd/cuddInit.c | 12 +- src/bdd/cudd/cuddInt.h | 10 +- src/bdd/cudd/cuddInteract.c | 8 +- src/bdd/cudd/cuddLCache.c | 48 +- src/bdd/cudd/cuddLevelQ.c | 36 +- src/bdd/cudd/cuddLinear.c | 18 +- src/bdd/cudd/cuddMatMult.c | 10 +- src/bdd/cudd/cuddPriority.c | 4 +- src/bdd/cudd/cuddRead.c | 20 +- src/bdd/cudd/cuddRef.c | 4 +- src/bdd/cudd/cuddReorder.c | 42 +- src/bdd/cudd/cuddSat.c | 6 +- src/bdd/cudd/cuddSign.c | 12 +- src/bdd/cudd/cuddSolve.c | 4 +- src/bdd/cudd/cuddSplit.c | 18 +- src/bdd/cudd/cuddSubsetHB.c | 204 +- src/bdd/cudd/cuddSubsetSP.c | 106 +- src/bdd/cudd/cuddSymmetry.c | 24 +- src/bdd/cudd/cuddTable.c | 228 +-- src/bdd/cudd/cuddUtil.c | 214 +- src/bdd/cudd/cuddWindow.c | 20 +- src/bdd/cudd/cuddZddCount.c | 12 +- src/bdd/cudd/cuddZddGroup.c | 18 +- src/bdd/cudd/cuddZddLin.c | 12 +- src/bdd/cudd/cuddZddReord.c | 20 +- src/bdd/cudd/cuddZddSymm.c | 24 +- src/bdd/cudd/cuddZddUtil.c | 30 +- src/bdd/dsd/dsd.h | 32 +- src/bdd/dsd/dsdCheck.c | 12 +- src/bdd/dsd/dsdLocal.c | 20 +- src/bdd/dsd/dsdMan.c | 12 +- src/bdd/dsd/dsdProc.c | 4 +- src/bdd/dsd/dsdTree.c | 20 +- src/bdd/epd/epd.c | 4 +- src/bdd/mtr/mtrBasic.c | 4 +- src/bdd/parse/parseCore.c | 13 +- src/bdd/parse/parseEqn.c | 10 +- src/bdd/parse/parseStack.c | 16 +- src/bdd/reo/reo.h | 16 +- src/bdd/reo/reoApi.c | 30 +- src/bdd/reo/reoCore.c | 86 +- src/bdd/reo/reoProfile.c | 8 +- src/bdd/reo/reoSwap.c | 4 +- src/bdd/reo/reoTest.c | 6 +- src/bdd/reo/reoTransfer.c | 6 +- src/bdd/reo/reoUnits.c | 10 +- src/demo.c | 181 ++ src/generic.h | 8 +- src/map/amap/amap.h | 15 +- src/map/amap/amapCore.c | 8 +- src/map/amap/amapInt.h | 16 +- src/map/amap/amapLib.c | 14 +- src/map/amap/amapLiberty.c | 911 +++++++++ src/map/amap/amapMan.c | 10 +- src/map/amap/amapMatch.c | 4 +- src/map/amap/amapMerge.c | 4 +- src/map/amap/amapParse.c | 30 +- src/map/amap/amapRead.c | 35 +- src/map/amap/amapUniq.c | 6 +- src/map/amap/module.make | 1 + src/map/fpga/fpga.h | 16 +- src/map/fpga/fpgaCore.c | 10 +- src/map/fpga/fpgaCreate.c | 44 +- src/map/fpga/fpgaCut.c | 28 +- src/map/fpga/fpgaInt.h | 18 +- src/map/fpga/fpgaLib.c | 10 +- src/map/fpga/fpgaTruth.c | 8 +- src/map/fpga/fpgaUtils.c | 4 +- src/map/fpga/fpgaVec.c | 10 +- src/map/if/if.h | 20 +- src/map/if/ifCore.c | 2 +- src/map/if/ifCut.c | 4 +- src/map/if/ifLib.c | 12 +- src/map/if/ifMan.c | 26 +- src/map/if/ifMap.c | 10 +- src/map/if/ifReduce.c | 6 +- src/map/if/ifUtil.c | 12 +- src/map/mapper/mapper.h | 17 +- src/map/mapper/mapperCore.c | 14 +- src/map/mapper/mapperCreate.c | 56 +- src/map/mapper/mapperCut.c | 28 +- src/map/mapper/mapperInt.h | 8 +- src/map/mapper/mapperLib.c | 10 +- src/map/mapper/mapperRefs.c | 4 +- src/map/mapper/mapperTable.c | 20 +- src/map/mapper/mapperTree.c | 2 +- src/map/mapper/mapperVec.c | 10 +- src/map/mio/mio.c | 81 + src/map/mio/mio.h | 8 +- src/map/mio/mioFunc.c | 8 +- src/map/mio/mioRead.c | 22 +- src/map/mio/mioUtils.c | 34 +- src/map/super/super.h | 8 +- src/map/super/superAnd.c | 44 +- src/map/super/superGate.c | 40 +- src/misc/extra/extra.h | 86 +- src/misc/extra/extraBddAuto.c | 26 +- src/misc/extra/extraBddCas.c | 10 +- src/misc/extra/extraBddImage.c | 66 +- src/misc/extra/extraBddMisc.c | 16 +- src/misc/extra/extraBddSymm.c | 20 +- src/misc/extra/extraBddUnate.c | 16 +- src/misc/extra/extraUtilBitMatrix.c | 12 +- src/misc/extra/extraUtilFile.c | 8 +- src/misc/extra/extraUtilMemory.c | 72 +- src/misc/extra/extraUtilMisc.c | 58 +- src/misc/extra/extraUtilProgress.c | 4 +- src/misc/extra/extraUtilReader.c | 8 +- src/misc/extra/extraUtilUtil.c | 16 +- src/misc/hash/hash.h | 13 +- src/misc/hash/hashFlt.h | 22 +- src/misc/hash/hashInt.h | 20 +- src/misc/hash/hashPtr.h | 20 +- src/misc/mvc/mvc.h | 4 +- src/misc/mvc/mvcContain.c | 2 +- src/misc/mvc/mvcCover.c | 6 +- src/misc/mvc/mvcCube.c | 10 +- src/misc/mvc/mvcDivisor.c | 2 +- src/misc/mvc/mvcMan.c | 4 +- src/misc/mvc/mvcUtils.c | 4 +- src/misc/nm/nm.h | 8 +- src/misc/nm/nmApi.c | 12 +- src/misc/nm/nmInt.h | 8 +- src/misc/nm/nmTable.c | 10 +- src/misc/st/st.c | 74 +- src/misc/st/stmm.c | 59 +- src/misc/st/stmm.h | 4 +- src/misc/util/abc_global.h | 178 ++ src/misc/util/port_type.h | 78 - src/misc/util/util_hack.h | 27 +- src/misc/vec/vec.h | 82 +- src/misc/vec/vecAtt.h | 20 +- src/misc/vec/vecFlt.h | 22 +- src/misc/vec/vecInt.h | 24 +- src/misc/vec/vecPtr.h | 52 +- src/misc/vec/vecStr.h | 22 +- src/misc/vec/vecVec.h | 4 +- src/opt/cut/cut.h | 8 +- src/opt/cut/cutMan.c | 18 +- src/opt/cut/cutOracle.c | 6 +- src/opt/cut/cutPre22.c | 20 +- src/opt/dec/dec.h | 22 +- src/opt/dec/decFactor.c | 4 +- src/opt/dec/decMan.c | 14 +- src/opt/dec/decUtil.c | 8 +- src/opt/fxu/fxu.c | 6 +- src/opt/fxu/fxu.h | 8 +- src/opt/fxu/fxuCreate.c | 10 +- src/opt/fxu/fxuHeapD.c | 10 +- src/opt/fxu/fxuHeapS.c | 10 +- src/opt/fxu/fxuInt.h | 6 +- src/opt/fxu/fxuMatrix.c | 16 +- src/opt/fxu/fxuPair.c | 14 +- src/opt/fxu/fxuPrint.c | 4 +- src/opt/fxu/fxuReduce.c | 22 +- src/opt/fxu/fxuSelect.c | 2 +- src/opt/fxu/fxuSingle.c | 12 +- src/opt/fxu/fxuUpdate.c | 2 +- src/opt/lpk/lpk.h | 8 +- src/opt/lpk/lpkAbcDsd.c | 4 +- src/opt/lpk/lpkAbcUtil.c | 4 +- src/opt/lpk/lpkCore.c | 32 +- src/opt/lpk/lpkCut.c | 22 +- src/opt/lpk/lpkInt.h | 8 +- src/opt/lpk/lpkMan.c | 10 +- src/opt/lpk/lpkMulti.c | 6 +- src/opt/lpk/lpkSets.c | 2 +- src/opt/mfs/mfs.h | 8 +- src/opt/mfs/mfsCore.c | 28 +- src/opt/mfs/mfsInt.h | 10 +- src/opt/mfs/mfsInter.c | 4 +- src/opt/mfs/mfsMan.c | 18 +- src/opt/mfs/mfsResub.c | 17 +- src/opt/mfs/mfsSat.c | 2 +- src/opt/mfs/mfsStrash.c | 8 +- src/opt/res/res.h | 8 +- src/opt/res/resCore.c | 28 +- src/opt/res/resInt.h | 8 +- src/opt/res/resSat.c | 62 +- src/opt/res/resSim.c | 4 +- src/opt/res/resWin.c | 4 +- src/opt/ret/retArea.c | 14 +- src/opt/ret/retCore.c | 2 +- src/opt/ret/retFlow.c | 2 +- src/opt/ret/retIncrem.c | 10 +- src/opt/ret/retInit.c | 32 +- src/opt/ret/retLvalue.c | 4 +- src/opt/rwr/rwr.h | 16 +- src/opt/rwr/rwrDec.c | 2 +- src/opt/rwr/rwrExp.c | 34 +- src/opt/rwr/rwrMan.c | 28 +- src/opt/rwr/rwrUtil.c | 18 +- src/opt/sim/sim.h | 8 +- src/opt/sim/simMan.c | 46 +- src/opt/sim/simSupp.c | 8 +- src/opt/sim/simSymStr.c | 4 +- src/opt/sim/simUtils.c | 4 +- src/sat/bsat/satInter.c | 52 +- src/sat/bsat/satInterA.c | 50 +- src/sat/bsat/satInterB.c | 50 +- src/sat/bsat/satInterP.c | 53 +- src/sat/bsat/satMem.c | 79 +- src/sat/bsat/satMem.h | 5 - src/sat/bsat/satSolver.c | 78 +- src/sat/bsat/satSolver.h | 31 +- src/sat/bsat/satStore.c | 17 +- src/sat/bsat/satStore.h | 24 +- src/sat/bsat/satTrace.c | 2 - src/sat/bsat/satUtil.c | 3 +- src/sat/bsat/satVec.h | 16 +- src/sat/csat/csat_apis.c | 36 +- src/sat/csat/csat_apis.h | 16 +- src/sat/fraig/fraig.h | 37 +- src/sat/fraig/fraigFeed.c | 12 +- src/sat/fraig/fraigInt.h | 31 +- src/sat/fraig/fraigMan.c | 24 +- src/sat/fraig/fraigMem.c | 26 +- src/sat/fraig/fraigSat.c | 40 +- src/sat/fraig/fraigTable.c | 24 +- src/sat/fraig/fraigUtil.c | 4 +- src/sat/fraig/fraigVec.c | 14 +- src/sat/lsat/solver.h | 2 +- src/sat/msat/module.make | 2 +- src/sat/msat/msat.h | 8 +- src/sat/msat/msatClause.c | 4 +- src/sat/msat/msatClauseVec.c | 10 +- src/sat/msat/msatInt.h | 32 +- src/sat/msat/msatMem.c | 64 +- src/sat/msat/msatOrderH.c | 4 +- src/sat/msat/msatQueue.c | 8 +- src/sat/msat/msatRead.c | 4 +- src/sat/msat/msatSolverApi.c | 70 +- src/sat/msat/msatSolverCore.c | 6 +- src/sat/msat/msatVec.c | 22 +- src/sat/proof/pr.c | 61 +- src/sat/proof/pr.h | 8 +- 621 files changed, 24947 insertions(+), 12040 deletions(-) delete mode 100644 abc.dsp delete mode 100644 abc.dsw create mode 100644 abcexe.dsp delete mode 100644 abclib.dsw create mode 100644 abcspace.dsw delete mode 100644 abctestlib.dsp delete mode 100644 abctestlib.dsw delete mode 100644 demo.c create mode 100644 src/aig/cec/cec.c delete mode 100644 src/aig/cec/cecAig.c delete mode 100644 src/aig/cec/cecCnf.c create mode 100644 src/aig/cec/cecPat.c delete mode 100644 src/aig/cec/cecSat.c delete mode 100644 src/aig/cec/cecSim.c create mode 100644 src/aig/cec/cecSolve.c delete mode 100644 src/aig/cec/cecStatus.c create mode 100644 src/aig/cec2/cec.h create mode 100644 src/aig/cec2/cecAig.c create mode 100644 src/aig/cec2/cecClass.c create mode 100644 src/aig/cec2/cecCnf.c create mode 100644 src/aig/cec2/cecCore.c create mode 100644 src/aig/cec2/cecInt.h create mode 100644 src/aig/cec2/cecMan.c create mode 100644 src/aig/cec2/cecSat.c create mode 100644 src/aig/cec2/cecSat2.c create mode 100644 src/aig/cec2/cecSim.c create mode 100644 src/aig/cec2/cecStatus.c create mode 100644 src/aig/cec2/cecSweep.c create mode 100644 src/aig/cec2/module.make create mode 100644 src/aig/gia/gia.c create mode 100644 src/aig/gia/gia.h create mode 100644 src/aig/gia/giaAig.c create mode 100644 src/aig/gia/giaAiger.c create mode 100644 src/aig/gia/giaCof.c create mode 100644 src/aig/gia/giaConstr.c create mode 100644 src/aig/gia/giaDfs.c create mode 100644 src/aig/gia/giaDup.c create mode 100644 src/aig/gia/giaFanout.c create mode 100644 src/aig/gia/giaForce.c create mode 100644 src/aig/gia/giaFrames.c create mode 100644 src/aig/gia/giaFront.c create mode 100644 src/aig/gia/giaGlitch.c create mode 100644 src/aig/gia/giaHash.c create mode 100644 src/aig/gia/giaLogic.c create mode 100644 src/aig/gia/giaMan.c create mode 100644 src/aig/gia/giaProp.c create mode 100644 src/aig/gia/giaSat.c create mode 100644 src/aig/gia/giaScl.c create mode 100644 src/aig/gia/giaSim.c create mode 100644 src/aig/gia/giaSolver.c create mode 100644 src/aig/gia/giaSolver_cnf.c create mode 100644 src/aig/gia/giaSwitch.c create mode 100644 src/aig/gia/giaTsim.c create mode 100644 src/aig/gia/giaUtil.c create mode 100644 src/aig/gia/module.make create mode 100644 src/demo.c create mode 100644 src/map/amap/amapLiberty.c create mode 100644 src/misc/util/abc_global.h delete mode 100644 src/misc/util/port_type.h diff --git a/Makefile b/Makefile index e17a5d08..8b0a68ab 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ MODULES := \ src/aig/bdc src/aig/bar src/aig/ntl src/aig/nwk \ src/aig/mfx src/aig/tim src/aig/saig src/aig/bbr \ src/aig/int src/aig/dch src/aig/ssw src/aig/cgt \ - src/aig/cec src/aig/fsim + src/aig/cec src/aig/gia default: $(PROG) diff --git a/abc.dsp b/abc.dsp deleted file mode 100644 index f0bad559..00000000 --- a/abc.dsp +++ /dev/null @@ -1,3695 +0,0 @@ -# Microsoft Developer Studio Project File - Name="abc" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=abc - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "abc.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "abc.mak" CFG="abc - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "abc - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "abc - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "abc - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/misc/bzlib" /I "src/misc/zlib" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/sat/nsat" /I "src/sat/psat" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /I "src/aig/mfx" /I "src/aig/saig" /I "src/aig/bbr" /I "src/aig/int" /I "src/aig/dch" /I "src/aig/ssw" /I "src/sat/lsat" /I "src/aig/cec" /I "src/aig/cgt" /I "src/aig/sec" /I "src/map/amap" /I "src/aig/fsim" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib m114pr.lib /nologo /subsystem:console /profile /machine:I386 /nodefaultlib:"libcp.lib libc.lib" /out:"_TEST/abc.exe" /libpath:"lib" - -!ELSEIF "$(CFG)" == "abc - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/misc/bzlib" /I "src/misc/zlib" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/sat/nsat" /I "src/sat/psat" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /I "src/aig/mfx" /I "src/aig/saig" /I "src/aig/bbr" /I "src/aig/int" /I "src/aig/dch" /I "src/aig/ssw" /I "src/sat/lsat" /I "src/aig/cec" /I "src/aig/cgt" /I "src/aig/sec" /I "src/map/amap" /I "src/aig/fsim" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /GZ /c -# SUBTRACT CPP /X -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib m114pd.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"libcpd.lib libcd.lib" /out:"_TEST/abc.exe" /pdbtype:sept /libpath:"lib" - -!ENDIF - -# Begin Target - -# Name "abc - Win32 Release" -# Name "abc - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Group "base" - -# PROP Default_Filter "" -# Begin Group "abc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\base\abc\abc.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcBlifMv.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcDfs.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcFanio.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcFunc.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcHie.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcLatch.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcLib.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcMinBase.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcNames.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcNetlist.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcNtk.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcObj.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcRefs.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcShow.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcSop.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abc\abcUtil.c -# End Source File -# End Group -# Begin Group "abci" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\base\abci\abc.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcAbc8.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcAttach.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcAuto.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcBalance.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcBidec.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcBmc.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcCas.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcClpBdd.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcClpSop.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcDar.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcDebug.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcDelay.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcDress.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcDsd.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcExtract.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcFpga.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcFpgaFast.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcFraig.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcFxu.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcGen.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcHaig.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcIf.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcIvy.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcLut.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcMap.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcMeasure.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcMerge.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcMini.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcMiter.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcMulti.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcMv.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcNtbdd.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcOdc.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcOrder.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcPart.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcPrint.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcProve.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcQbf.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcQuant.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcReach.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcRec.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcReconv.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcRefactor.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcRenode.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcReorder.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcRestruct.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcResub.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcRewrite.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcRr.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcSense.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcStrash.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcSweep.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcSymm.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcTiming.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcUnate.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcUnreach.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcVerify.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\abci\abcXsim.c -# End Source File -# End Group -# Begin Group "cmd" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\base\cmd\cmd.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\cmd\cmd.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\cmd\cmdAlias.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\cmd\cmdApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\cmd\cmdFlag.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\cmd\cmdHist.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\cmd\cmdInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\cmd\cmdUtils.c -# End Source File -# End Group -# Begin Group "io" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\base\io\io.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioabc.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadAiger.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadBaf.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadBench.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadBlif.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadBlifAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadBlifMv.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadDsd.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadEdif.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadEqn.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadPla.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioReadVerilog.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteAiger.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteBaf.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteBench.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteBlif.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteBlifMv.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteBook.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteCnf.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteDot.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteEqn.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteGml.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteList.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWritePla.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\io\ioWriteVerilog.c -# End Source File -# End Group -# Begin Group "main" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\base\main\libSupport.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\main\main.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\main\main.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\main\mainFrame.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\main\mainInit.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\main\mainInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\main\mainUtils.c -# End Source File -# End Group -# Begin Group "ver" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\base\ver\ver.h -# End Source File -# Begin Source File - -SOURCE=.\src\base\ver\verCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\ver\verFormula.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\ver\verParse.c -# End Source File -# Begin Source File - -SOURCE=.\src\base\ver\verStream.c -# End Source File -# End Group -# End Group -# Begin Group "bdd" - -# PROP Default_Filter "" -# Begin Group "cudd" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\bdd\cudd\cudd.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAddAbs.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAddApply.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAddFind.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAddInv.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAddIte.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAddNeg.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAddWalsh.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAndAbs.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAnneal.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddApa.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddAPI.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddApprox.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddBddAbs.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddBddCorr.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddBddIte.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddBridge.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddCache.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddClip.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddCof.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddCompose.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddDecomp.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddEssent.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddExact.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddExport.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddGenCof.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddGenetic.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddGroup.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddHarwell.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddInit.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddInteract.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddLCache.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddLevelQ.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddLinear.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddLiteral.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddMatMult.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddPriority.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddRead.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddRef.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddReorder.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddSign.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddSolve.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddSplit.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddSubsetHB.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddSubsetSP.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddSymmetry.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddTable.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddWindow.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddCount.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddFuncs.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddGroup.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddIsop.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddLin.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddMisc.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddPort.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddReord.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddSetop.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddSymm.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cudd\cuddZddUtil.c -# End Source File -# End Group -# Begin Group "epd" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\bdd\epd\epd.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\epd\epd.h -# End Source File -# End Group -# Begin Group "mtr" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\bdd\mtr\mtr.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\mtr\mtrBasic.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\mtr\mtrGroup.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\mtr\mtrInt.h -# End Source File -# End Group -# Begin Group "parse" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\bdd\parse\parse.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\parse\parseCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\parse\parseEqn.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\parse\parseInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\parse\parseStack.c -# End Source File -# End Group -# Begin Group "dsd" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsd.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsdApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsdCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsdInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsdLocal.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsdMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsdProc.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\dsd\dsdTree.c -# End Source File -# End Group -# Begin Group "reo" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\bdd\reo\reo.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoProfile.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoShuffle.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoSift.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoSwap.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoTest.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoTransfer.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\reo\reoUnits.c -# End Source File -# End Group -# Begin Group "cas" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\bdd\cas\cas.h -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cas\casCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\bdd\cas\casDec.c -# End Source File -# End Group -# End Group -# Begin Group "sat" - -# PROP Default_Filter "" -# Begin Group "msat" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\sat\msat\msat.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatActivity.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatClause.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatClauseVec.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatMem.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatOrderH.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatQueue.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatRead.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatSolverApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatSolverCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatSolverIo.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatSolverSearch.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatSort.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\msat\msatVec.c -# End Source File -# End Group -# Begin Group "fraig" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\sat\fraig\fraig.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigCanon.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigChoice.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigFanout.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigFeed.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigMem.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigNode.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigPrime.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigTable.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\fraig\fraigVec.c -# End Source File -# End Group -# Begin Group "csat" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\sat\csat\csat_apis.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\csat\csat_apis.h -# End Source File -# End Group -# Begin Group "bsat" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\sat\bsat\satInter.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satInterA.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satInterB.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satInterP.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satMem.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satMem.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satSolver.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satSolver.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satStore.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satStore.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satTrace.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\bsat\satVec.h -# End Source File -# End Group -# Begin Group "proof" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\sat\proof\pr.c -# End Source File -# Begin Source File - -SOURCE=.\src\sat\proof\pr.h -# End Source File -# End Group -# Begin Group "psat" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\sat\psat\m114p.h -# End Source File -# Begin Source File - -SOURCE=.\src\sat\psat\m114p_types.h -# End Source File -# End Group -# Begin Group "nsat" - -# PROP Default_Filter "" -# End Group -# Begin Group "lsat" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\sat\lsat\solver.h -# End Source File -# End Group -# End Group -# Begin Group "opt" - -# PROP Default_Filter "" -# Begin Group "fxu" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\fxu\fxu.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxu.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuCreate.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuHeapD.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuHeapS.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuList.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuMatrix.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuPair.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuPrint.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuReduce.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuSelect.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuSingle.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\fxu\fxuUpdate.c -# End Source File -# End Group -# Begin Group "rwr" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\rwr\rwr.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrDec.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrEva.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrExp.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrLib.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrPrint.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrTemp.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\rwr\rwrUtil.c -# End Source File -# End Group -# Begin Group "cut" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\cut\cut.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutExpand.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutList.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutMerge.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutNode.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutOracle.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutPre22.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutSeq.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\cut\cutTruth.c -# End Source File -# End Group -# Begin Group "dec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\dec\dec.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\dec\decAbc.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\dec\decFactor.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\dec\decMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\dec\decPrint.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\dec\decUtil.c -# End Source File -# End Group -# Begin Group "sim" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\sim\sim.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSeq.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSupp.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSwitch.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSym.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSymSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSymSim.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simSymStr.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\sim\simUtils.c -# End Source File -# End Group -# Begin Group "ret" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\ret\retArea.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\ret\retCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\ret\retDelay.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\ret\retFlow.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\ret\retIncrem.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\ret\retInit.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\ret\retInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\ret\retLvalue.c -# End Source File -# End Group -# Begin Group "res" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\res\res.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resDivs.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resFilter.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resSim.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resStrash.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\res\resWin.c -# End Source File -# End Group -# Begin Group "lpk" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\lpk\lpk.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkAbcDec.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkAbcDsd.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkAbcMux.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkAbcUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkMap.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkMulti.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkMux.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\lpk\lpkSets.c -# End Source File -# End Group -# Begin Group "fret" - -# PROP Default_Filter "" -# End Group -# Begin Group "mfs" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\opt\mfs\mfs.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsDiv.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsInter.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsResub.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsStrash.c -# End Source File -# Begin Source File - -SOURCE=.\src\opt\mfs\mfsWin.c -# End Source File -# End Group -# End Group -# Begin Group "map" - -# PROP Default_Filter "" -# Begin Group "fpga" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\map\fpga\fpga.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpga.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaCreate.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaCutUtils.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaFanout.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaLib.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaMatch.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaSwitch.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaTime.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaTruth.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaUtils.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\fpga\fpgaVec.c -# End Source File -# End Group -# Begin Group "mapper" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\map\mapper\mapper.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapper.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperCanon.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperCreate.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperCutUtils.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperFanout.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperLib.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperMatch.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperRefs.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperSuper.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperSwitch.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperTable.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperTime.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperTree.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperTruth.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperUtils.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mapper\mapperVec.c -# End Source File -# End Group -# Begin Group "mio" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\map\mio\mio.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mio\mio.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\mio\mioApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mio\mioFunc.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mio\mioInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\mio\mioRead.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\mio\mioUtils.c -# End Source File -# End Group -# Begin Group "super" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\map\super\super.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\super\super.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\super\superAnd.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\super\superGate.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\super\superInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\super\superWrite.c -# End Source File -# End Group -# Begin Group "if" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\map\if\if.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifLib.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifMap.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifReduce.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifTime.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifTruth.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\if\ifUtil.c -# End Source File -# End Group -# Begin Group "ply" - -# PROP Default_Filter "" -# End Group -# Begin Group "pcm" - -# PROP Default_Filter "" -# End Group -# Begin Group "amap" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\map\amap\amap.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapGraph.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapLib.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapMatch.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapMerge.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapOutput.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapParse.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapPerm.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapRead.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapRule.c -# End Source File -# Begin Source File - -SOURCE=.\src\map\amap\amapUniq.c -# End Source File -# End Group -# End Group -# Begin Group "misc" - -# PROP Default_Filter "" -# Begin Group "extra" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\extra\extra.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraBddAuto.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraBddCas.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraBddImage.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraBddKmap.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraBddMisc.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraBddSymm.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraBddUnate.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilBitMatrix.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilCanon.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilFile.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilMemory.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilMisc.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilProgress.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilReader.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilTruth.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\extra\extraUtilUtil.c -# End Source File -# End Group -# Begin Group "st" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\st\st.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\st\st.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\st\stmm.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\st\stmm.h -# End Source File -# End Group -# Begin Group "mvc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\mvc\mvc.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvc.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcCompare.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcContain.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcCover.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcCube.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcDivide.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcDivisor.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcList.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcLits.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcOpAlg.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcOpBool.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcPrint.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcSort.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\mvc\mvcUtils.c -# End Source File -# End Group -# Begin Group "vec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\vec\vec.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\vec\vecAtt.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\vec\vecFlt.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\vec\vecInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\vec\vecPtr.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\vec\vecStr.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\vec\vecVec.h -# End Source File -# End Group -# Begin Group "util" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\util\port_type.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\util\util_hack.h -# End Source File -# End Group -# Begin Group "nm" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\nm\nm.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\nm\nmApi.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\nm\nmInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\nm\nmTable.c -# End Source File -# End Group -# Begin Group "hash" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\hash\hash.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\hash\hashFlt.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\hash\hashInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\hash\hashPtr.h -# End Source File -# End Group -# Begin Group "bzlib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\bzlib\blocksort.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\bzlib.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\bzlib.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\bzlib_private.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\compress.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\crctable.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\decompress.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\huffman.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\bzlib\randtable.c -# End Source File -# End Group -# Begin Group "zlib" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\zlib\adler32.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\compress_.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\crc32.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\crc32.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\deflate.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\deflate.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\gzio.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\infback.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\inffast.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\inffast.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\inffixed.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\inflate.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\inflate.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\inftrees.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\inftrees.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\trees.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\trees.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\uncompr.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\zconf.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\zlib.h -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\zutil.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\zlib\zutil.h -# End Source File -# End Group -# End Group -# Begin Group "ai" - -# PROP Default_Filter "" -# Begin Group "hop" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\hop\hop.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopBalance.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopDfs.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopMem.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopObj.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopOper.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopTable.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopTruth.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\hop\hopUtil.c -# End Source File -# End Group -# Begin Group "ivy" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\ivy\ivy.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyBalance.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyCanon.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyCutTrav.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyDfs.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyDsd.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyFanout.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyFastMap.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyFraig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyHaig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyMem.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyMulti.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyObj.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyOper.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyResyn.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyRwr.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivySeq.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyShow.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyTable.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ivy\ivyUtil.c -# End Source File -# End Group -# Begin Group "rwt" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\rwt\rwt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\rwt\rwtDec.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\rwt\rwtMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\rwt\rwtUtil.c -# End Source File -# End Group -# Begin Group "deco" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\deco\deco.h -# End Source File -# End Group -# Begin Group "mem" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\mem\mem.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mem\mem.h -# End Source File -# End Group -# Begin Group "ioa" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\ioa\ioa.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ioa\ioaReadAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ioa\ioaUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ioa\ioaWriteAig.c -# End Source File -# End Group -# Begin Group "dar" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\dar\dar.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darBalance.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darData.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darLib.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darPrec.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darRefact.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darResub.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dar\darScript.c -# End Source File -# End Group -# Begin Group "fra" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\fra\fra.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraBmc.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraCec.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraClass.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraClau.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraClaus.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraCnf.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraHot.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraImp.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraInd.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraIndVer.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraLcr.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraPart.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraSec.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fra\fraSim.c -# End Source File -# End Group -# Begin Group "cnf" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\cnf\cnf.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfData.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfMap.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfPost.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cnf\cnfWrite.c -# End Source File -# End Group -# Begin Group "csw" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\csw\csw.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\csw\cswCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\csw\cswCut.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\csw\cswInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\csw\cswMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\csw\cswTable.c -# End Source File -# End Group -# Begin Group "kit" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\kit\cloud.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\cloud.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kit.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitBdd.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitCloud.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitDsd.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitFactor.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitGraph.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitHop.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitIsop.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitPla.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitSop.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\kit\kitTruth.c -# End Source File -# End Group -# Begin Group "bdc" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\bdc\bdc.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bdc\bdcCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bdc\bdcDec.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bdc\bdcInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bdc\bdcTable.c -# End Source File -# End Group -# Begin Group "aig" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\aig\aig.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigCanon.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigCuts.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigDfs.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigDup.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigFanout.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigFrames.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigInter.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigMem.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigMffc.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigObj.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigOper.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigOrder.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigPart.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigPartReg.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigPartSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigRepr.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigRet.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigRetF.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigScl.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigShow.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigTable.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigTiming.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigTruth.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigTsim.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\aig\aigWin.c -# End Source File -# End Group -# Begin Group "bar" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\bar\bar.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bar\bar.h -# End Source File -# End Group -# Begin Group "ntl" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\ntl\ntl.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlEc.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlExtract.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlFraig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlInsert.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlMap.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlObj.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlReadBlif.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlSweep.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlTable.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlTime.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ntl\ntlWriteBlif.c -# End Source File -# End Group -# Begin Group "tim" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\tim\tim.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\tim\tim.h -# End Source File -# End Group -# Begin Group "nwk" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\nwk\nwk.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkBidec.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkCheck.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkDfs.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkFanio.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkFlow.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkMap.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkMerge.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkMerge.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkObj.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkSpeedup.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkStrash.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkTiming.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nwk\nwkUtil.c -# End Source File -# End Group -# Begin Group "mfx" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\mfx\mfx.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxDiv.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxInter.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxResub.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxStrash.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\mfx\mfxWin.c -# End Source File -# End Group -# Begin Group "bbr" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\bbr\bbr.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bbr\bbrCex.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bbr\bbrImage.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bbr\bbrNtbdd.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\bbr\bbrReach.c -# End Source File -# End Group -# Begin Group "saig" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\saig\saig.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigAbs.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigBmc.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigBmc2.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigCone.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigDup.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigHaig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigInd.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigIoa.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigMiter.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigPhase.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigRetFwd.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigRetMin.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigRetStep.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigScl.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigSimExt.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigSimFast.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigSimMv.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigSimSeq.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigStrSim.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigSwitch.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigSynch.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigTrans.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\saig\saigWnd.c -# End Source File -# End Group -# Begin Group "int" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\int\int.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intContain.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intCtrex.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intDup.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intFrames.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intInter.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intM114.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intM114p.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\int\intUtil.c -# End Source File -# End Group -# Begin Group "dch" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\dch\dch.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchChoice.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchClass.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchCnf.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchSim.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchSimSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\dch\dchSweep.c -# End Source File -# End Group -# Begin Group "ssw" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\ssw\ssw.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswBmc.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswClass.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswCnf.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswDyn.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswIslands.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswLcorr.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswPairs.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswPart.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswSemi.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswSim.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswSimSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswSweep.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\ssw\sswUnique.c -# End Source File -# End Group -# Begin Group "cec" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\cec\cec.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecClass.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecCnf.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecSat.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecSim.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cec\cecStatus.c -# End Source File -# End Group -# Begin Group "cgt" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\cgt\cgt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cgt\cgtAig.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cgt\cgtCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cgt\cgtDecide.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cgt\cgtInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cgt\cgtMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\cgt\cgtSat.c -# End Source File -# End Group -# Begin Group "sec" - -# PROP Default_Filter "" -# End Group -# Begin Group "nal" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\nal\nal.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalFlop.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalFunc.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalModels.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalRead.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalUtil.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\nal\nalWrite.c -# End Source File -# End Group -# Begin Group "fsim" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\aig\fsim\fsim.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fsim\fsimCore.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fsim\fsimFront.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fsim\fsimInt.h -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fsim\fsimMan.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fsim\fsimSim.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fsim\fsimSwitch.c -# End Source File -# Begin Source File - -SOURCE=.\src\aig\fsim\fsimTsim.c -# End Source File -# End Group -# End Group -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/abc.dsw b/abc.dsw deleted file mode 100644 index 83f94950..00000000 --- a/abc.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "abc"=.\abc.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/abc.rc b/abc.rc index 6deeeb51..4e97d561 100644 --- a/abc.rc +++ b/abc.rc @@ -2,8 +2,8 @@ #set check # checks intermediate networks #set checkfio # prints warnings when fanins/fanouts are duplicated set checkread # checks new networks after reading from file -set backup # saves backup networks retrived by "undo" and "recall" -set savesteps 1 # sets the maximum number of backup networks to save +#set backup # saves backup networks retrived by "undo" and "recall" +#set savesteps 1 # sets the maximum number of backup networks to save set progressbar # display the progress bar # program names for internal calls @@ -45,6 +45,7 @@ alias pl print_level alias plat print_latch alias pio print_io alias pk print_kmap +alias pm print_miter alias ps print_stats alias psb print_stats -b alias psu print_supp diff --git a/abcexe.dsp b/abcexe.dsp new file mode 100644 index 00000000..96e719a4 --- /dev/null +++ b/abcexe.dsp @@ -0,0 +1,102 @@ +# Microsoft Developer Studio Project File - Name="abcexe" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=abcexe - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "abcexe.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "abcexe.mak" CFG="abcexe - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "abcexe - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "abcexe - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "abcexe - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "ReleaseExe" +# PROP BASE Intermediate_Dir "ReleaseExe" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "ReleaseExe" +# PROP Intermediate_Dir "ReleaseExe" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/misc/bzlib" /I "src/misc/zlib" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/sat/nsat" /I "src/sat/psat" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /I "src/aig/mfx" /I "src/aig/saig" /I "src/aig/bbr" /I "src/aig/int" /I "src/aig/dch" /I "src/aig/ssw" /I "src/sat/lsat" /I "src/aig/cec" /I "src/aig/cgt" /I "src/aig/sec" /I "src/map/amap" /I "src/aig/fsim" /I "src/aig/gia" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib lib\abcr.lib /nologo /subsystem:console /incremental:yes /debug /machine:I386 /out:"_TEST/abc.exe" + +!ELSEIF "$(CFG)" == "abcexe - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "DebugExe" +# PROP BASE Intermediate_Dir "DebugExe" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "DebugExe" +# PROP Intermediate_Dir "DebugExe" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/misc/bzlib" /I "src/misc/zlib" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/sat/nsat" /I "src/sat/psat" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /I "src/aig/mfx" /I "src/aig/saig" /I "src/aig/bbr" /I "src/aig/int" /I "src/aig/dch" /I "src/aig/ssw" /I "src/sat/lsat" /I "src/aig/cec" /I "src/aig/cgt" /I "src/aig/sec" /I "src/map/amap" /I "src/aig/fsim" /I "src/aig/gia" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib lib\abcd.lib /nologo /subsystem:console /debug /machine:I386 /out:"_TEST/abc.exe" + +!ENDIF + +# Begin Target + +# Name "abcexe - Win32 Release" +# Name "abcexe - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\src\base\main\main.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/abclib.dsp b/abclib.dsp index df244f0f..acdf9bdb 100644 --- a/abclib.dsp +++ b/abclib.dsp @@ -32,16 +32,16 @@ RSC=rc.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "abclib___Win32_Release" -# PROP BASE Intermediate_Dir "abclib___Win32_Release" +# PROP BASE Output_Dir "ReleaseLib" +# PROP BASE Intermediate_Dir "ReleaseLib" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "abclib\ReleaseLib" -# PROP Intermediate_Dir "abclib\ReleaseLib" +# PROP Output_Dir "ReleaseLib" +# PROP Intermediate_Dir "ReleaseLib" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "__STDC__" /D "HAVE_ASSERT_H" /FR /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/misc/bzlib" /I "src/misc/zlib" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/sat/nsat" /I "src/sat/psat" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /I "src/aig/mfx" /I "src/aig/saig" /I "src/aig/bbr" /I "src/aig/int" /I "src/aig/dch" /I "src/aig/ssw" /I "src/sat/lsat" /I "src/aig/cec" /I "src/aig/cgt" /I "src/aig/sec" /I "src/map/amap" /I "src/aig/fsim" /I "src/aig/gia" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -49,22 +49,22 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"abclib\abclib_release.lib" +# ADD LIB32 /nologo /out:"lib\abcr.lib" !ELSEIF "$(CFG)" == "abclib - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "abclib___Win32_Debug" -# PROP BASE Intermediate_Dir "abclib___Win32_Debug" +# PROP BASE Output_Dir "DebugLib" +# PROP BASE Intermediate_Dir "DebugLib" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "abclib\DebugLib" -# PROP Intermediate_Dir "abclib\DebugLib" +# PROP Output_Dir "DebugLib" +# PROP Intermediate_Dir "DebugLib" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "__STDC__" /D "HAVE_ASSERT_H" /FR /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "src/base/abc" /I "src/base/abci" /I "src/base/cmd" /I "src/base/io" /I "src/base/main" /I "src/base/ver" /I "src/bdd/cudd" /I "src/bdd/dsd" /I "src/bdd/epd" /I "src/bdd/mtr" /I "src/bdd/parse" /I "src/bdd/reo" /I "src/bdd/cas" /I "src/map/fpga" /I "src/map/mapper" /I "src/map/mio" /I "src/map/super" /I "src/map/if" /I "src/map/pcm" /I "src/map/ply" /I "src/misc/extra" /I "src/misc/mvc" /I "src/misc/st" /I "src/misc/util" /I "src/misc/espresso" /I "src/misc/nm" /I "src/misc/vec" /I "src/misc/hash" /I "src/misc/bzlib" /I "src/misc/zlib" /I "src/opt/cut" /I "src/opt/dec" /I "src/opt/fxu" /I "src/opt/rwr" /I "src/opt/sim" /I "src/opt/ret" /I "src/opt/res" /I "src/opt/lpk" /I "src/sat/bsat" /I "src/sat/csat" /I "src/sat/msat" /I "src/sat/fraig" /I "src/sat/nsat" /I "src/sat/psat" /I "src/aig/ivy" /I "src/aig/hop" /I "src/aig/rwt" /I "src/aig/deco" /I "src/aig/mem" /I "src/aig/dar" /I "src/aig/fra" /I "src/aig/cnf" /I "src/aig/csw" /I "src/aig/ioa" /I "src/aig/aig" /I "src/aig/kit" /I "src/aig/bdc" /I "src/aig/bar" /I "src/aig/ntl" /I "src/aig/nwk" /I "src/aig/tim" /I "src/opt/mfs" /I "src/aig/mfx" /I "src/aig/saig" /I "src/aig/bbr" /I "src/aig/int" /I "src/aig/dch" /I "src/aig/ssw" /I "src/sat/lsat" /I "src/aig/cec" /I "src/aig/cgt" /I "src/aig/sec" /I "src/map/amap" /I "src/aig/fsim" /I "src/aig/gia" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__STDC__" /D ABC_DLL=ABC_DLLEXPORT /D "_CRT_SECURE_NO_DEPRECATE" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -72,7 +72,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo -# ADD LIB32 /nologo /out:"abclib\abclib_debug.lib" +# ADD LIB32 /nologo /out:"lib\abcd.lib" !ENDIF @@ -179,6 +179,10 @@ SOURCE=.\src\base\abci\abc.c # End Source File # Begin Source File +SOURCE=.\src\base\abci\abcAbc8.c +# End Source File +# Begin Source File + SOURCE=.\src\base\abci\abcAttach.c # End Source File # Begin Source File @@ -191,6 +195,10 @@ SOURCE=.\src\base\abci\abcBalance.c # End Source File # Begin Source File +SOURCE=.\src\base\abci\abcBidec.c +# End Source File +# Begin Source File + SOURCE=.\src\base\abci\abcBmc.c # End Source File # Begin Source File @@ -219,15 +227,15 @@ SOURCE=.\src\base\abci\abcDebug.c # End Source File # Begin Source File -SOURCE=.\src\base\abci\abcDress.c +SOURCE=.\src\base\abci\abcDelay.c # End Source File # Begin Source File -SOURCE=.\src\base\abci\abcDsd.c +SOURCE=.\src\base\abci\abcDress.c # End Source File # Begin Source File -SOURCE=.\src\base\abci\abcEspresso.c +SOURCE=.\src\base\abci\abcDsd.c # End Source File # Begin Source File @@ -279,6 +287,10 @@ SOURCE=.\src\base\abci\abcMeasure.c # End Source File # Begin Source File +SOURCE=.\src\base\abci\abcMerge.c +# End Source File +# Begin Source File + SOURCE=.\src\base\abci\abcMini.c # End Source File # Begin Source File @@ -327,7 +339,7 @@ SOURCE=.\src\base\abci\abcQuant.c # End Source File # Begin Source File -SOURCE=.\src\base\abci\abcRec.c +SOURCE=.\src\base\abci\abcReach.c # End Source File # Begin Source File @@ -367,6 +379,10 @@ SOURCE=.\src\base\abci\abcSat.c # End Source File # Begin Source File +SOURCE=.\src\base\abci\abcSense.c +# End Source File +# Begin Source File + SOURCE=.\src\base\abci\abcStrash.c # End Source File # Begin Source File @@ -443,7 +459,7 @@ SOURCE=.\src\base\io\io.c # End Source File # Begin Source File -SOURCE=.\src\base\io\io.h +SOURCE=.\src\base\io\ioabc.h # End Source File # Begin Source File @@ -519,6 +535,10 @@ SOURCE=.\src\base\io\ioWriteBlifMv.c # End Source File # Begin Source File +SOURCE=.\src\base\io\ioWriteBook.c +# End Source File +# Begin Source File + SOURCE=.\src\base\io\ioWriteCnf.c # End Source File # Begin Source File @@ -555,10 +575,6 @@ SOURCE=.\src\base\main\libSupport.c # End Source File # Begin Source File -SOURCE=.\src\base\main\main.c -# End Source File -# Begin Source File - SOURCE=.\src\base\main\main.h # End Source File # Begin Source File @@ -975,6 +991,10 @@ SOURCE=.\src\bdd\reo\reoProfile.c # End Source File # Begin Source File +SOURCE=.\src\bdd\reo\reoShuffle.c +# End Source File +# Begin Source File + SOURCE=.\src\bdd\reo\reoSift.c # End Source File # Begin Source File @@ -1163,6 +1183,18 @@ SOURCE=.\src\sat\bsat\satInter.c # End Source File # Begin Source File +SOURCE=.\src\sat\bsat\satInterA.c +# End Source File +# Begin Source File + +SOURCE=.\src\sat\bsat\satInterB.c +# End Source File +# Begin Source File + +SOURCE=.\src\sat\bsat\satInterP.c +# End Source File +# Begin Source File + SOURCE=.\src\sat\bsat\satMem.c # End Source File # Begin Source File @@ -1210,6 +1242,30 @@ SOURCE=.\src\sat\proof\pr.c SOURCE=.\src\sat\proof\pr.h # End Source File # End Group +# Begin Group "psat" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\sat\psat\m114p.h +# End Source File +# Begin Source File + +SOURCE=.\src\sat\psat\m114p_types.h +# End Source File +# End Group +# Begin Group "nsat" + +# PROP Default_Filter "" +# End Group +# Begin Group "lsat" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\sat\lsat\solver.h +# End Source File +# End Group # End Group # Begin Group "opt" @@ -1578,6 +1634,54 @@ SOURCE=.\src\opt\lpk\lpkMux.c SOURCE=.\src\opt\lpk\lpkSets.c # End Source File # End Group +# Begin Group "fret" + +# PROP Default_Filter "" +# End Group +# Begin Group "mfs" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\opt\mfs\mfs.h +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsDiv.c +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsInter.c +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsResub.c +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsSat.c +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsStrash.c +# End Source File +# Begin Source File + +SOURCE=.\src\opt\mfs\mfsWin.c +# End Source File +# End Group # End Group # Begin Group "map" @@ -1807,19 +1911,19 @@ SOURCE=.\src\map\if\ifCut.c # End Source File # Begin Source File -SOURCE=.\src\map\if\ifMan.c +SOURCE=.\src\map\if\ifLib.c # End Source File # Begin Source File -SOURCE=.\src\map\if\ifMap.c +SOURCE=.\src\map\if\ifMan.c # End Source File # Begin Source File -SOURCE=.\src\map\if\ifReduce.c +SOURCE=.\src\map\if\ifMap.c # End Source File # Begin Source File -SOURCE=.\src\map\if\ifSeq.c +SOURCE=.\src\map\if\ifReduce.c # End Source File # Begin Source File @@ -1834,6 +1938,78 @@ SOURCE=.\src\map\if\ifTruth.c SOURCE=.\src\map\if\ifUtil.c # End Source File # End Group +# Begin Group "ply" + +# PROP Default_Filter "" +# End Group +# Begin Group "pcm" + +# PROP Default_Filter "" +# End Group +# Begin Group "amap" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\map\amap\amap.h +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapGraph.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapLib.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapLiberty.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapMatch.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapMerge.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapOutput.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapParse.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapPerm.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapRead.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapRule.c +# End Source File +# Begin Source File + +SOURCE=.\src\map\amap\amapUniq.c +# End Source File +# End Group # End Group # Begin Group "misc" @@ -1855,6 +2031,10 @@ SOURCE=.\src\misc\extra\extraBddCas.c # End Source File # Begin Source File +SOURCE=.\src\misc\extra\extraBddImage.c +# End Source File +# Begin Source File + SOURCE=.\src\misc\extra\extraBddKmap.c # End Source File # Begin Source File @@ -1926,14 +2106,6 @@ SOURCE=.\src\misc\st\stmm.c SOURCE=.\src\misc\st\stmm.h # End Source File # End Group -# Begin Group "util" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\src\misc\util\util_hack.h -# End Source File -# End Group # Begin Group "mvc" # PROP Default_Filter "" @@ -2038,228 +2210,188 @@ SOURCE=.\src\misc\vec\vecStr.h SOURCE=.\src\misc\vec\vecVec.h # End Source File # End Group -# Begin Group "espresso" +# Begin Group "util" # PROP Default_Filter "" # Begin Source File -SOURCE=.\src\misc\espresso\cofactor.c +SOURCE=.\src\misc\util\abc_global.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\cols.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\compl.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\contain.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\cubehack.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\cubestr.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\cvrin.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\cvrm.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\cvrmisc.c -# End Source File -# Begin Source File - -SOURCE=.\src\misc\espresso\cvrout.c +SOURCE=.\src\misc\util\util_hack.h # End Source File -# Begin Source File +# End Group +# Begin Group "nm" -SOURCE=.\src\misc\espresso\dominate.c -# End Source File +# PROP Default_Filter "" # Begin Source File -SOURCE=.\src\misc\espresso\equiv.c +SOURCE=.\src\misc\nm\nm.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\espresso.c +SOURCE=.\src\misc\nm\nmApi.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\espresso.h +SOURCE=.\src\misc\nm\nmInt.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\essen.c +SOURCE=.\src\misc\nm\nmTable.c # End Source File -# Begin Source File +# End Group +# Begin Group "hash" -SOURCE=.\src\misc\espresso\exact.c -# End Source File +# PROP Default_Filter "" # Begin Source File -SOURCE=.\src\misc\espresso\expand.c +SOURCE=.\src\misc\hash\hash.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\gasp.c +SOURCE=.\src\misc\hash\hashFlt.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\gimpel.c +SOURCE=.\src\misc\hash\hashInt.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\globals.c +SOURCE=.\src\misc\hash\hashPtr.h # End Source File -# Begin Source File +# End Group +# Begin Group "bzlib" -SOURCE=.\src\misc\espresso\hack.c -# End Source File +# PROP Default_Filter "" # Begin Source File -SOURCE=.\src\misc\espresso\indep.c +SOURCE=.\src\misc\bzlib\blocksort.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\irred.c +SOURCE=.\src\misc\bzlib\bzlib.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\map.c +SOURCE=.\src\misc\bzlib\bzlib.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\matrix.c +SOURCE=.\src\misc\bzlib\bzlib_private.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\mincov.c +SOURCE=.\src\misc\bzlib\compress.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\mincov.h +SOURCE=.\src\misc\bzlib\crctable.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\mincov_int.h +SOURCE=.\src\misc\bzlib\decompress.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\opo.c +SOURCE=.\src\misc\bzlib\huffman.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\pair.c +SOURCE=.\src\misc\bzlib\randtable.c # End Source File -# Begin Source File +# End Group +# Begin Group "zlib" -SOURCE=.\src\misc\espresso\part.c -# End Source File +# PROP Default_Filter "" # Begin Source File -SOURCE=.\src\misc\espresso\primes.c +SOURCE=.\src\misc\zlib\adler32.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\reduce.c +SOURCE=.\src\misc\zlib\compress_.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\rows.c +SOURCE=.\src\misc\zlib\crc32.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\set.c +SOURCE=.\src\misc\zlib\crc32.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\setc.c +SOURCE=.\src\misc\zlib\deflate.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\sharp.c +SOURCE=.\src\misc\zlib\deflate.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\sminterf.c +SOURCE=.\src\misc\zlib\gzio.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\solution.c +SOURCE=.\src\misc\zlib\infback.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\sparse.c +SOURCE=.\src\misc\zlib\inffast.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\sparse.h +SOURCE=.\src\misc\zlib\inffast.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\sparse_int.h +SOURCE=.\src\misc\zlib\inffixed.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\unate.c +SOURCE=.\src\misc\zlib\inflate.c # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\util_old.h +SOURCE=.\src\misc\zlib\inflate.h # End Source File # Begin Source File -SOURCE=.\src\misc\espresso\verify.c +SOURCE=.\src\misc\zlib\inftrees.c # End Source File -# End Group -# Begin Group "nm" - -# PROP Default_Filter "" # Begin Source File -SOURCE=.\src\misc\nm\nm.h +SOURCE=.\src\misc\zlib\inftrees.h # End Source File # Begin Source File -SOURCE=.\src\misc\nm\nmApi.c +SOURCE=.\src\misc\zlib\trees.c # End Source File # Begin Source File -SOURCE=.\src\misc\nm\nmInt.h +SOURCE=.\src\misc\zlib\trees.h # End Source File # Begin Source File -SOURCE=.\src\misc\nm\nmTable.c +SOURCE=.\src\misc\zlib\uncompr.c # End Source File -# End Group -# Begin Group "hash" - -# PROP Default_Filter "" # Begin Source File -SOURCE=.\src\misc\hash\hash.h +SOURCE=.\src\misc\zlib\zconf.h # End Source File # Begin Source File -SOURCE=.\src\misc\hash\hashFlt.h +SOURCE=.\src\misc\zlib\zlib.h # End Source File # Begin Source File -SOURCE=.\src\misc\hash\hashInt.h +SOURCE=.\src\misc\zlib\zutil.c # End Source File # Begin Source File -SOURCE=.\src\misc\hash\hashPtr.h +SOURCE=.\src\misc\zlib\zutil.h # End Source File # End Group # End Group @@ -2307,6 +2439,10 @@ SOURCE=.\src\aig\hop\hopTable.c # End Source File # Begin Source File +SOURCE=.\src\aig\hop\hopTruth.c +# End Source File +# Begin Source File + SOURCE=.\src\aig\hop\hopUtil.c # End Source File # End Group @@ -2539,6 +2675,14 @@ SOURCE=.\src\aig\fra\fraClass.c # End Source File # Begin Source File +SOURCE=.\src\aig\fra\fraClau.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\fra\fraClaus.c +# End Source File +# Begin Source File + SOURCE=.\src\aig\fra\fraCnf.c # End Source File # Begin Source File @@ -2547,6 +2691,10 @@ SOURCE=.\src\aig\fra\fraCore.c # End Source File # Begin Source File +SOURCE=.\src\aig\fra\fraHot.c +# End Source File +# Begin Source File + SOURCE=.\src\aig\fra\fraImp.c # End Source File # Begin Source File @@ -2555,6 +2703,10 @@ SOURCE=.\src\aig\fra\fraInd.c # End Source File # Begin Source File +SOURCE=.\src\aig\fra\fraIndVer.c +# End Source File +# Begin Source File + SOURCE=.\src\aig\fra\fraLcr.c # End Source File # Begin Source File @@ -2695,6 +2847,10 @@ SOURCE=.\src\aig\kit\kitIsop.c # End Source File # Begin Source File +SOURCE=.\src\aig\kit\kitPla.c +# End Source File +# Begin Source File + SOURCE=.\src\aig\kit\kitSop.c # End Source File # Begin Source File @@ -2735,35 +2891,55 @@ SOURCE=.\src\aig\aig\aig.h # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigCheck.c +SOURCE=.\src\aig\aig\aigCanon.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigDfs.c +SOURCE=.\src\aig\aig\aigCheck.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigFanout.c +SOURCE=.\src\aig\aig\aigCuts.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigMan.c +SOURCE=.\src\aig\aig\aigDfs.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigMem.c +SOURCE=.\src\aig\aig\aigDup.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigMffc.c +SOURCE=.\src\aig\aig\aigFanout.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigObj.c +SOURCE=.\src\aig\aig\aigFrames.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigOper.c +SOURCE=.\src\aig\aig\aigInter.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\aig\aigMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\aig\aigMem.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\aig\aigMffc.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\aig\aigObj.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\aig\aigOper.c # End Source File # Begin Source File @@ -2775,6 +2951,14 @@ SOURCE=.\src\aig\aig\aigPart.c # End Source File # Begin Source File +SOURCE=.\src\aig\aig\aigPartReg.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\aig\aigPartSat.c +# End Source File +# Begin Source File + SOURCE=.\src\aig\aig\aigRepr.c # End Source File # Begin Source File @@ -2783,11 +2967,11 @@ SOURCE=.\src\aig\aig\aigRet.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigScl.c +SOURCE=.\src\aig\aig\aigRetF.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigSeq.c +SOURCE=.\src\aig\aig\aigScl.c # End Source File # Begin Source File @@ -2799,10 +2983,6 @@ SOURCE=.\src\aig\aig\aigTable.c # End Source File # Begin Source File -SOURCE=.\src\aig\aig\aigTime.c -# End Source File -# Begin Source File - SOURCE=.\src\aig\aig\aigTiming.c # End Source File # Begin Source File @@ -2834,6 +3014,670 @@ SOURCE=.\src\aig\bar\bar.c SOURCE=.\src\aig\bar\bar.h # End Source File # End Group +# Begin Group "ntl" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\ntl\ntl.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlCheck.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlEc.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlExtract.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlFraig.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlInsert.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlMap.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlObj.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlReadBlif.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlSweep.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlTable.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlTime.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlUtil.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ntl\ntlWriteBlif.c +# End Source File +# End Group +# Begin Group "tim" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\tim\tim.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\tim\tim.h +# End Source File +# End Group +# Begin Group "nwk" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\nwk\nwk.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkAig.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkBidec.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkCheck.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkDfs.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkFanio.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkFlow.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkMap.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkMerge.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkMerge.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkObj.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkSpeedup.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkStrash.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkTiming.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\nwk\nwkUtil.c +# End Source File +# End Group +# Begin Group "mfx" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\mfx\mfx.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxDiv.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxInter.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxResub.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxSat.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxStrash.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\mfx\mfxWin.c +# End Source File +# End Group +# Begin Group "bbr" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\bbr\bbr.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\bbr\bbrCex.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\bbr\bbrImage.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\bbr\bbrNtbdd.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\bbr\bbrReach.c +# End Source File +# End Group +# Begin Group "saig" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\saig\saig.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigAbs.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigBmc.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigBmc2.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigCone.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigDup.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigHaig.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigInd.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigIoa.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigMiter.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigPhase.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigRetFwd.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigRetMin.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigRetStep.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigScl.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigSimExt.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigSimFast.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigSimMv.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigSimSeq.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigStrSim.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigSwitch.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigSynch.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigTrans.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\saig\saigWnd.c +# End Source File +# End Group +# Begin Group "int" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\int\int.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intContain.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intCtrex.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intDup.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intFrames.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intInter.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intM114.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intM114p.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\int\intUtil.c +# End Source File +# End Group +# Begin Group "dch" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\dch\dch.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchAig.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchChoice.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchClass.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchCnf.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchSat.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchSim.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchSimSat.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\dch\dchSweep.c +# End Source File +# End Group +# Begin Group "ssw" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\ssw\ssw.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswAig.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswBmc.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswClass.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswCnf.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswDyn.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswIslands.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswLcorr.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswPairs.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswPart.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswSat.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswSemi.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswSim.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswSimSat.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswSweep.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\ssw\sswUnique.c +# End Source File +# End Group +# Begin Group "cec" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\cec\cec.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cec\cecClass.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cec\cecCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cec\cecInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cec\cecMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cec\cecPat.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cec\cecSolve.c +# End Source File +# End Group +# Begin Group "cgt" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\cgt\cgt.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cgt\cgtAig.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cgt\cgtCore.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cgt\cgtDecide.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cgt\cgtInt.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cgt\cgtMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\cgt\cgtSat.c +# End Source File +# End Group +# Begin Group "sec" + +# PROP Default_Filter "" +# End Group +# Begin Group "nal" + +# PROP Default_Filter "" +# End Group +# Begin Group "fsim" + +# PROP Default_Filter "" +# End Group +# Begin Group "gia" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\src\aig\gia\gia.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\gia.h +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaAig.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaAiger.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaCof.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaDfs.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaDup.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaFanout.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaForce.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaFrames.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaFront.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaGlitch.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaHash.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaLogic.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaMan.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaScl.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaSim.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaSolver.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaSwitch.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaTsim.c +# End Source File +# Begin Source File + +SOURCE=.\src\aig\gia\giaUtil.c +# End Source File +# End Group # End Group # End Group # Begin Group "Header Files" diff --git a/abclib.dsw b/abclib.dsw deleted file mode 100644 index 260ade17..00000000 --- a/abclib.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "abclib"=.\abclib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/abcspace.dsw b/abcspace.dsw new file mode 100644 index 00000000..0f69c0df --- /dev/null +++ b/abcspace.dsw @@ -0,0 +1,44 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "abcexe"=.\abcexe.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ + Begin Project Dependency + Project_Dep_Name abclib + End Project Dependency +}}} + +############################################################################### + +Project: "abclib"=.\abclib.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/abctestlib.dsp b/abctestlib.dsp deleted file mode 100644 index e901cbda..00000000 --- a/abctestlib.dsp +++ /dev/null @@ -1,102 +0,0 @@ -# Microsoft Developer Studio Project File - Name="abctestlib" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=abctestlib - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "abctestlib.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "abctestlib.mak" CFG="abctestlib - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "abctestlib - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "abctestlib - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "abctestlib - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib C:\_projects\abc\abclib\abclib_release.lib /nologo /subsystem:console /machine:I386 /out:"_TEST/abctestlib.exe" - -!ELSEIF "$(CFG)" == "abctestlib - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib C:\_projects\abc\abclib\abclib_debug.lib /nologo /subsystem:console /debug /machine:I386 /out:"_TEST/abctestlib.exe" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "abctestlib - Win32 Release" -# Name "abctestlib - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\demo.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/abctestlib.dsw b/abctestlib.dsw deleted file mode 100644 index 7ae6cac9..00000000 --- a/abctestlib.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "abctestlib"=.\abctestlib.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/demo.c b/demo.c deleted file mode 100644 index de162409..00000000 --- a/demo.c +++ /dev/null @@ -1,181 +0,0 @@ -/**CFile**************************************************************** - - FileName [demo.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [ABC as a static library.] - - Synopsis [A demo program illustrating the use of ABC as a static library.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: demo.c,v 1.00 2005/11/14 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include -#include - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -// procedures to start and stop the ABC framework -// (should be called before and after the ABC procedures are called) -extern void Abc_Start(); -extern void Abc_Stop(); - -// procedures to get the ABC framework and execute commands in it -extern void * Abc_FrameGetGlobalFrame(); -extern int Cmd_CommandExecute( void * pAbc, char * sCommand ); - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [The main() procedure.] - - Description [This procedure compiles into a stand-alone program for - DAG-aware rewriting of the AIGs. A BLIF or PLA file to be considered - for rewriting should be given as a command-line argument. Implementation - of the rewriting is inspired by the paper: Per Bjesse, Arne Boralv, - "DAG-aware circuit compression for formal verification", Proc. ICCAD 2004.] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int main( int argc, char * argv[] ) -{ - // parameters - int fUseResyn2 = 0; - int fPrintStats = 1; - int fVerify = 1; - // variables - void * pAbc; - char * pFileName; - char Command[1000]; - int clkRead, clkResyn, clkVer, clk; - - ////////////////////////////////////////////////////////////////////////// - // get the input file name - if ( argc != 2 ) - { - printf( "Wrong number of command-line arguments.\n" ); - return 1; - } - pFileName = argv[1]; - - ////////////////////////////////////////////////////////////////////////// - // start the ABC framework - Abc_Start(); - pAbc = Abc_FrameGetGlobalFrame(); - -clk = clock(); - ////////////////////////////////////////////////////////////////////////// - // read the file - sprintf( Command, "read %s", pFileName ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } - - ////////////////////////////////////////////////////////////////////////// - // balance - sprintf( Command, "balance" ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } -clkRead = clock() - clk; - - ////////////////////////////////////////////////////////////////////////// - // print stats - if ( fPrintStats ) - { - sprintf( Command, "print_stats" ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } - } - -clk = clock(); - ////////////////////////////////////////////////////////////////////////// - // synthesize - if ( fUseResyn2 ) - { - sprintf( Command, "balance; rewrite -l; refactor -l; balance; rewrite -l; rewrite -lz; balance; refactor -lz; rewrite -lz; balance" ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } - } - else - { - sprintf( Command, "balance; rewrite -l; rewrite -lz; balance; rewrite -lz; balance" ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } - } -clkResyn = clock() - clk; - - ////////////////////////////////////////////////////////////////////////// - // print stats - if ( fPrintStats ) - { - sprintf( Command, "print_stats" ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } - } - - ////////////////////////////////////////////////////////////////////////// - // write the result in blif - sprintf( Command, "write_blif result.blif" ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } - - ////////////////////////////////////////////////////////////////////////// - // perform verification -clk = clock(); - if ( fVerify ) - { - sprintf( Command, "cec %s result.blif", pFileName ); - if ( Cmd_CommandExecute( pAbc, Command ) ) - { - fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); - return 1; - } - } -clkVer = clock() - clk; - - printf( "Reading = %6.2f sec ", (float)(clkRead)/(float)(CLOCKS_PER_SEC) ); - printf( "Rewriting = %6.2f sec ", (float)(clkResyn)/(float)(CLOCKS_PER_SEC) ); - printf( "Verification = %6.2f sec\n", (float)(clkVer)/(float)(CLOCKS_PER_SEC) ); - - ////////////////////////////////////////////////////////////////////////// - // stop the ABC framework - Abc_Stop(); - return 0; -} - diff --git a/src/aig/aig/aig.h b/src/aig/aig/aig.h index 3db9b845..d9e57f7e 100644 --- a/src/aig/aig/aig.h +++ b/src/aig/aig/aig.h @@ -21,10 +21,6 @@ #ifndef __AIG_H__ #define __AIG_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -41,6 +37,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -196,17 +196,6 @@ struct Aig_ManCut_t_ unsigned * puTemp[4]; // used for the truth table computation }; -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - static inline Aig_Cut_t * Aig_ObjCuts( Aig_ManCut_t * p, Aig_Obj_t * pObj ) { return p->pCuts[pObj->Id]; } static inline void Aig_ObjSetCuts( Aig_ManCut_t * p, Aig_Obj_t * pObj, Aig_Cut_t * pCuts ) { p->pCuts[pObj->Id] = pCuts; } @@ -231,16 +220,12 @@ static inline Aig_Cut_t * Aig_CutNext( Aig_Cut_t * pCut ) { return #define AIG_ABS(a) (((a) >= 0)? (a) :-(a)) #define AIG_INFINITY (100000000) -#ifndef PRT -#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)) -#endif - static inline int Aig_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 char * Aig_UtilStrsav( char * s ) { return s ? strcpy(ALLOC(char, strlen(s)+1), s) : NULL; } +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)); } static inline int Aig_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; } @@ -265,10 +250,10 @@ static inline int Aig_WordFindFirstBit( unsigned uWord ) return -1; } -static inline Aig_Obj_t * Aig_Regular( Aig_Obj_t * p ) { return (Aig_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); } -static inline Aig_Obj_t * Aig_Not( Aig_Obj_t * p ) { return (Aig_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); } -static inline Aig_Obj_t * Aig_NotCond( Aig_Obj_t * p, int c ) { return (Aig_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); } -static inline int Aig_IsComplement( Aig_Obj_t * p ) { return (int)((PORT_PTRUINT_T)(p) & 01); } +static inline Aig_Obj_t * Aig_Regular( Aig_Obj_t * p ) { return (Aig_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); } +static inline Aig_Obj_t * Aig_Not( Aig_Obj_t * p ) { return (Aig_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); } +static inline Aig_Obj_t * Aig_NotCond( Aig_Obj_t * p, int c ) { return (Aig_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); } +static inline int Aig_IsComplement( Aig_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); } static inline int Aig_ManPiNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_PI]; } static inline int Aig_ManPoNum( Aig_Man_t * p ) { return p->nObjs[AIG_OBJ_PO]; } @@ -344,7 +329,7 @@ static inline void Aig_ObjSetEquiv( Aig_Man_t * p, Aig_Obj_t * pObj, Aig static inline Aig_Obj_t * Aig_ObjRepr( Aig_Man_t * p, Aig_Obj_t * pObj ) { return p->pReprs? p->pReprs[pObj->Id] : NULL; } static inline void Aig_ObjSetRepr( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pRepr ) { assert(p->pReprs); p->pReprs[pObj->Id] = pRepr; } static inline Aig_Obj_t * Aig_ObjHaig( Aig_Obj_t * pObj ) { assert( Aig_Regular(pObj)->pHaig ); return Aig_NotCond( Aig_Regular(pObj)->pHaig, Aig_IsComplement(pObj) ); } -static inline int Aig_ObjPioNum( Aig_Obj_t * pObj ) { assert( !Aig_ObjIsNode(pObj) ); return (int)(PORT_PTRINT_T)pObj->pNext; } +static inline int Aig_ObjPioNum( Aig_Obj_t * pObj ) { assert( !Aig_ObjIsNode(pObj) ); return (int)(ABC_PTRINT_T)pObj->pNext; } static inline int Aig_ObjWhatFanin( Aig_Obj_t * pObj, Aig_Obj_t * pFanin ) { if ( Aig_ObjFanin0(pObj) == pFanin ) return 0; @@ -635,6 +620,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 int Aig_ManHasNoGaps( Aig_Man_t * p ); extern int Aig_ManLevels( Aig_Man_t * p ); extern void Aig_ManResetRefs( Aig_Man_t * p ); extern void Aig_ManCleanMarkA( Aig_Man_t * p ); @@ -658,9 +644,10 @@ extern void Aig_ManDumpBlif( Aig_Man_t * p, char * pFileName, Vec_Ptr extern void Aig_ManDumpVerilog( Aig_Man_t * p, char * pFileName ); extern void Aig_ManSetPioNumbers( Aig_Man_t * p ); extern void Aig_ManCleanPioNumbers( Aig_Man_t * p ); -extern int Aig_ManCountChoices( Aig_Man_t * p ); +extern int Aig_ManChoiceNum( Aig_Man_t * p ); extern char * Aig_FileNameGenericAppend( char * pBase, char * pSuffix ); extern unsigned Aig_ManRandom( int fReset ); +extern void Aig_ManRandomInfo( Vec_Ptr_t * vInfo, 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 ); diff --git a/src/aig/aig/aigCanon.c b/src/aig/aig/aigCanon.c index febad8ae..4f241842 100644 --- a/src/aig/aig/aigCanon.c +++ b/src/aig/aig/aigCanon.c @@ -96,14 +96,14 @@ Aig_RMan_t * Aig_RManStart() { static Bdc_Par_t Pars = {0}, * pPars = &Pars; Aig_RMan_t * p; - p = ALLOC( Aig_RMan_t, 1 ); + p = ABC_ALLOC( Aig_RMan_t, 1 ); memset( p, 0, sizeof(Aig_RMan_t) ); p->nVars = RMAN_MAXVARS; p->pAig = Aig_ManStart( 1000000 ); Aig_IthVar( p->pAig, p->nVars-1 ); // create hash table p->nBins = Aig_PrimeCudd(5000); - p->pBins = CALLOC( Aig_Tru_t *, p->nBins ); + p->pBins = ABC_CALLOC( Aig_Tru_t *, p->nBins ); p->pMemTrus = Aig_MmFlexStart(); // bi-decomposition manager pPars->nVarsMax = p->nVars; @@ -179,7 +179,7 @@ clk = clock(); nBinsOld = p->nBins; // get the new Bins p->nBins = Aig_PrimeCudd( 3 * nBinsOld ); - p->pBins = CALLOC( Aig_Tru_t *, p->nBins ); + p->pBins = ABC_CALLOC( Aig_Tru_t *, p->nBins ); // rehash the entries from the old table Counter = 0; for ( i = 0; i < nBinsOld; i++ ) @@ -195,8 +195,8 @@ clk = clock(); Counter++; } assert( Counter == p->nEntries ); -// PRT( "Time", clock() - clk ); - free( pBinsOld ); +// ABC_PRT( "Time", clock() - clk ); + ABC_FREE( pBinsOld ); } /**Function************************************************************* @@ -259,8 +259,8 @@ void Aig_RManStop( Aig_RMan_t * p ) Aig_MmFlexStop( p->pMemTrus, 0 ); Aig_ManStop( p->pAig ); Bdc_ManFree( p->pBidec ); - free( p->pBins ); - free( p ); + ABC_FREE( p->pBins ); + ABC_FREE( p ); } diff --git a/src/aig/aig/aigCuts.c b/src/aig/aig/aigCuts.c index 494d0d5b..dc677269 100644 --- a/src/aig/aig/aigCuts.c +++ b/src/aig/aig/aigCuts.c @@ -46,7 +46,7 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in assert( nCutsMax >= 2 ); assert( nLeafMax <= 16 ); // allocate the fraiging manager - p = ALLOC( Aig_ManCut_t, 1 ); + p = ABC_ALLOC( Aig_ManCut_t, 1 ); memset( p, 0, sizeof(Aig_ManCut_t) ); p->nCutsMax = nCutsMax; p->nLeafMax = nLeafMax; @@ -54,7 +54,7 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in p->fVerbose = fVerbose; p->pAig = pMan; // allocate room for cuts and equivalent nodes - p->pCuts = ALLOC( Aig_Cut_t *, Aig_ManObjNumMax(pMan) ); + p->pCuts = ABC_ALLOC( Aig_Cut_t *, Aig_ManObjNumMax(pMan) ); memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pMan) ); // allocate memory manager p->nTruthWords = Aig_TruthWordNum(nLeafMax); @@ -63,7 +63,7 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in // room for temporary truth tables if ( fTruth ) { - p->puTemp[0] = ALLOC( unsigned, 4 * p->nTruthWords ); + p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords ); p->puTemp[1] = p->puTemp[0] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords; @@ -85,9 +85,9 @@ Aig_ManCut_t * Aig_ManCutStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, in void Aig_ManCutStop( Aig_ManCut_t * p ) { Aig_MmFixedStop( p->pMemCuts, 0 ); - FREE( p->puTemp[0] ); - free( p->pCuts ); - free( p ); + ABC_FREE( p->puTemp[0] ); + ABC_FREE( p->pCuts ); + ABC_FREE( p ); } /**Function************************************************************* @@ -207,7 +207,7 @@ static inline float Aig_CutFindCost2( Aig_ManCut_t * p, Aig_Cut_t * pCut ) /**Function************************************************************* - Synopsis [Returns the next free cut to use.] + Synopsis [Returns the next ABC_FREE cut to use.] Description [] @@ -650,7 +650,7 @@ Aig_ManCut_t * Aig_ComputeCuts( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, in Aig_ManObjNum(pAig), nCuts, nLeafMax, nCutsK ); printf( "Cut size = %2d. Truth size = %2d. Total mem = %5.2f Mb ", p->nCutSize, 4*p->nTruthWords, 1.0*Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) ); - PRT( "Runtime", clock() - clk ); + ABC_PRT( "Runtime", clock() - clk ); /* Aig_ManForEachNode( pAig, pObj, i ) if ( i % 300 == 0 ) diff --git a/src/aig/aig/aigDup.c b/src/aig/aig/aigDup.c index ade1edc0..6c9cb499 100644 --- a/src/aig/aig/aigDup.c +++ b/src/aig/aig/aigDup.c @@ -431,12 +431,12 @@ Aig_Man_t * Aig_ManDupDfs( Aig_Man_t * p ) // duplicate representation of choice nodes if ( p->pEquivs ) { - pNew->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); + pNew->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); memset( pNew->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) ); } if ( p->pReprs ) { - pNew->pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); + pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) ); } // create the PIs @@ -578,12 +578,12 @@ Aig_Man_t * Aig_ManDupDfsGuided( Aig_Man_t * p, Aig_Man_t * pGuide ) // duplicate representation of choice nodes if ( p->pEquivs ) { - pNew->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); + pNew->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); memset( pNew->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) ); } if ( p->pReprs ) { - pNew->pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); + pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) ); } // create the PIs @@ -651,12 +651,12 @@ Aig_Man_t * Aig_ManDupLevelized( Aig_Man_t * p ) // duplicate representation of choice nodes if ( p->pEquivs ) { - pNew->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); + pNew->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); memset( pNew->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) ); } if ( p->pReprs ) { - pNew->pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); + pNew->pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); memset( pNew->pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) ); } // create the PIs diff --git a/src/aig/aig/aigFanout.c b/src/aig/aig/aigFanout.c index d0beb128..89702087 100644 --- a/src/aig/aig/aigFanout.c +++ b/src/aig/aig/aigFanout.c @@ -60,7 +60,7 @@ void Aig_ManFanoutStart( Aig_Man_t * p ) p->nFansAlloc = 2 * Aig_ManObjNumMax(p); if ( p->nFansAlloc < (1<<12) ) p->nFansAlloc = (1<<12); - p->pFanData = ALLOC( int, 5 * p->nFansAlloc ); + p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc ); memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc ); // add fanouts for all objects Aig_ManForEachObj( p, pObj, i ) @@ -86,7 +86,7 @@ void Aig_ManFanoutStart( Aig_Man_t * p ) void Aig_ManFanoutStop( Aig_Man_t * p ) { assert( p->pFanData != NULL ); - FREE( p->pFanData ); + ABC_FREE( p->pFanData ); p->nFansAlloc = 0; } @@ -110,7 +110,7 @@ void Aig_ObjAddFanout( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFanout ) if ( pObj->Id >= p->nFansAlloc || pFanout->Id >= p->nFansAlloc ) { int nFansAlloc = 2 * AIG_MAX( pObj->Id, pFanout->Id ); - p->pFanData = REALLOC( int, p->pFanData, 5 * nFansAlloc ); + p->pFanData = ABC_REALLOC( int, p->pFanData, 5 * nFansAlloc ); memset( p->pFanData + 5 * p->nFansAlloc, 0, sizeof(int) * 5 * (nFansAlloc - p->nFansAlloc) ); p->nFansAlloc = nFansAlloc; } diff --git a/src/aig/aig/aigFrames.c b/src/aig/aig/aigFrames.c index 4cd23290..f25f7a8f 100644 --- a/src/aig/aig/aigFrames.c +++ b/src/aig/aig/aigFrames.c @@ -53,7 +53,7 @@ Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int fOuts, int int i, f; // create mapping for the frames nodes - pObjMap = ALLOC( Aig_Obj_t *, nFs * Aig_ManObjNumMax(pAig) ); + pObjMap = ABC_ALLOC( Aig_Obj_t *, nFs * Aig_ManObjNumMax(pAig) ); memset( pObjMap, 0, sizeof(Aig_Obj_t *) * nFs * Aig_ManObjNumMax(pAig) ); // start the fraig package @@ -124,7 +124,7 @@ Aig_Man_t * Aig_ManFrames( Aig_Man_t * pAig, int nFs, int fInit, int fOuts, int if ( ppObjMap ) *ppObjMap = pObjMap; else - free( pObjMap ); + ABC_FREE( pObjMap ); return pFrames; } diff --git a/src/aig/aig/aigInter.c b/src/aig/aig/aigInter.c index 80198753..23c1dbf5 100644 --- a/src/aig/aig/aigInter.c +++ b/src/aig/aig/aigInter.c @@ -122,14 +122,14 @@ void Aig_ManInterFast( Aig_Man_t * pManOn, Aig_Man_t * pManOff, int fVerbose ) Lits[0] = toLitCond( pCnfOn->pVarNums[pObj->Id], 0 ); Lits[1] = toLitCond( pCnfOff->pVarNums[pObj2->Id], 0 ); - status = sat_solver_solve( pSat, Lits, Lits+2, (sint64)0, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, Lits, Lits+2, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status != l_False ) printf( "The incremental SAT problem is not UNSAT.\n" ); } Cnf_DataFree( pCnfOn ); Cnf_DataFree( pCnfOff ); sat_solver_delete( pSat ); -// PRT( "Fast interpolation time", clock() - clk ); +// ABC_PRT( "Fast interpolation time", clock() - clk ); } /**Function************************************************************* @@ -242,7 +242,7 @@ clk = clock(); */ // solve the problem - status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); timeSat += clock() - clk; if ( status == l_False ) { diff --git a/src/aig/aig/aigMan.c b/src/aig/aig/aigMan.c index a13550df..0b6ff6bd 100644 --- a/src/aig/aig/aigMan.c +++ b/src/aig/aig/aigMan.c @@ -47,7 +47,7 @@ Aig_Man_t * Aig_ManStart( int nNodesMax ) if ( nNodesMax <= 0 ) nNodesMax = 10007; // start the manager - p = ALLOC( Aig_Man_t, 1 ); + p = ABC_ALLOC( Aig_Man_t, 1 ); memset( p, 0, sizeof(Aig_Man_t) ); // perform initializations p->nTravIds = 1; @@ -66,7 +66,7 @@ Aig_Man_t * Aig_ManStart( int nNodesMax ) p->nObjs[AIG_OBJ_CONST1]++; // start the table p->nTableSize = Aig_PrimeCudd( nNodesMax ); - p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Aig_Obj_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize ); return p; } @@ -186,8 +186,8 @@ void Aig_ManStop( Aig_Man_t * p ) if ( p->vMapped ) Vec_PtrFree( p->vMapped ); // print time - if ( p->time1 ) { PRT( "time1", p->time1 ); } - if ( p->time2 ) { PRT( "time2", p->time2 ); } + 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 ); @@ -211,16 +211,16 @@ void Aig_ManStop( Aig_Man_t * p ) if ( p->vOnehots ) Vec_VecFree( (Vec_Vec_t *)p->vOnehots ); if ( p->vClockDoms) Vec_VecFree( p->vClockDoms ); if ( p->vProbs ) Vec_IntFree( p->vProbs ); - FREE( p->pFastSim ); - FREE( p->pData ); - FREE( p->pSeqModel ); - FREE( p->pName ); - FREE( p->pSpec ); - FREE( p->pObjCopies ); - FREE( p->pReprs ); - FREE( p->pEquivs ); - free( p->pTable ); - free( p ); + ABC_FREE( p->pFastSim ); + ABC_FREE( p->pData ); + ABC_FREE( p->pSeqModel ); + ABC_FREE( p->pName ); + ABC_FREE( p->pSpec ); + ABC_FREE( p->pObjCopies ); + ABC_FREE( p->pReprs ); + ABC_FREE( p->pEquivs ); + ABC_FREE( p->pTable ); + ABC_FREE( p ); } /**Function************************************************************* @@ -371,7 +371,7 @@ int Aig_ManHaigCounter( Aig_Man_t * pAig ) ***********************************************************************/ void Aig_ManPrintStats( Aig_Man_t * p ) { - int nChoices = Aig_ManCountChoices(p); + int nChoices = Aig_ManChoiceNum(p); printf( "%-15s : ", p->pName ); printf( "pi = %5d ", Aig_ManPiNum(p) ); printf( "po = %5d ", Aig_ManPoNum(p) ); diff --git a/src/aig/aig/aigMem.c b/src/aig/aig/aigMem.c index 80a5ceb5..c0b76ff8 100644 --- a/src/aig/aig/aigMem.c +++ b/src/aig/aig/aigMem.c @@ -31,7 +31,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 free entries + char * pEntriesFree; // the linked list of ABC_FREE entries // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -48,8 +48,8 @@ struct Aig_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 + char * pCurrent; // the current pointer to ABC_FREE memory + char * pEnd; // the first entry outside the ABC_FREE memory // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -74,12 +74,6 @@ struct Aig_MmStep_t_ char ** pChunks; // the allocated memory }; -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) - //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -100,7 +94,7 @@ Aig_MmFixed_t * Aig_MmFixedStart( int nEntrySize, int nEntriesMax ) { Aig_MmFixed_t * p; - p = ALLOC( Aig_MmFixed_t, 1 ); + p = ABC_ALLOC( Aig_MmFixed_t, 1 ); memset( p, 0, sizeof(Aig_MmFixed_t) ); p->nEntrySize = nEntrySize; @@ -114,7 +108,7 @@ Aig_MmFixed_t * Aig_MmFixedStart( int nEntrySize, int nEntriesMax ) p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -145,9 +139,9 @@ void Aig_MmFixedStop( Aig_MmFixed_t * p, int fVerbose ) p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -166,16 +160,16 @@ char * Aig_MmFixedEntryFetch( Aig_MmFixed_t * p ) char * pTemp; int i; - // check if there are still free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize ); + 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; @@ -195,7 +189,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 free entry list + // return the first entry in the ABC_FREE entry list pTemp = p->pEntriesFree; p->pEntriesFree = *((char **)pTemp); return pTemp; @@ -216,7 +210,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 free entries + // add the entry to the linked list of ABC_FREE entries *((char **)pEntry) = p->pEntriesFree; p->pEntriesFree = pEntry; } @@ -240,7 +234,7 @@ void Aig_MmFixedRestart( Aig_MmFixed_t * p ) return; // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; // transform these entries into a linked list pTemp = p->pChunks[0]; @@ -251,7 +245,7 @@ void Aig_MmFixedRestart( Aig_MmFixed_t * p ) } // set the last link *((char **)pTemp) = NULL; - // set the free entry list + // set the ABC_FREE entry list p->pEntriesFree = p->pChunks[0]; // set the correct statistics p->nMemoryAlloc = p->nEntrySize * p->nChunkSize; @@ -309,7 +303,7 @@ Aig_MmFlex_t * Aig_MmFlexStart() { Aig_MmFlex_t * p; - p = ALLOC( Aig_MmFlex_t, 1 ); + p = ABC_ALLOC( Aig_MmFlex_t, 1 ); memset( p, 0, sizeof(Aig_MmFlex_t) ); p->nEntriesUsed = 0; @@ -319,7 +313,7 @@ Aig_MmFlex_t * Aig_MmFlexStart() p->nChunkSize = (1 << 18); p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -350,9 +344,9 @@ void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose ) p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -369,13 +363,13 @@ 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 free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } if ( nBytes > p->nChunkSize ) { @@ -383,7 +377,7 @@ char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes ) // (ideally, this should never happen) p->nChunkSize = 2 * nBytes; } - p->pCurrent = ALLOC( char, p->nChunkSize ); + p->pCurrent = ABC_ALLOC( char, p->nChunkSize ); p->pEnd = p->pCurrent + p->nChunkSize; p->nMemoryAlloc += p->nChunkSize; // add the chunk to the chunk storage @@ -418,7 +412,7 @@ void Aig_MmFlexRestart( Aig_MmFlex_t * p ) return; // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; p->nMemoryAlloc = p->nChunkSize; // transform these entries into a linked list @@ -461,7 +455,7 @@ int Aig_MmFlexReadMemUsage( Aig_MmFlex_t * p ) 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 free()ed.] + entries are handed over to malloc() and then ABC_FREE()ed.] SideEffects [] @@ -472,16 +466,16 @@ Aig_MmStep_t * Aig_MmStepStart( int nSteps ) { Aig_MmStep_t * p; int i, k; - p = ALLOC( Aig_MmStep_t, 1 ); + p = ABC_ALLOC( Aig_MmStep_t, 1 ); memset( p, 0, sizeof(Aig_MmStep_t) ); p->nMems = nSteps; // start the fixed memory managers - p->pMems = ALLOC( Aig_MmFixed_t *, p->nMems ); + p->pMems = ABC_ALLOC( Aig_MmFixed_t *, p->nMems ); for ( i = 0; i < p->nMems; i++ ) p->pMems[i] = Aig_MmFixedStart( (8<nMapSize = (4<nMems); - p->pMap = ALLOC( Aig_MmFixed_t *, p->nMapSize+1 ); + p->pMap = ABC_ALLOC( Aig_MmFixed_t *, p->nMapSize+1 ); p->pMap[0] = NULL; for ( k = 1; k <= 4; k++ ) p->pMap[k] = p->pMems[0]; @@ -492,7 +486,7 @@ Aig_MmStep_t * Aig_MmStepStart( int nSteps ) //printf( "%10d: size = %10d\n", i, p->pMap[i]->nEntrySize ); p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); return p; } @@ -515,12 +509,12 @@ void Aig_MmStepStop( Aig_MmStep_t * p, int fVerbose ) if ( p->nChunksAlloc ) { for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); } - free( p->pMems ); - free( p->pMap ); - free( p ); + ABC_FREE( p->pMems ); + ABC_FREE( p->pMap ); + ABC_FREE( p ); } /**Function************************************************************* @@ -543,9 +537,9 @@ char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes ) if ( p->nChunks == p->nChunksAlloc ) { p->nChunksAlloc *= 2; - p->pChunks = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pChunks[ p->nChunks++ ] = ALLOC( char, nBytes ); + p->pChunks[ p->nChunks++ ] = ABC_ALLOC( char, nBytes ); return p->pChunks[p->nChunks-1]; } return Aig_MmFixedEntryFetch( p->pMap[nBytes] ); @@ -569,7 +563,7 @@ void Aig_MmStepEntryRecycle( Aig_MmStep_t * p, char * pEntry, int nBytes ) return; if ( nBytes > p->nMapSize ) { -// free( pEntry ); +// ABC_FREE( pEntry ); return; } Aig_MmFixedEntryRecycle( p->pMap[nBytes], pEntry ); diff --git a/src/aig/aig/aigOrder.c b/src/aig/aig/aigOrder.c index 62aeca6e..746f0f18 100644 --- a/src/aig/aig/aigOrder.c +++ b/src/aig/aig/aigOrder.c @@ -49,7 +49,7 @@ void Aig_ManOrderStart( Aig_Man_t * p ) p->nOrderAlloc = 2 * Aig_ManObjNumMax(p); if ( p->nOrderAlloc < (1<<12) ) p->nOrderAlloc = (1<<12); - p->pOrderData = ALLOC( unsigned, 2 * p->nOrderAlloc ); + p->pOrderData = ABC_ALLOC( unsigned, 2 * p->nOrderAlloc ); memset( p->pOrderData, 0xFF, sizeof(unsigned) * 2 * p->nOrderAlloc ); // add the constant node p->pOrderData[0] = p->pOrderData[1] = 0; @@ -73,7 +73,7 @@ void Aig_ManOrderStart( Aig_Man_t * p ) void Aig_ManOrderStop( Aig_Man_t * p ) { assert( p->pOrderData ); - FREE( p->pOrderData ); + ABC_FREE( p->pOrderData ); p->nOrderAlloc = 0; p->iPrev = p->iNext = 0; } @@ -97,7 +97,7 @@ void Aig_ObjOrderInsert( Aig_Man_t * p, int ObjId ) if ( ObjId >= p->nOrderAlloc ) { int nOrderAlloc = 2 * ObjId; - p->pOrderData = REALLOC( unsigned, p->pOrderData, 2 * nOrderAlloc ); + p->pOrderData = ABC_REALLOC( unsigned, p->pOrderData, 2 * nOrderAlloc ); memset( p->pOrderData + 2 * p->nOrderAlloc, 0xFF, sizeof(unsigned) * 2 * (nOrderAlloc - p->nOrderAlloc) ); p->nOrderAlloc = nOrderAlloc; } diff --git a/src/aig/aig/aigPart.c b/src/aig/aig/aigPart.c index aca07bd9..1fd85768 100644 --- a/src/aig/aig/aigPart.c +++ b/src/aig/aig/aigPart.c @@ -30,10 +30,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 free memory - int nFreeSize; // the size of remaining free memory + char * pFreeBuf; // the pointer to ABC_FREE memory + int nFreeSize; // the size of remaining ABC_FREE memory Vec_Ptr_t * vMemory; // the memory allocated - Vec_Ptr_t * vFree; // the vector of free pieces of memory + Vec_Ptr_t * vFree; // the vector of ABC_FREE pieces of memory }; typedef struct Part_One_t_ Part_One_t; @@ -67,7 +67,7 @@ static inline void Part_OneSetNext( char * pPart, char * pNext ) { *((char **) Part_Man_t * Part_ManStart( int nChunkSize, int nStepSize ) { Part_Man_t * p; - p = ALLOC( Part_Man_t, 1 ); + p = ABC_ALLOC( Part_Man_t, 1 ); memset( p, 0, sizeof(Part_Man_t) ); p->nChunkSize = nChunkSize; p->nStepSize = nStepSize; @@ -92,10 +92,10 @@ void Part_ManStop( Part_Man_t * p ) void * pMemory; int i; Vec_PtrForEachEntry( p->vMemory, pMemory, i ) - free( pMemory ); + ABC_FREE( pMemory ); Vec_PtrFree( p->vMemory ); Vec_PtrFree( p->vFree ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -124,7 +124,7 @@ char * Part_ManFetch( Part_Man_t * p, int nSize ) nSizeReal = p->nStepSize * Type; if ( p->nFreeSize < nSizeReal ) { - p->pFreeBuf = ALLOC( char, p->nChunkSize ); + p->pFreeBuf = ABC_ALLOC( char, p->nChunkSize ); p->nFreeSize = p->nChunkSize; Vec_PtrPush( p->vMemory, p->pFreeBuf ); } @@ -447,7 +447,7 @@ unsigned * Aig_ManSuppCharStart( Vec_Int_t * vOne, int nPis ) unsigned * pBuffer; int i, Entry; int nWords = Aig_BitWordNum(nPis); - pBuffer = ALLOC( unsigned, nWords ); + pBuffer = ABC_ALLOC( unsigned, nWords ); memset( pBuffer, 0, sizeof(unsigned) * nWords ); Vec_IntForEachEntry( vOne, Entry, i ) { @@ -670,7 +670,7 @@ clk = clock(); vSupports = Aig_ManSupports( p ); if ( fVerbose ) { -PRT( "Supps", clock() - clk ); +ABC_PRT( "Supps", clock() - clk ); } // start char-based support representation vPartSuppsBit = Vec_PtrAlloc( 1000 ); @@ -716,13 +716,13 @@ clk = clock(); // stop char-based support representation Vec_PtrForEachEntry( vPartSuppsBit, vTemp, i ) - free( vTemp ); + ABC_FREE( vTemp ); Vec_PtrFree( vPartSuppsBit ); //printf( "\n" ); if ( fVerbose ) { -PRT( "Parts", clock() - clk ); +ABC_PRT( "Parts", clock() - clk ); } clk = clock(); @@ -748,7 +748,7 @@ clk = clock(); if ( fVerbose ) { -//PRT( "Comps", clock() - clk ); +//ABC_PRT( "Comps", clock() - clk ); } // cleanup @@ -797,7 +797,7 @@ clk = clock(); Vec_IntPush( vOne, i ); if ( fVerbose ) { -PRT( "Supps", clock() - clk ); +ABC_PRT( "Supps", clock() - clk ); } // start char-based support representation @@ -844,13 +844,13 @@ clk = clock(); // stop char-based support representation Vec_PtrForEachEntry( vPartSuppsBit, vTemp, i ) - free( vTemp ); + ABC_FREE( vTemp ); Vec_PtrFree( vPartSuppsBit ); //printf( "\n" ); if ( fVerbose ) { -PRT( "Parts", clock() - clk ); +ABC_PRT( "Parts", clock() - clk ); } clk = clock(); @@ -876,7 +876,7 @@ clk = clock(); if ( fVerbose ) { -//PRT( "Comps", clock() - clk ); +//ABC_PRT( "Comps", clock() - clk ); } // cleanup @@ -1281,7 +1281,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon } Vec_PtrFree( vOuts ); // store contents of pData pointers - ppData = ALLOC( void *, Aig_ManObjNumMax(pAigPart) ); + ppData = ABC_ALLOC( void *, Aig_ManObjNumMax(pAigPart) ); Aig_ManForEachObj( pAigPart, pObj, k ) ppData[k] = pObj->pData; // report the process @@ -1295,7 +1295,7 @@ Aig_Man_t * Aig_ManChoicePartitioned( Vec_Ptr_t * vAigs, int nPartSize, int nCon // reset the pData pointers Aig_ManForEachObj( pAigPart, pObj, k ) pObj->pData = ppData[k]; - free( ppData ); + ABC_FREE( ppData ); // transfer representatives to the total AIG if ( pAigPart->pReprs ) Aig_ManTransferRepr( pAigTotal, pAigPart ); @@ -1372,7 +1372,7 @@ Aig_Man_t * Aig_ManFraigPartitioned( Aig_Man_t * pAig, int nPartSize, int nConfM // derive the partition AIG pAigPart = Aig_ManDupPartAll( pAig, vPart ); // store contents of pData pointers - ppData = ALLOC( void *, Aig_ManObjNumMax(pAigPart) ); + ppData = ABC_ALLOC( void *, Aig_ManObjNumMax(pAigPart) ); Aig_ManForEachObj( pAigPart, pObj, k ) ppData[k] = pObj->pData; // report the process @@ -1386,7 +1386,7 @@ Aig_Man_t * Aig_ManFraigPartitioned( Aig_Man_t * pAig, int nPartSize, int nConfM // reset the pData pointers Aig_ManForEachObj( pAigPart, pObj, k ) pObj->pData = ppData[k]; - free( ppData ); + ABC_FREE( ppData ); // transfer representatives to the total AIG if ( pAigPart->pReprs ) Aig_ManTransferRepr( pAig, pAigPart ); @@ -1549,7 +1549,7 @@ Aig_Man_t * Aig_ManChoiceConstructive( Vec_Ptr_t * vAigs, int fVerbose ) // create room for equivalent nodes and representatives assert( pNew->pReprs == NULL ); pNew->nReprsAlloc = Vec_PtrSize(vAigs) * Aig_ManObjNumMax(pNew); - pNew->pReprs = ALLOC( Aig_Obj_t *, pNew->nReprsAlloc ); + 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 ) diff --git a/src/aig/aig/aigPartReg.c b/src/aig/aig/aigPartReg.c index 36be0810..1e77c224 100644 --- a/src/aig/aig/aigPartReg.c +++ b/src/aig/aig/aigPartReg.c @@ -39,7 +39,7 @@ struct Aig_ManPre_t_ // info about the current partition Vec_Int_t * vRegs; // registers of this partition Vec_Int_t * vUniques; // unique registers of this partition - Vec_Int_t * vFreeVars; // free variables of this partition + Vec_Int_t * vFreeVars; // ABC_FREE variables of this partition Vec_Flt_t * vPartCost; // costs of adding each variable char * pfPartVars; // input/output registers of the partition }; @@ -63,7 +63,7 @@ struct Aig_ManPre_t_ Aig_ManPre_t * Aig_ManRegManStart( Aig_Man_t * pAig, int nPartSize ) { Aig_ManPre_t * p; - p = ALLOC( Aig_ManPre_t, 1 ); + p = ABC_ALLOC( Aig_ManPre_t, 1 ); memset( p, 0, sizeof(Aig_ManPre_t) ); p->pAig = pAig; p->vMatrix = Aig_ManSupportsRegisters( pAig ); @@ -73,9 +73,9 @@ Aig_ManPre_t * Aig_ManRegManStart( Aig_Man_t * pAig, int nPartSize ) p->vUniques = Vec_IntAlloc(256); p->vFreeVars = Vec_IntAlloc(256); p->vPartCost = Vec_FltAlloc(256); - p->pfUsedRegs = ALLOC( char, Aig_ManRegNum(p->pAig) ); + p->pfUsedRegs = ABC_ALLOC( char, Aig_ManRegNum(p->pAig) ); memset( p->pfUsedRegs, 0, sizeof(char) * Aig_ManRegNum(p->pAig) ); - p->pfPartVars = ALLOC( char, Aig_ManRegNum(p->pAig) ); + p->pfPartVars = ABC_ALLOC( char, Aig_ManRegNum(p->pAig) ); return p; } @@ -99,9 +99,9 @@ void Aig_ManRegManStop( Aig_ManPre_t * p ) Vec_IntFree( p->vUniques ); Vec_IntFree( p->vFreeVars ); Vec_FltFree( p->vPartCost ); - free( p->pfUsedRegs ); - free( p->pfPartVars ); - free( p ); + ABC_FREE( p->pfUsedRegs ); + ABC_FREE( p->pfPartVars ); + ABC_FREE( p ); } /**Function************************************************************* @@ -155,7 +155,7 @@ int Aig_ManRegFindBestVar( Aig_ManPre_t * p ) Vec_Int_t * vSupp; int nNewVars, nNewVarsBest = AIG_INFINITY; int iVarFree, iVarSupp, iVarBest = -1, i, k; - // go through the free variables + // go through the ABC_FREE variables Vec_IntForEachEntry( p->vFreeVars, iVarFree, i ) { // if ( p->pfUsedRegs[iVarFree] ) @@ -205,7 +205,7 @@ void Aig_ManRegPartitionAdd( Aig_ManPre_t * p, int iReg ) p->pfUsedRegs[iReg] = 1; Vec_IntPush( p->vUniques, iReg ); } - // remove it from the free variables + // remove it from the ABC_FREE variables if ( Vec_IntSize(p->vFreeVars) > 0 ) { assert( p->pfPartVars[iReg] ); @@ -372,7 +372,7 @@ Aig_Man_t * Aig_ManRegCreatePart( Aig_Man_t * pAig, Vec_Int_t * vPart, int * pnC // create map if ( ppMapBack ) { - pMapBack = ALLOC( int, Aig_ManObjNumMax(pNew) ); + pMapBack = ABC_ALLOC( int, Aig_ManObjNumMax(pNew) ); memset( pMapBack, 0xff, sizeof(int) * Aig_ManObjNumMax(pNew) ); // map constant nodes pMapBack[0] = 0; @@ -441,7 +441,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 free variables + // quit if there are not ABC_FREE variables if ( Vec_IntSize(p->vFreeVars) == 0 ) break; } diff --git a/src/aig/aig/aigPartSat.c b/src/aig/aig/aigPartSat.c index 15aa1a05..a8c9008f 100644 --- a/src/aig/aig/aigPartSat.c +++ b/src/aig/aig/aigPartSat.c @@ -520,7 +520,7 @@ int Aig_ManPartitionedSat( Aig_Man_t * p, int nAlgo, int nPartSize, if ( fVerbose ) { printf( "Partitioning derived %d partitions. ", Vec_IntFindMax(vNode2Part) + 1 ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // split the original AIG into partition AIGs (vAigs) @@ -532,7 +532,7 @@ int Aig_ManPartitionedSat( Aig_Man_t * p, int nAlgo, int nPartSize, if ( fVerbose ) { printf( "Partions were transformed into AIGs. " ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // synthesize partitions @@ -567,13 +567,13 @@ clk = clock(); break; } // call the SAT solver - status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfRemaining, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfRemaining, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( fVerbose ) { printf( "%4d : Aig = %6d. Vs = %7d. RootCs = %7d. LearnCs = %6d. ", i, nNodes += Aig_ManNodeNum(pAig), sat_solver_nvars(pSat), (int)pSat->stats.clauses, (int)pSat->stats.learnts ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } // analize the result if ( status == l_False ) diff --git a/src/aig/aig/aigRepr.c b/src/aig/aig/aigRepr.c index 7a092c0f..0ab02144 100644 --- a/src/aig/aig/aigRepr.c +++ b/src/aig/aig/aigRepr.c @@ -44,7 +44,7 @@ void Aig_ManReprStart( Aig_Man_t * p, int nIdMax ) assert( Aig_ManBufNum(p) == 0 ); assert( p->pReprs == NULL ); p->nReprsAlloc = nIdMax; - p->pReprs = ALLOC( Aig_Obj_t *, p->nReprsAlloc ); + p->pReprs = ABC_ALLOC( Aig_Obj_t *, p->nReprsAlloc ); memset( p->pReprs, 0, sizeof(Aig_Obj_t *) * p->nReprsAlloc ); } @@ -62,7 +62,7 @@ void Aig_ManReprStart( Aig_Man_t * p, int nIdMax ) void Aig_ManReprStop( Aig_Man_t * p ) { assert( p->pReprs != NULL ); - FREE( p->pReprs ); + ABC_FREE( p->pReprs ); p->nReprsAlloc = 0; } @@ -214,7 +214,7 @@ void Aig_ManTransferRepr( Aig_Man_t * pNew, Aig_Man_t * pOld ) if ( pNew->nReprsAlloc < Aig_ManObjNumMax(pNew) ) { int nReprsAllocNew = 2 * Aig_ManObjNumMax(pNew); - pNew->pReprs = REALLOC( Aig_Obj_t *, pNew->pReprs, nReprsAllocNew ); + pNew->pReprs = ABC_REALLOC( Aig_Obj_t *, pNew->pReprs, nReprsAllocNew ); memset( pNew->pReprs + pNew->nReprsAlloc, 0, sizeof(Aig_Obj_t *) * (nReprsAllocNew-pNew->nReprsAlloc) ); pNew->nReprsAlloc = nReprsAllocNew; } @@ -476,7 +476,7 @@ void Aig_ManMarkValidChoices( Aig_Man_t * p ) assert( p->pReprs != NULL ); // create equivalent nodes in the manager assert( p->pEquivs == NULL ); - p->pEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); + p->pEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p) ); memset( p->pEquivs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(p) ); // make the choice nodes Aig_ManForEachNode( p, pObj, i ) diff --git a/src/aig/aig/aigRet.c b/src/aig/aig/aigRet.c index 4641318a..c5cc6392 100644 --- a/src/aig/aig/aigRet.c +++ b/src/aig/aig/aigRet.c @@ -174,7 +174,7 @@ void Rtm_ObjTransferToBig( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) if ( p->nExtraCur + 1 > p->nExtraAlloc ) { int nExtraAllocNew = AIG_MAX( 2 * p->nExtraAlloc, 1024 ); - p->pExtra = REALLOC( unsigned, p->pExtra, nExtraAllocNew ); + p->pExtra = ABC_REALLOC( unsigned, p->pExtra, nExtraAllocNew ); p->nExtraAlloc = nExtraAllocNew; } p->pExtra[p->nExtraCur] = pEdge->LData; @@ -200,7 +200,7 @@ void Rtm_ObjTransferToBigger( Rtm_Man_t * p, Rtm_Edg_t * pEdge ) if ( p->nExtraCur + nWords + 1 > p->nExtraAlloc ) { int nExtraAllocNew = AIG_MAX( 2 * p->nExtraAlloc, 1024 ); - p->pExtra = REALLOC( unsigned, p->pExtra, nExtraAllocNew ); + p->pExtra = ABC_REALLOC( unsigned, p->pExtra, nExtraAllocNew ); p->nExtraAlloc = nExtraAllocNew; } memcpy( p->pExtra + p->nExtraCur, p->pExtra + pEdge->LData, sizeof(unsigned) * nWords ); @@ -300,7 +300,7 @@ Rtm_Man_t * Rtm_ManAlloc( Aig_Man_t * p ) { Rtm_Man_t * pRtm; // start the manager - pRtm = ALLOC( Rtm_Man_t, 1 ); + pRtm = ABC_ALLOC( Rtm_Man_t, 1 ); memset( pRtm, 0, sizeof(Rtm_Man_t) ); // perform initializations pRtm->vObjs = Vec_PtrAlloc( Aig_ManObjNum(p) ); @@ -327,8 +327,8 @@ void Rtm_ManFree( Rtm_Man_t * p ) Vec_PtrFree( p->vPis ); Vec_PtrFree( p->vPos ); Aig_MmFlexStop( p->pMem, 0 ); - FREE( p->pExtra ); - free( p ); + ABC_FREE( p->pExtra ); + ABC_FREE( p ); } /**Function************************************************************* @@ -767,7 +767,7 @@ Aig_Man_t * Rtm_ManToAig( Rtm_Man_t * pRtm ) Rtm_Edg_t * pEdge; int i, k, m, Val, nLatches, * pLatches; // count latches and mark the first latch on each edge - pLatches = ALLOC( int, 2 * Vec_PtrSize(pRtm->vObjs) ); + pLatches = ABC_ALLOC( int, 2 * Vec_PtrSize(pRtm->vObjs) ); nLatches = 0; Rtm_ManForEachObj( pRtm, pObjRtm, i ) Rtm_ObjForEachFaninEdge( pObjRtm, pEdge, k ) @@ -808,7 +808,7 @@ Aig_Man_t * Rtm_ManToAig( Rtm_Man_t * pRtm ) } // assert( Aig_Regular(pObjNew)->nRefs > 0 ); } - free( pLatches ); + ABC_FREE( pLatches ); Aig_ManSetRegNum( pNew, nLatches ); // remove useless nodes Aig_ManCleanup( pNew ); @@ -852,7 +852,7 @@ clk = clock(); if ( fVerbose ) { printf( "Detected %d autonomous objects. ", nAutos ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // set the current retiming number @@ -943,7 +943,7 @@ clk = clock(); printf( "Performed %d %s latch moves of max depth %d and max latch count %d.\n", Vec_PtrSize(vQueue), fForward? "fwd":"bwd", DegreeMax, Rtm_ManLatchMax(pRtm) ); printf( "Memory usage = %d. ", pRtm->nExtraCur ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } Vec_PtrFree( vQueue ); @@ -957,7 +957,7 @@ clk = clock(); pNew = Aig_ManReduceLaches( pNew, fVerbose ); if ( fVerbose ) { - PRT( "Register sharing time", clock() - clk ); + ABC_PRT( "Register sharing time", clock() - clk ); } return pNew; } diff --git a/src/aig/aig/aigScl.c b/src/aig/aig/aigScl.c index 57b7b989..b6331b0e 100644 --- a/src/aig/aig/aigScl.c +++ b/src/aig/aig/aigScl.c @@ -396,7 +396,7 @@ Vec_Ptr_t * Aig_ManReduceLachesOnce( Aig_Man_t * p ) Aig_ManForEachPiSeq( p, pObj, i ) Vec_PtrPush( vMap, pObj ); // create mapping of fanin nodes into the corresponding latch outputs - pMapping = ALLOC( int, 2 * Aig_ManObjNumMax(p) ); + pMapping = ABC_ALLOC( int, 2 * Aig_ManObjNumMax(p) ); Aig_ManForEachLiLoSeq( p, pObjLi, pObjLo, i ) { pFanin = Aig_ObjFanin0(pObjLi); @@ -427,7 +427,7 @@ Vec_Ptr_t * Aig_ManReduceLachesOnce( Aig_Man_t * p ) } } } - free( pMapping ); + ABC_FREE( pMapping ); Aig_ManForEachLiSeq( p, pObj, i ) { pFanin = Aig_ObjFanin0(pObj); @@ -456,6 +456,7 @@ Aig_Man_t * Aig_ManReduceLaches( Aig_Man_t * p, int fVerbose ) printf( "Performing combinational register sweep:\n" ); for ( nSaved = 0; (nCur = Aig_ManReduceLachesCount(p)); nSaved += nCur ) { +// printf( "Reducible = %d\n", nCur ); vMap = Aig_ManReduceLachesOnce( p ); p = Aig_ManRemap( pTemp = p, vMap ); Vec_PtrFree( vMap ); @@ -532,7 +533,7 @@ void Aig_ManComputeSccs( Aig_Man_t * p ) // detect strongly connected components vComp = Vec_IntAlloc( Aig_ManRegNum(p) ); - pVarsTot = ALLOC( char, Aig_ManRegNum(p) ); + pVarsTot = ABC_ALLOC( char, Aig_ManRegNum(p) ); memset( pVarsTot, 0, Aig_ManRegNum(p) * sizeof(char) ); for ( nComps = 0; ; nComps++ ) { @@ -571,7 +572,7 @@ void Aig_ManComputeSccs( Aig_Man_t * p ) } printf( "SCC #%d contains %5d registers.\n", nComps+1, Vec_IntSize(vComp) ); } - free( pVarsTot ); + ABC_FREE( pVarsTot ); Vec_IntFree( vComp ); Vec_PtrFree( vMatrix ); Vec_VecFree( (Vec_Vec_t *)vMatrix2 ); @@ -622,7 +623,7 @@ Aig_Man_t * Aig_ManSclPart( Aig_Man_t * pAig, int fLatchConst, int fLatchEqual, Aig_ManStop( pNew ); } Aig_ManStop( pTemp ); - free( pMapBack ); + ABC_FREE( pMapBack ); } pNew = Aig_ManDupRepr( pAig, 0 ); Aig_ManSeqCleanup( pNew ); diff --git a/src/aig/aig/aigTable.c b/src/aig/aig/aigTable.c index 68efbba6..7ca4bb32 100644 --- a/src/aig/aig/aigTable.c +++ b/src/aig/aig/aigTable.c @@ -75,7 +75,7 @@ clk = clock(); nTableSizeOld = p->nTableSize; // get the new table p->nTableSize = Aig_PrimeCudd( 2 * Aig_ManNodeNum(p) ); - p->pTable = ALLOC( Aig_Obj_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Aig_Obj_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize ); // rehash the entries from the old table Counter = 0; @@ -93,9 +93,9 @@ clk = clock(); } assert( Counter == Aig_ManNodeNum(p) ); // printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( pTableOld ); + ABC_FREE( pTableOld ); } /**Function************************************************************* @@ -259,7 +259,7 @@ void Aig_TableProfile( Aig_Man_t * p ) ******************************************************************************/ void Aig_TableClear( Aig_Man_t * p ) { - FREE( p->pTable ); + ABC_FREE( p->pTable ); p->nTableSize = 0; } diff --git a/src/aig/aig/aigTsim.c b/src/aig/aig/aigTsim.c index c411100b..e9bad08e 100644 --- a/src/aig/aig/aigTsim.c +++ b/src/aig/aig/aigTsim.c @@ -126,14 +126,14 @@ static inline void Aig_TsiSetNext( unsigned * pState, int nWords, unsigned Aig_Tsi_t * Aig_TsiStart( Aig_Man_t * pAig ) { Aig_Tsi_t * p; - p = (Aig_Tsi_t *)malloc( sizeof(Aig_Tsi_t) ); + p = ABC_ALLOC( Aig_Tsi_t, 1 ); memset( p, 0, sizeof(Aig_Tsi_t) ); p->pAig = pAig; p->nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) ); p->vStates = Vec_PtrAlloc( 1000 ); p->pMem = Aig_MmFixedStart( sizeof(unsigned) * p->nWords + sizeof(unsigned *), 10000 ); p->nBins = Aig_PrimeCudd(TSI_MAX_ROUNDS/2); - p->pBins = ALLOC( unsigned *, p->nBins ); + p->pBins = ABC_ALLOC( unsigned *, p->nBins ); memset( p->pBins, 0, sizeof(unsigned *) * p->nBins ); return p; } @@ -153,8 +153,8 @@ void Aig_TsiStop( Aig_Tsi_t * p ) { Aig_MmFixedStop( p->pMem, 0 ); Vec_PtrFree( p->vStates ); - free( p->pBins ); - free( p ); + ABC_FREE( p->pBins ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/aig/aigUtil.c b/src/aig/aig/aigUtil.c index 2668bbb2..b5c7272b 100644 --- a/src/aig/aig/aigUtil.c +++ b/src/aig/aig/aigUtil.c @@ -82,6 +82,22 @@ void Aig_ManIncrementTravId( Aig_Man_t * p ) p->nTravIds++; } +/**Function************************************************************* + + Synopsis [Make sure AIG has not gaps in the numeric order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Aig_ManHasNoGaps( Aig_Man_t * p ) +{ + return (int)(Aig_ManObjNum(p) == Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManNodeNum(p) + 1); +} + /**Function************************************************************* Synopsis [Collect the latches.] @@ -997,7 +1013,7 @@ void Aig_ManCleanPioNumbers( Aig_Man_t * p ) SeeAlso [] ***********************************************************************/ -int Aig_ManCountChoices( Aig_Man_t * p ) +int Aig_ManChoiceNum( Aig_Man_t * p ) { Aig_Obj_t * pObj; int i, Counter = 0; @@ -1160,6 +1176,26 @@ unsigned Aig_ManRandom( int fReset ) } +/**Function************************************************************* + + Synopsis [Creates random info for the primary inputs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Aig_ManRandomInfo( Vec_Ptr_t * vInfo, int iWordStart, int iWordStop ) +{ + unsigned * pInfo; + int i, w; + Vec_PtrForEachEntry( vInfo, pInfo, i ) + for ( w = iWordStart; w < iWordStop; w++ ) + pInfo[w] = Aig_ManRandom(0); +} + /**Function************************************************************* Synopsis [Returns the result of merging the two vectors.] diff --git a/src/aig/bar/bar.c b/src/aig/bar/bar.c index f802d60c..2c5065cb 100644 --- a/src/aig/bar/bar.c +++ b/src/aig/bar/bar.c @@ -21,6 +21,7 @@ #include #include #include +#include "abc_global.h" #include "bar.h" //////////////////////////////////////////////////////////////////////// @@ -67,7 +68,7 @@ Bar_Progress_t * Bar_ProgressStart( FILE * pFile, int nItemsTotal ) if ( pFrame == NULL ) return NULL; if ( !Abc_FrameShowProgress(pFrame) ) return NULL; - p = (Bar_Progress_t *) malloc(sizeof(Bar_Progress_t)); + p = ABC_ALLOC( Bar_Progress_t, 1 ); memset( p, 0, sizeof(Bar_Progress_t) ); p->pFile = pFile; p->nItemsTotal = nItemsTotal; @@ -123,7 +124,7 @@ void Bar_ProgressStop( Bar_Progress_t * p ) { if ( p == NULL ) return; Bar_ProgressClean( p ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/bar/bar.h b/src/aig/bar/bar.h index 814fbe6f..104c6f47 100644 --- a/src/aig/bar/bar.h +++ b/src/aig/bar/bar.h @@ -21,10 +21,6 @@ #ifndef __BAR_H__ #define __BAR_H__ -#ifdef __cplusplus -extern "C" { -#endif - #ifdef _WIN32 #define inline __inline // compatible with MS VS 6.0 #endif @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define BAR_PROGRESS_USE 1 //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/bbr/bbr.h b/src/aig/bbr/bbr.h index 69d5fae7..ee91fe8b 100644 --- a/src/aig/bbr/bbr.h +++ b/src/aig/bbr/bbr.h @@ -21,10 +21,6 @@ #ifndef __BBR_H__ #define __BBR_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -38,6 +34,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/bbr/bbrCex.c b/src/aig/bbr/bbrCex.c index be5377af..41253dbc 100644 --- a/src/aig/bbr/bbrCex.c +++ b/src/aig/bbr/bbrCex.c @@ -73,7 +73,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd, } // allocate room for the cube - pValues = ALLOC( char, dd->size ); + pValues = ABC_ALLOC( char, dd->size ); // get the last cube RetValue = Cudd_bddPickOneCube( dd, bCubeFirst, pValues ); @@ -105,7 +105,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd, if ( !fSilent ) printf( "BDDs blew up during image computation. " ); Bbr_bddImageTreeDelete( pTree ); - free( pValues ); + ABC_FREE( pValues ); return NULL; } Cudd_Ref( bImage ); @@ -145,7 +145,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd, } // cleanup Bbr_bddImageTreeDelete( pTree ); - free( pValues ); + ABC_FREE( pValues ); // verify the counter example if ( Vec_PtrSize(vOnionRings) < 1000 ) { @@ -155,7 +155,7 @@ Ssw_Cex_t * Aig_ManVerifyUsingBddsCountExample( Aig_Man_t * p, DdManager * dd, } if ( fVerbose && !fSilent ) { - PRT( "Counter-example generation time", clock() - clk ); + ABC_PRT( "Counter-example generation time", clock() - clk ); } return pCex; } diff --git a/src/aig/bbr/bbrImage.c b/src/aig/bbr/bbrImage.c index afc8dc39..edd344bf 100644 --- a/src/aig/bbr/bbrImage.c +++ b/src/aig/bbr/bbrImage.c @@ -94,8 +94,8 @@ struct Bbr_ImageVar_t_ #define b0 Cudd_Not((dd)->one) #define b1 (dd)->one -#ifndef PRB -#define PRB(dd,f) printf("%s = ", #f); Bbr_bddPrint(dd,f); printf("\n") +#ifndef ABC_PRB +#define ABC_PRB(dd,f) printf("%s = ", #f); Bbr_bddPrint(dd,f); printf("\n") #endif /**AutomaticStart*************************************************************/ @@ -191,26 +191,26 @@ Bbr_ImageTree_t * Bbr_bddImageStart( { for ( v = 0; v < dd->size; v++ ) if ( pVars[v] ) - free( pVars[v] ); - free( pVars ); + ABC_FREE( pVars[v] ); + ABC_FREE( pVars ); for ( v = 0; v <= nParts; v++ ) if ( pNodes[v] ) { Bbr_DeleteParts_rec( pNodes[v] ); Bbr_bddImageTreeDelete_rec( pNodes[v] ); } - free( pNodes ); - free( pParts ); + ABC_FREE( pNodes ); + ABC_FREE( pParts ); return NULL; } // make sure the variables are gone for ( v = 0; v < dd->size; v++ ) assert( pVars[v] == NULL ); - FREE( pVars ); + ABC_FREE( pVars ); // create the tree - pTree = ALLOC( Bbr_ImageTree_t, 1 ); + pTree = ABC_ALLOC( Bbr_ImageTree_t, 1 ); memset( pTree, 0, sizeof(Bbr_ImageTree_t) ); pTree->pCare = pCare; pTree->fVerbose = fVerbose; @@ -221,7 +221,7 @@ Bbr_ImageTree_t * Bbr_bddImageStart( // make sure the nodes are gone for ( v = 0; v < nParts + 1; v++ ) assert( pNodes[v] == NULL ); - FREE( pNodes ); + ABC_FREE( pNodes ); // if ( fVerbose ) // Bbr_bddImagePrintTree( pTree ); @@ -231,7 +231,7 @@ Bbr_ImageTree_t * Bbr_bddImageStart( // clean the partitions Bbr_DeleteParts_rec( pTree->pRoot ); - FREE( pParts ); + ABC_FREE( pParts ); return pTree; } @@ -261,9 +261,9 @@ DdNode * Bbr_bddImageCompute( Bbr_ImageTree_t * pTree, DdNode * bCare ) if ( bRem != b1 ) { printf( "Original care set support: " ); -PRB( dd, pTree->bCareSupp ); +ABC_PRB( dd, pTree->bCareSupp ); printf( "Current care set support: " ); -PRB( dd, bSupp ); +ABC_PRB( dd, bSupp ); Cudd_RecursiveDeref( dd, bSupp ); Cudd_RecursiveDeref( dd, bRem ); printf( "The care set depends on some vars that were not in the care set during scheduling.\n" ); @@ -305,7 +305,7 @@ void Bbr_bddImageTreeDelete( Bbr_ImageTree_t * pTree ) if ( pTree->bCareSupp ) Cudd_RecursiveDeref( pTree->pRoot->dd, pTree->bCareSupp ); Bbr_bddImageTreeDelete_rec( pTree->pRoot ); - FREE( pTree ); + ABC_FREE( pTree ); } /**Function************************************************************* @@ -406,11 +406,11 @@ Bbr_ImagePart_t ** Bbr_CreateParts( DdManager * dd, int i; // start the partitions - pParts = ALLOC( Bbr_ImagePart_t *, nParts + 1 ); + pParts = ABC_ALLOC( Bbr_ImagePart_t *, nParts + 1 ); // create structures for each variable for ( i = 0; i < nParts; i++ ) { - pParts[i] = ALLOC( Bbr_ImagePart_t, 1 ); + pParts[i] = ABC_ALLOC( Bbr_ImagePart_t, 1 ); pParts[i]->bFunc = pbParts[i]; Cudd_Ref( pParts[i]->bFunc ); pParts[i]->bSupp = Cudd_Support( dd, pParts[i]->bFunc ); Cudd_Ref( pParts[i]->bSupp ); pParts[i]->nSupp = Cudd_SupportSize( dd, pParts[i]->bSupp ); @@ -418,7 +418,7 @@ Bbr_ImagePart_t ** Bbr_CreateParts( DdManager * dd, pParts[i]->iPart = i; } // add the care set as the last partition - pParts[nParts] = ALLOC( Bbr_ImagePart_t, 1 ); + pParts[nParts] = ABC_ALLOC( Bbr_ImagePart_t, 1 ); pParts[nParts]->bFunc = bCare; Cudd_Ref( pParts[nParts]->bFunc ); pParts[nParts]->bSupp = Cudd_Support( dd, pParts[nParts]->bFunc ); Cudd_Ref( pParts[nParts]->bSupp ); pParts[nParts]->nSupp = Cudd_SupportSize( dd, pParts[nParts]->bSupp ); @@ -448,11 +448,11 @@ Bbr_ImageVar_t ** Bbr_CreateVars( DdManager * dd, int nVarsTotal, iVar, p, Counter; // put all the functions into one array - pbFuncs = ALLOC( DdNode *, nParts ); + pbFuncs = ABC_ALLOC( DdNode *, nParts ); for ( p = 0; p < nParts; p++ ) pbFuncs[p] = pParts[p]->bSupp; bSupp = Cudd_VectorSupport( dd, pbFuncs, nParts ); Cudd_Ref( bSupp ); - FREE( pbFuncs ); + ABC_FREE( pbFuncs ); // remove the NS vars bCubeNs = Cudd_bddComputeCube( dd, pbVars, NULL, nVars ); Cudd_Ref( bCubeNs ); @@ -464,13 +464,13 @@ Bbr_ImageVar_t ** Bbr_CreateVars( DdManager * dd, nVarsTotal = Cudd_SupportSize( dd, bSupp ); // start the variables - pVars = ALLOC( Bbr_ImageVar_t *, dd->size ); + pVars = ABC_ALLOC( Bbr_ImageVar_t *, dd->size ); memset( pVars, 0, sizeof(Bbr_ImageVar_t *) * dd->size ); // create structures for each variable for ( bSuppTemp = bSupp; bSuppTemp != b1; bSuppTemp = cuddT(bSuppTemp) ) { iVar = bSuppTemp->index; - pVars[iVar] = ALLOC( Bbr_ImageVar_t, 1 ); + pVars[iVar] = ABC_ALLOC( Bbr_ImageVar_t, 1 ); pVars[iVar]->iNum = iVar; // collect all the parts this var belongs to Counter = 0; @@ -517,11 +517,11 @@ Bbr_ImageNode_t ** Bbr_CreateNodes( DdManager * dd, Bbr_ImagePart_t * pPart; // the partition (temporary) */ // start the partitions - pNodes = ALLOC( Bbr_ImageNode_t *, nParts ); + pNodes = ABC_ALLOC( Bbr_ImageNode_t *, nParts ); // create structures for each leaf nodes for ( i = 0; i < nParts; i++ ) { - pNodes[i] = ALLOC( Bbr_ImageNode_t, 1 ); + pNodes[i] = ABC_ALLOC( Bbr_ImageNode_t, 1 ); memset( pNodes[i], 0, sizeof(Bbr_ImageNode_t) ); pNodes[i]->dd = dd; pNodes[i]->pPart = pParts[i]; @@ -548,7 +548,7 @@ Bbr_ImageNode_t ** Bbr_CreateNodes( DdManager * dd, } // remove these variables Cudd_RecursiveDeref( dd, pVars[v]->bParts ); - FREE( pVars[v] ); + ABC_FREE( pVars[v] ); } // assign the leaf node images @@ -583,9 +583,9 @@ Bbr_ImageNode_t ** Bbr_CreateNodes( DdManager * dd, for ( i = 0; i < nParts; i++ ) { pNode = pNodes[i]; -PRB( dd, pNode->bCube ); -PRB( dd, pNode->pPart->bFunc ); -PRB( dd, pNode->pPart->bSupp ); +ABC_PRB( dd, pNode->bCube ); +ABC_PRB( dd, pNode->pPart->bFunc ); +ABC_PRB( dd, pNode->pPart->bSupp ); printf( "\n" ); } */ @@ -614,7 +614,7 @@ void Bbr_DeleteParts_rec( Bbr_ImageNode_t * pNode ) pPart = pNode->pPart; Cudd_RecursiveDeref( pNode->dd, pPart->bFunc ); Cudd_RecursiveDeref( pNode->dd, pPart->bSupp ); - FREE( pNode->pPart ); + ABC_FREE( pNode->pPart ); } /**Function************************************************************* @@ -639,7 +639,7 @@ void Bbr_bddImageTreeDelete_rec( Bbr_ImageNode_t * pNode ) if ( pNode->bImage ) Cudd_RecursiveDeref( pNode->dd, pNode->bImage ); assert( pNode->pPart == NULL ); - FREE( pNode ); + ABC_FREE( pNode ); } /**Function************************************************************* @@ -757,11 +757,11 @@ int Bbr_BuildTreeNode( DdManager * dd, Cudd_RecursiveDeref( dd, bTemp ); // clean this var Cudd_RecursiveDeref( dd, pVars[v]->bParts ); - FREE( pVars[v] ); + ABC_FREE( pVars[v] ); } // clean the best var Cudd_RecursiveDeref( dd, pVars[iVarBest]->bParts ); - FREE( pVars[iVarBest] ); + ABC_FREE( pVars[iVarBest] ); // combines two nodes pNode = Bbr_CombineTwoNodes( dd, bCube, pNode1, pNode2 ); @@ -884,7 +884,7 @@ Bbr_ImageNode_t * Bbr_CombineTwoNodes( DdManager * dd, DdNode * bCube, Bbr_ImagePart_t * pPart; // create a new partition - pPart = ALLOC( Bbr_ImagePart_t, 1 ); + pPart = ABC_ALLOC( Bbr_ImagePart_t, 1 ); memset( pPart, 0, sizeof(Bbr_ImagePart_t) ); // create the function pPart->bFunc = Cudd_bddAndAbstract( dd, pNode1->pPart->bFunc, pNode2->pPart->bFunc, bCube ); @@ -897,12 +897,12 @@ Bbr_ImageNode_t * Bbr_CombineTwoNodes( DdManager * dd, DdNode * bCube, pPart->nNodes = Cudd_DagSize( pPart->bFunc ); pPart->iPart = -1; /* -PRB( dd, pNode1->pPart->bSupp ); -PRB( dd, pNode2->pPart->bSupp ); -PRB( dd, pPart->bSupp ); +ABC_PRB( dd, pNode1->pPart->bSupp ); +ABC_PRB( dd, pNode2->pPart->bSupp ); +ABC_PRB( dd, pPart->bSupp ); */ // create a new node - pNode = ALLOC( Bbr_ImageNode_t, 1 ); + pNode = ABC_ALLOC( Bbr_ImageNode_t, 1 ); memset( pNode, 0, sizeof(Bbr_ImageNode_t) ); pNode->dd = dd; pNode->pPart = pPart; @@ -1114,7 +1114,7 @@ void Bbr_bddImagePrintTree_rec( Bbr_ImageNode_t * pNode, int Offset ) printf( "<%d> ", pNode->pPart->iPart ); if ( Cube != NULL ) { - PRB( pNode->dd, Cube ); + ABC_PRB( pNode->dd, Cube ); } else printf( "\n" ); @@ -1124,7 +1124,7 @@ void Bbr_bddImagePrintTree_rec( Bbr_ImageNode_t * pNode, int Offset ) printf( "<*> " ); if ( Cube != NULL ) { - PRB( pNode->dd, Cube ); + ABC_PRB( pNode->dd, Cube ); } else printf( "\n" ); @@ -1198,7 +1198,7 @@ Bbr_ImageTree2_t * Bbr_bddImageStart2( DdNode * bCubeAll, * bCubeNot, * bTemp; int i; - pTree = ALLOC( Bbr_ImageTree2_t, 1 ); + pTree = ABC_ALLOC( Bbr_ImageTree2_t, 1 ); pTree->dd = dd; pTree->bImage = NULL; @@ -1259,7 +1259,7 @@ void Bbr_bddImageTreeDelete2( Bbr_ImageTree2_t * pTree ) Cudd_RecursiveDeref( pTree->dd, pTree->bCube ); if ( pTree->bImage ) Cudd_RecursiveDeref( pTree->dd, pTree->bImage ); - FREE( pTree ); + ABC_FREE( pTree ); } /**Function************************************************************* diff --git a/src/aig/bbr/bbrReach.c b/src/aig/bbr/bbrReach.c index 05f7ef55..c2982856 100644 --- a/src/aig/bbr/bbrReach.c +++ b/src/aig/bbr/bbrReach.c @@ -101,8 +101,8 @@ DdNode * Aig_ManInitStateVarMap( DdManager * dd, Aig_Man_t * p, int fVerbose ) int i; // set the variable mapping for Cudd_bddVarMap() - pbVarsX = ALLOC( DdNode *, dd->size ); - pbVarsY = ALLOC( DdNode *, dd->size ); + pbVarsX = ABC_ALLOC( DdNode *, dd->size ); + pbVarsY = ABC_ALLOC( DdNode *, dd->size ); bProd = (dd)->one; Cudd_Ref( bProd ); Saig_ManForEachLo( p, pLatch, i ) { @@ -113,8 +113,8 @@ DdNode * Aig_ManInitStateVarMap( DdManager * dd, Aig_Man_t * p, int fVerbose ) Cudd_RecursiveDeref( dd, bTemp ); } Cudd_SetVarMap( dd, pbVarsX, pbVarsY, Saig_ManRegNum(p) ); - FREE( pbVarsX ); - FREE( pbVarsY ); + ABC_FREE( pbVarsX ); + ABC_FREE( pbVarsY ); Cudd_Deref( bProd ); return bProd; @@ -137,7 +137,7 @@ DdNode ** Aig_ManCreateOutputs( DdManager * dd, Aig_Man_t * p ) Aig_Obj_t * pNode; int i; // compute the transition relation - pbOutputs = ALLOC( DdNode *, Saig_ManPoNum(p) ); + pbOutputs = ABC_ALLOC( DdNode *, Saig_ManPoNum(p) ); Saig_ManForEachPo( p, pNode, i ) { pbOutputs[i] = Aig_ObjGlobalBdd(pNode); Cudd_Ref( pbOutputs[i] ); @@ -174,13 +174,13 @@ DdNode ** Aig_ManCreatePartitions( DdManager * dd, Aig_Man_t * p, int fReorder, Cudd_AutodynDisable( dd ); // compute the transition relation - pbParts = ALLOC( DdNode *, Saig_ManRegNum(p) ); + pbParts = ABC_ALLOC( DdNode *, Saig_ManRegNum(p) ); Saig_ManForEachLi( p, pNode, i ) { bVar = Cudd_bddIthVar( dd, Saig_ManCiNum(p) + i ); pbParts[i] = Cudd_bddXnor( dd, bVar, Aig_ObjGlobalBdd(pNode) ); Cudd_Ref( pbParts[i] ); } - // free global BDDs + // ABC_FREE global BDDs Aig_ManFreeGlobalBdds( p, dd ); // reorder and disable reordering @@ -316,7 +316,7 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D fprintf( stdout, "\r" ); } Cudd_RecursiveDeref( dd, bNext ); - // free the onion rings + // ABC_FREE the onion rings Vec_PtrForEachEntry( vOnionRings, bTemp, i ) Cudd_RecursiveDeref( dd, bTemp ); Vec_PtrFree( vOnionRings ); @@ -338,7 +338,7 @@ int Aig_ManComputeReachable( DdManager * dd, Aig_Man_t * p, DdNode ** pbParts, D fprintf( stdout, "Reachable states = %.0f. (Ratio = %.4f %%)\n", nMints, 100.0*nMints/pow(2.0, Saig_ManRegNum(p)) ); fflush( stdout ); } -//PRB( dd, bReached ); +//ABC_PRB( dd, bReached ); Cudd_RecursiveDeref( dd, bReached ); if ( nIters > nIterMax || Cudd_DagSize(bReached) > nBddMax ) { @@ -413,7 +413,7 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fParti break; } } - // free the onion rings + // ABC_FREE the onion rings Vec_PtrForEachEntry( vOnionRings, bTemp, i ) Cudd_RecursiveDeref( dd, bTemp ); Vec_PtrFree( vOnionRings ); @@ -425,10 +425,10 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fParti Cudd_RecursiveDeref( dd, bInitial ); for ( i = 0; i < Saig_ManRegNum(p); i++ ) Cudd_RecursiveDeref( dd, pbParts[i] ); - free( pbParts ); + ABC_FREE( pbParts ); for ( i = 0; i < Saig_ManPoNum(p); i++ ) Cudd_RecursiveDeref( dd, pbOutputs[i] ); - free( pbOutputs ); + ABC_FREE( pbOutputs ); if ( RetValue == -1 ) Cudd_Quit( dd ); else @@ -437,7 +437,7 @@ int Aig_ManVerifyUsingBdds( Aig_Man_t * p, int nBddMax, int nIterMax, int fParti // report the runtime if ( !fSilent ) { - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); fflush( stdout ); } return RetValue; diff --git a/src/aig/bdc/bdc.h b/src/aig/bdc/bdc.h index fc476ec6..0bdccf2b 100644 --- a/src/aig/bdc/bdc.h +++ b/src/aig/bdc/bdc.h @@ -20,10 +20,6 @@ #ifndef __BDC_H__ #define __BDC_H__ - -#ifdef __cplusplus -extern "C" { -#endif //////////////////////////////////////////////////////////////////////// /// INCLUDES /// @@ -32,6 +28,10 @@ extern "C" { //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// @@ -49,10 +49,10 @@ struct Bdc_Par_t_ }; // working with complemented attributes of objects -static inline int Bdc_IsComplement( Bdc_Fun_t * p ) { return (int)((PORT_PTRUINT_T)p & (PORT_PTRUINT_T)01); } -static inline Bdc_Fun_t * Bdc_Regular( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((PORT_PTRUINT_T)p & ~(PORT_PTRUINT_T)01); } -static inline Bdc_Fun_t * Bdc_Not( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((PORT_PTRUINT_T)p ^ (PORT_PTRUINT_T)01); } -static inline Bdc_Fun_t * Bdc_NotCond( Bdc_Fun_t * p, int c ) { return (Bdc_Fun_t *)((PORT_PTRUINT_T)p ^ (PORT_PTRUINT_T)(c!=0)); } +static inline int Bdc_IsComplement( Bdc_Fun_t * p ) { return (int)((ABC_PTRUINT_T)p & (ABC_PTRUINT_T)01); } +static inline Bdc_Fun_t * Bdc_Regular( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p & ~(ABC_PTRUINT_T)01); } +static inline Bdc_Fun_t * Bdc_Not( Bdc_Fun_t * p ) { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)01); } +static inline Bdc_Fun_t * Bdc_NotCond( Bdc_Fun_t * p, int c ) { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)(c!=0)); } //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// diff --git a/src/aig/bdc/bdcCore.c b/src/aig/bdc/bdcCore.c index 9067d315..fea08115 100644 --- a/src/aig/bdc/bdcCore.c +++ b/src/aig/bdc/bdcCore.c @@ -62,7 +62,7 @@ void Bdc_FuncSetCopy( Bdc_Fun_t * p, void * pCopy ) { p->pCopy = pCop Bdc_Man_t * Bdc_ManAlloc( Bdc_Par_t * pPars ) { Bdc_Man_t * p; - p = ALLOC( Bdc_Man_t, 1 ); + p = ABC_ALLOC( Bdc_Man_t, 1 ); memset( p, 0, sizeof(Bdc_Man_t) ); assert( pPars->nVarsMax > 1 && pPars->nVarsMax < 16 ); p->pPars = pPars; @@ -70,18 +70,18 @@ Bdc_Man_t * Bdc_ManAlloc( Bdc_Par_t * pPars ) p->nDivsLimit = 200; // internal nodes p->nNodesAlloc = 512; - p->pNodes = ALLOC( Bdc_Fun_t, p->nNodesAlloc ); + p->pNodes = ABC_ALLOC( Bdc_Fun_t, p->nNodesAlloc ); // memory p->vMemory = Vec_IntStart( 8 * p->nWords * p->nNodesAlloc ); Vec_IntClear(p->vMemory); // set up hash table p->nTableSize = (1 << p->pPars->nVarsMax); - p->pTable = ALLOC( Bdc_Fun_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Bdc_Fun_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Bdc_Fun_t *) * p->nTableSize ); p->vSpots = Vec_IntAlloc( 256 ); // truth tables p->vTruths = Vec_PtrAllocTruthTables( p->pPars->nVarsMax ); - p->puTemp1 = ALLOC( unsigned, 4 * p->nWords ); + p->puTemp1 = ABC_ALLOC( unsigned, 4 * p->nWords ); p->puTemp2 = p->puTemp1 + p->nWords; p->puTemp3 = p->puTemp2 + p->nWords; p->puTemp4 = p->puTemp3 + p->nWords; @@ -112,19 +112,19 @@ void Bdc_ManFree( Bdc_Man_t * p ) p->numCalls, p->numNodes, p->numReuse ); printf( "ANDs = %d. ORs = %d. Weak = %d. Muxes = %d. Memory = %.2f K\n", p->numAnds, p->numOrs, p->numWeaks, p->numMuxes, 4.0 * Vec_IntSize(p->vMemory) / (1<<10) ); - PRT( "Cache", p->timeCache ); - PRT( "Check", p->timeCheck ); - PRT( "Muxes", p->timeMuxes ); - PRT( "Supps", p->timeSupps ); - PRT( "TOTAL", p->timeTotal ); + ABC_PRT( "Cache", p->timeCache ); + ABC_PRT( "Check", p->timeCheck ); + ABC_PRT( "Muxes", p->timeMuxes ); + ABC_PRT( "Supps", p->timeSupps ); + ABC_PRT( "TOTAL", p->timeTotal ); } Vec_IntFree( p->vMemory ); Vec_IntFree( p->vSpots ); Vec_PtrFree( p->vTruths ); - free( p->puTemp1 ); - free( p->pNodes ); - free( p->pTable ); - free( p ); + ABC_FREE( p->puTemp1 ); + ABC_FREE( p->pNodes ); + ABC_FREE( p->pTable ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/bdc/bdcInt.h b/src/aig/bdc/bdcInt.h index a35663ef..71ad8449 100644 --- a/src/aig/bdc/bdcInt.h +++ b/src/aig/bdc/bdcInt.h @@ -21,10 +21,6 @@ #ifndef __BDC_INT_H__ #define __BDC_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -36,6 +32,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define BDC_SCALE 1000 // value used to compute the cost //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/cec/cec.c b/src/aig/cec/cec.c new file mode 100644 index 00000000..a017f831 --- /dev/null +++ b/src/aig/cec/cec.c @@ -0,0 +1,48 @@ +/**CFile**************************************************************** + + FileName [cec.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec/cec.h b/src/aig/cec/cec.h index fb0bb830..fa7c5dbc 100644 --- a/src/aig/cec/cec.h +++ b/src/aig/cec/cec.h @@ -21,10 +21,6 @@ #ifndef __CEC_H__ #define __CEC_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -44,8 +44,8 @@ struct Cec_ParSat_t_ int nBTLimit; // conflict limit at a node int nSatVarMax; // the max number of SAT variables int nCallsRecycle; // calls to perform before recycling SAT solver + int fPolarFlip; // flops polarity of variables int fFirstStop; // stop on the first sat output - int fPolarFlip; // uses polarity adjustment int fVerbose; // verbose stats }; @@ -55,8 +55,15 @@ struct Cec_ParCsw_t_ { int nWords; // the number of simulation words int nRounds; // the number of simulation rounds - int nBTlimit; // conflict limit at a node + int nItersMax; // the maximum number of iterations of SAT sweeping + int nBTLimit; // conflict limit at a node + int nSatVarMax; // the max number of SAT variables + int nCallsRecycle; // calls to perform before recycling SAT solver + int nLevelMax; // restriction on the level nodes to be swept + int nDepthMax; // the depth in terms of steps of speculative reduction int fRewriting; // enables AIG rewriting + int fFirstStop; // stop on the first sat output + int fVeryVerbose; // verbose stats int fVerbose; // verbose stats }; @@ -86,7 +93,8 @@ struct Cec_ParCec_t_ extern void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p ); extern void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p ); extern void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p ); -extern int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * p ); +extern Gia_Man_t * Cec_ManSatSweeping( Gia_Man_t * pAig, Cec_ParCsw_t * pPars ); +extern Gia_Man_t * Cec_ManSatSolving( Gia_Man_t * pAig, Cec_ParSat_t * pPars ); #ifdef __cplusplus } diff --git a/src/aig/cec/cecAig.c b/src/aig/cec/cecAig.c deleted file mode 100644 index 2a6f5683..00000000 --- a/src/aig/cec/cecAig.c +++ /dev/null @@ -1,151 +0,0 @@ -/**CFile**************************************************************** - - FileName [cecAig.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [Combinatinoal equivalence checking.] - - Synopsis [AIG manipulation.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: cecAig.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "cecInt.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Derives combinational miter of the two AIGs.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Aig_Obj_t * Cec_DeriveMiter_rec( Aig_Man_t * pNew, Aig_Obj_t * pObj ) -{ - if ( pObj->pData ) - return pObj->pData; - Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj) ); - if ( Aig_ObjIsBuf(pObj) ) - return pObj->pData = Aig_ObjChild0Copy(pObj); - Cec_DeriveMiter_rec( pNew, Aig_ObjFanin1(pObj) ); - pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ); - Aig_Regular(pObj->pData)->pHaig = pObj->pHaig; - return pObj->pData; -} - -/**Function************************************************************* - - Synopsis [Derives combinational miter of the two AIGs.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 ) -{ - Bar_Progress_t * pProgress = NULL; - Aig_Man_t * pNew; - Aig_Obj_t * pObj0, * pObj1, * pObjNew; - int i; - assert( Aig_ManPiNum(p0) == Aig_ManPiNum(p1) ); - assert( Aig_ManPoNum(p0) == Aig_ManPoNum(p1) ); - // create the new manager - pNew = Aig_ManStart( Aig_ManNodeNum(p0) + Aig_ManNodeNum(p1) ); - pNew->pName = Aig_UtilStrsav( p0->pName ); - // create the PIs - Aig_ManCleanData( p0 ); - Aig_ManCleanData( p1 ); - Aig_ManConst1(p0)->pData = Aig_ManConst1(pNew); - Aig_ManConst1(p1)->pData = Aig_ManConst1(pNew); - Aig_ManForEachPi( p0, pObj0, i ) - { - pObjNew = Aig_ObjCreatePi( pNew ); - pObj0->pData = pObjNew; - Aig_ManPi(p1, i)->pData = pObjNew; - } - // add logic for the POs - pProgress = Bar_ProgressStart( stdout, Aig_ManPoNum(p0) ); - Aig_ManForEachPo( p0, pObj0, i ) - { - Bar_ProgressUpdate( pProgress, i, "Miter..." ); - pObj1 = Aig_ManPo( p1, i ); - Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj0) ); - Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj1) ); - pObjNew = Aig_Exor( pNew, Aig_ObjChild0Copy(pObj0), Aig_ObjChild0Copy(pObj1) ); - Aig_ObjCreatePo( pNew, pObjNew ); - } - Bar_ProgressStop( pProgress ); - Aig_ManCleanup( pNew ); - Aig_ManSetRegNum( pNew, 0 ); - // check the resulting network -// if ( !Aig_ManCheck(pNew) ) -// printf( "Cec_DeriveMiter(): The check has failed.\n" ); - return pNew; -} - -/**Function************************************************************* - - Synopsis [Duplicates AIG in the DFS order.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Aig_Man_t * Cec_Duplicate( Aig_Man_t * p ) -{ - Aig_Man_t * pNew; - Aig_Obj_t * pObj; - int i; - // create the new manager - pNew = Aig_ManStart( Aig_ManNodeNum(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 ); - // add logic for the POs - Aig_ManForEachPo( p, pObj, i ) - { - Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj) ); - Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) ); - } - Aig_ManCleanup( pNew ); - Aig_ManSetRegNum( pNew, 0 ); - assert( Aig_ManBufNum(p) != 0 || Aig_ManNodeNum(p) == Aig_ManNodeNum(pNew) ); - // check the resulting network -// if ( !Aig_ManCheck(pNew) ) -// printf( "Cec_DeriveMiter(): The check has failed.\n" ); - return pNew; -} - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/aig/cec/cecClass.c b/src/aig/cec/cecClass.c index f3f6bf11..65fa2e9b 100644 --- a/src/aig/cec/cecClass.c +++ b/src/aig/cec/cecClass.c @@ -24,10 +24,67 @@ /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// +static inline int Cec_ObjRepr( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iRepr; } +static inline void Cec_ObjSetRepr( Cec_ManCsw_t * p, int Id, int Num ) { p->pObjs[Id].iRepr = Num; } + +static inline int Cec_ObjProved( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iProved; } +static inline void Cec_ObjSetProved( Cec_ManCsw_t * p, int Id ) { p->pObjs[Id].iProved = 1; } + +static inline int Cec_ObjFailed( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iFailed; } +static inline void Cec_ObjSetFailed( Cec_ManCsw_t * p, int Id ) { p->pObjs[Id].iFailed = 1; } + +static inline int Cec_ObjNext( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].iNext; } +static inline void Cec_ObjSetNext( Cec_ManCsw_t * p, int Id, int Num ) { p->pObjs[Id].iNext = Num; } + +static inline unsigned Cec_ObjSim( Cec_ManCsw_t * p, int Id ) { return p->pObjs[Id].SimNum; } +static inline unsigned * Cec_ObjSimP1( Cec_ManCsw_t * p, int Id ) { return &p->pObjs[Id].SimNum; } +static inline unsigned * Cec_ObjSimP( Cec_ManCsw_t * p, int Id ) { return p->pMems + Cec_ObjSim(p, Id) + 1; } +static inline void Cec_ObjSetSim( Cec_ManCsw_t * p, int Id, unsigned n ) { p->pObjs[Id].SimNum = n; } + +static inline int Cec_ObjIsConst( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) == 0; } +static inline int Cec_ObjIsHead( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) < 0 && Cec_ObjNext(p, Id) > 0; } +static inline int Cec_ObjIsNone( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) < 0 && Cec_ObjNext(p, Id) == 0; } +static inline int Cec_ObjIsTail( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) > 0 && Cec_ObjNext(p, Id) == 0; } +static inline int Cec_ObjIsClass( Cec_ManCsw_t * p, int Id ) { return Cec_ObjRepr(p, Id) > 0 || Cec_ObjNext(p, Id) > 0; } + +#define Cec_ManForEachObj( p, i ) \ + for ( i = 0; i < Gia_ManObjNum(p->pAig); i++ ) +#define Cec_ManForEachObj1( p, i ) \ + for ( i = 1; i < Gia_ManObjNum(p->pAig); i++ ) +#define Cec_ManForEachClass( p, i ) \ + for ( i = 1; i < Gia_ManObjNum(p->pAig); i++ ) if ( !Cec_ObjIsHead(p, i) ) {} else +#define Cec_ClassForEachObj( p, i, iObj ) \ + for ( assert(Cec_ObjIsHead(p, i)), iObj = i; iObj; iObj = Cec_ObjNext(p, iObj) ) +#define Cec_ClassForEachObj1( p, i, iObj ) \ + for ( assert(Cec_ObjIsHead(p, i)), iObj = Cec_ObjNext(p, i); iObj; iObj = Cec_ObjNext(p, iObj) ) + //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// +/**Function************************************************************* + + Synopsis [Creates the set of representatives.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int * Cec_ManCswDeriveReprs( Cec_ManCsw_t * p ) +{ + int i, * pReprs = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) ); + for ( i = 1; i < Gia_ManObjNum(p->pAig); i++ ) + if ( Cec_ObjProved(p, i) ) + { + assert( Cec_ObjRepr(p, i) >= 0 ); + pReprs[i] = Cec_ObjRepr(p, i); + } + return pReprs; +} + /**Function************************************************************* Synopsis [] @@ -39,42 +96,50 @@ SeeAlso [] ***********************************************************************/ -Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p ) +Gia_Man_t * Cec_ManCswDupWithClasses( Cec_ManCsw_t * p ) { - Aig_Man_t * pAig; - Aig_Obj_t ** pCopy; - Aig_Obj_t * pMiter, * pRes0, * pRes1, * pRepr; - int i; - pCopy = ALLOC( Aig_Obj_t *, p->nObjs ); - pCopy[0] = NULL; - pAig = Aig_ManStart( p->nNodes ); - for ( i = 1; i < p->nObjs; i++ ) + Gia_Man_t * pNew, * pTemp; + Gia_Obj_t * pObj, * pRepr; + int iRes0, iRes1, iRepr, iNode; + int i, fCompl, * piCopies; + Vec_IntClear( p->vXorNodes ); + Gia_ManLevelNum( p->pAig ); + pNew = Gia_ManStart( Gia_ManObjNum(p->pAig) ); + pNew->pName = Aig_UtilStrsav( p->pAig->pName ); + Gia_ManHashAlloc( pNew ); + piCopies = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) ); + piCopies[0] = 0; + Gia_ManForEachObj1( p->pAig, pObj, i ) { - if ( p->pFans0[i] == 0 ) // pi always has zero first fanin + if ( Gia_ObjIsCi(pObj) ) { - pCopy[i] = Aig_ObjCreatePi( pAig ); + piCopies[i] = Gia_ManAppendCi( pNew ); continue; } - if ( p->pFans1[i] == 0 ) // po always has non-zero 1st fanin and zero 2nd fanin + iRes0 = Gia_LitNotCond( piCopies[Gia_ObjFaninId0(pObj,i)], Gia_ObjFaninC0(pObj) ); + if ( Gia_ObjIsCo(pObj) ) + { + Gia_ManAppendCo( pNew, iRes0 ); continue; - pRes0 = pCopy[ Cec_Lit2Var(p->pFans0[i]) ]; - pRes0 = Aig_NotCond( pRes0, Cec_LitIsCompl(p->pFans0[i]) ); - pRes1 = pCopy[ Cec_Lit2Var(p->pFans1[i]) ]; - pRes1 = Aig_NotCond( pRes1, Cec_LitIsCompl(p->pFans1[i]) ); - pCopy[i] = Aig_And( pAig, pRes0, pRes1 ); - if ( p->pReprs[i] < 0 ) + } + iRes1 = Gia_LitNotCond( piCopies[Gia_ObjFaninId1(pObj,i)], Gia_ObjFaninC1(pObj) ); + iNode = piCopies[i] = Gia_ManHashAnd( pNew, iRes0, iRes1 ); + if ( Cec_ObjRepr(p, i) < 0 || !Cec_ObjProved(p, i) ) continue; - assert( p->pReprs[i] < i ); - pRepr = p->pReprs[i]? pCopy[ p->pReprs[i] ] : Aig_ManConst1(pAig); - if ( Aig_Regular(pCopy[i]) == Aig_Regular(pRepr) ) + assert( Cec_ObjRepr(p, i) < i ); + iRepr = piCopies[Cec_ObjRepr(p, i)]; + if ( Gia_LitRegular(iNode) == Gia_LitRegular(iRepr) ) continue; - pMiter = Aig_Exor( pAig, pCopy[i], pRepr ); - Aig_ObjCreatePo( pAig, Aig_NotCond(pMiter, Aig_ObjPhaseReal(pMiter)) ); + pRepr = Gia_ManObj( p->pAig, Cec_ObjRepr(p, i) ); + fCompl = Gia_ObjPhaseReal(pObj) ^ Gia_ObjPhaseReal(pRepr); + piCopies[i] = Gia_LitNotCond( iRepr, fCompl ); } - free( pCopy ); - Aig_ManSetRegNum( pAig, 0 ); - Aig_ManCleanup( pAig ); - return pAig; + ABC_FREE( piCopies ); + Gia_ManHashStop( pNew ); + Gia_ManSetRegNum( pNew, 0 ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; } /**Function************************************************************* @@ -88,16 +153,70 @@ Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p ) SeeAlso [] ***********************************************************************/ -int Caig_ManCountOne( Caig_Man_t * p, int i ) +Gia_Man_t * Cec_ManCswSpecReduction( Cec_ManCsw_t * p ) { - int Ent, nLits = 0; - assert( p->pReprs[i] < 0 && p->pNexts[i] > 0 ); - for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] ) + Gia_Man_t * pNew, * pTemp; + Gia_Obj_t * pObj, * pRepr; + int iRes0, iRes1, iRepr, iNode, iMiter; + int i, fCompl, * piCopies, * pDepths; + Vec_IntClear( p->vXorNodes ); +// Gia_ManLevelNum( p->pAig ); + pNew = Gia_ManStart( Gia_ManObjNum(p->pAig) ); + pNew->pName = Aig_UtilStrsav( p->pAig->pName ); + Gia_ManHashAlloc( pNew ); + piCopies = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) ); + pDepths = ABC_CALLOC( int, Gia_ManObjNum(p->pAig) ); + piCopies[0] = 0; + Gia_ManForEachObj1( p->pAig, pObj, i ) { - assert( p->pReprs[Ent] == i ); - nLits++; + if ( Gia_ObjIsCi(pObj) ) + { + piCopies[i] = Gia_ManAppendCi( pNew ); + continue; + } + if ( Gia_ObjIsCo(pObj) ) + continue; + if ( piCopies[Gia_ObjFaninId0(pObj,i)] == -1 || + piCopies[Gia_ObjFaninId1(pObj,i)] == -1 ) + continue; + iRes0 = Gia_LitNotCond( piCopies[Gia_ObjFaninId0(pObj,i)], Gia_ObjFaninC0(pObj) ); + iRes1 = Gia_LitNotCond( piCopies[Gia_ObjFaninId1(pObj,i)], Gia_ObjFaninC1(pObj) ); + iNode = piCopies[i] = Gia_ManHashAnd( pNew, iRes0, iRes1 ); + pDepths[i] = AIG_MAX( pDepths[Gia_ObjFaninId0(pObj,i)], pDepths[Gia_ObjFaninId1(pObj,i)] ); + if ( Cec_ObjRepr(p, i) < 0 || Cec_ObjFailed(p, i) ) + continue; + assert( Cec_ObjRepr(p, i) < i ); + iRepr = piCopies[Cec_ObjRepr(p, i)]; + if ( iRepr == -1 ) + continue; + if ( Gia_LitRegular(iNode) == Gia_LitRegular(iRepr) ) + continue; + pRepr = Gia_ManObj( p->pAig, Cec_ObjRepr(p, i) ); + fCompl = Gia_ObjPhaseReal(pObj) ^ Gia_ObjPhaseReal(pRepr); + piCopies[i] = Gia_LitNotCond( iRepr, fCompl ); + if ( Cec_ObjProved(p, i) ) + continue; +// if ( p->pPars->nLevelMax && +// (Gia_ObjLevel(p->pAig, pObj) > p->pPars->nLevelMax || +// Gia_ObjLevel(p->pAig, pRepr) > p->pPars->nLevelMax) ) +// continue; + // produce speculative miter + iMiter = Gia_ManHashXor( pNew, iNode, piCopies[i] ); + Gia_ManAppendCo( pNew, iMiter ); + Vec_IntPush( p->vXorNodes, Cec_ObjRepr(p, i) ); + Vec_IntPush( p->vXorNodes, i ); + // add to the depth of this node + pDepths[i] = 1 + AIG_MAX( pDepths[i], pDepths[Cec_ObjRepr(p, i)] ); + if ( p->pPars->nDepthMax && pDepths[i] >= p->pPars->nDepthMax ) + piCopies[i] = -1; } - return 1 + nLits; + ABC_FREE( piCopies ); + ABC_FREE( pDepths ); + Gia_ManHashStop( pNew ); + Gia_ManSetRegNum( pNew, 0 ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; } /**Function************************************************************* @@ -109,15 +228,52 @@ int Caig_ManCountOne( Caig_Man_t * p, int i ) SideEffects [] SeeAlso [] - + ***********************************************************************/ -int Caig_ManCountLiterals( Caig_Man_t * p ) +Gia_Man_t * Cec_ManCswSpecReductionProved( Cec_ManCsw_t * p ) { - int i, nLits = 0; - for ( i = 1; i < p->nObjs; i++ ) - if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) - nLits += Caig_ManCountOne(p, i) - 1; - return nLits; + Gia_Man_t * pNew, * pTemp; + Gia_Obj_t * pObj, * pRepr; + int iRes0, iRes1, iRepr, iNode, iMiter; + int i, fCompl, * piCopies; + Vec_IntClear( p->vXorNodes ); + Gia_ManLevelNum( p->pAig ); + pNew = Gia_ManStart( Gia_ManObjNum(p->pAig) ); + pNew->pName = Aig_UtilStrsav( p->pAig->pName ); + Gia_ManHashAlloc( pNew ); + piCopies = ABC_FALLOC( int, Gia_ManObjNum(p->pAig) ); + piCopies[0] = 0; + Gia_ManForEachObj1( p->pAig, pObj, i ) + { + if ( Gia_ObjIsCi(pObj) ) + { + piCopies[i] = Gia_ManAppendCi( pNew ); + continue; + } + if ( Gia_ObjIsCo(pObj) ) + continue; + iRes0 = Gia_LitNotCond( piCopies[Gia_ObjFaninId0(pObj,i)], Gia_ObjFaninC0(pObj) ); + iRes1 = Gia_LitNotCond( piCopies[Gia_ObjFaninId1(pObj,i)], Gia_ObjFaninC1(pObj) ); + iNode = piCopies[i] = Gia_ManHashAnd( pNew, iRes0, iRes1 ); + if ( Cec_ObjRepr(p, i) < 0 || !Cec_ObjProved(p, i) ) + continue; + assert( Cec_ObjRepr(p, i) < i ); + iRepr = piCopies[Cec_ObjRepr(p, i)]; + if ( Gia_LitRegular(iNode) == Gia_LitRegular(iRepr) ) + continue; + pRepr = Gia_ManObj( p->pAig, Cec_ObjRepr(p, i) ); + fCompl = Gia_ObjPhaseReal(pObj) ^ Gia_ObjPhaseReal(pRepr); + piCopies[i] = Gia_LitNotCond( iRepr, fCompl ); + // add speculative miter + iMiter = Gia_ManHashXor( pNew, iNode, piCopies[i] ); + Gia_ManAppendCo( pNew, iMiter ); + } + ABC_FREE( piCopies ); + Gia_ManHashStop( pNew ); + Gia_ManSetRegNum( pNew, 0 ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; } /**Function************************************************************* @@ -131,13 +287,15 @@ int Caig_ManCountLiterals( Caig_Man_t * p ) SeeAlso [] ***********************************************************************/ -void Caig_ManPrintOne( Caig_Man_t * p, int i, int Counter ) +int Cec_ManCswCountOne( Cec_ManCsw_t * p, int i ) { - int Ent; - printf( "Class %4d : Num = %2d {", Counter, Caig_ManCountOne(p, i) ); - for ( Ent = i; Ent; Ent = p->pNexts[Ent] ) - printf(" %d", Ent ); - printf( " }\n" ); + int Ent, nLits = 1; + Cec_ClassForEachObj1( p, i, Ent ) + { + assert( Cec_ObjRepr(p, Ent) == i ); + nLits++; + } + return nLits; } /**Function************************************************************* @@ -151,25 +309,12 @@ void Caig_ManPrintOne( Caig_Man_t * p, int i, int Counter ) SeeAlso [] ***********************************************************************/ -void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose ) +int Cec_ManCswCountLitsAll( Cec_ManCsw_t * p ) { - int i, Counter = 0, Counter1 = 0, CounterX = 0, nLits; - for ( i = 1; i < p->nObjs; i++ ) - { - if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) - Counter++; - if ( p->pReprs[i] == 0 ) - Counter1++; - if ( p->pReprs[i] < 0 && p->pNexts[i] == 0 ) - CounterX++; - } - nLits = Caig_ManCountLiterals( p ); - printf( "Class = %6d. Const1 = %6d. Other = %6d. Lits = %7d. Total = %7d.\n", - Counter, Counter1, CounterX, nLits, nLits+Counter1 ); - if ( fVerbose ) - for ( i = 1; i < p->nObjs; i++ ) - if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) - Caig_ManPrintOne( p, i, ++Counter ); + int i, nLits = 0; + Cec_ManForEachObj( p, i ) + nLits += (Cec_ObjRepr(p, i) >= 0); + return nLits; } /**Function************************************************************* @@ -183,12 +328,13 @@ void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose ) SeeAlso [] ***********************************************************************/ -void Caig_ManCollectSimsSimple( Caig_Man_t * p, int i ) +void Cec_ManCswPrintOne( Cec_ManCsw_t * p, int i, int Counter ) { int Ent; - Vec_PtrClear( p->vSims ); - for ( Ent = i; Ent; Ent = p->pNexts[Ent] ) - Vec_PtrPush( p->vSims, p->pSims + Ent ); + printf( "Class %4d : Num = %2d {", Counter, Cec_ManCswCountOne(p, i) ); + Cec_ClassForEachObj( p, i, Ent ) + printf(" %d", Ent ); + printf( " }\n" ); } /**Function************************************************************* @@ -202,15 +348,26 @@ void Caig_ManCollectSimsSimple( Caig_Man_t * p, int i ) SeeAlso [] ***********************************************************************/ -void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i ) +void Cec_ManCswPrintClasses( Cec_ManCsw_t * p, int fVerbose ) { - unsigned * pSim; - int Ent; - Vec_PtrClear( p->vSims ); - for ( Ent = i; Ent; Ent = p->pNexts[Ent] ) + int i, Counter = 0, Counter1 = 0, CounterX = 0, nLits; + Cec_ManForEachObj1( p, i ) + { + if ( Cec_ObjIsHead(p, i) ) + Counter++; + else if ( Cec_ObjIsConst(p, i) ) + Counter1++; + else if ( Cec_ObjIsNone(p, i) ) + CounterX++; + } + nLits = Cec_ManCswCountLitsAll( p ); + printf( "Class =%7d. Const =%7d. Unsed =%7d. Lits =%8d. All =%8d. Mem = %5.2f Mb\n", + Counter, Counter1, CounterX, nLits-Counter1, nLits, 1.0*p->nMemsMax*(p->pPars->nWords+1)/(1<<20) ); + if ( fVerbose ) { - pSim = Caig_ManSimDeref( p, Ent ); - Vec_PtrPush( p->vSims, pSim + 1 ); + Counter = 0; + Cec_ManForEachClass( p, i ) + Cec_ManCswPrintOne( p, i, ++Counter ); } } @@ -225,7 +382,7 @@ void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i ) SeeAlso [] ***********************************************************************/ -int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords ) +int Cec_ManCswCompareEqual( unsigned * p0, unsigned * p1, int nWords ) { int w; if ( (p0[0] & 1) == (p1[0] & 1) ) @@ -255,7 +412,7 @@ int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords ) SeeAlso [] ***********************************************************************/ -int Caig_ManCompareConst( unsigned * p, int nWords ) +int Cec_ManCswCompareConst( unsigned * p, int nWords ) { int w; if ( p[0] & 1 ) @@ -285,26 +442,26 @@ int Caig_ManCompareConst( unsigned * p, int nWords ) SeeAlso [] ***********************************************************************/ -void Caig_ManClassCreate( Caig_Man_t * p, Vec_Int_t * vClass ) +void Cec_ManCswClassCreate( Cec_ManCsw_t * p, Vec_Int_t * vClass ) { - int * pNext, Repr, Ent, i; + int Repr = -1, EntPrev = -1, Ent, i; assert( Vec_IntSize(vClass) > 0 ); Vec_IntForEachEntry( vClass, Ent, i ) { if ( i == 0 ) { Repr = Ent; - p->pReprs[Ent] = -1; - pNext = p->pNexts + Ent; + Cec_ObjSetRepr( p, Ent, -1 ); + EntPrev = Ent; } else { - p->pReprs[Ent] = Repr; - *pNext = Ent; - pNext = p->pNexts + Ent; + Cec_ObjSetRepr( p, Ent, Repr ); + Cec_ObjSetNext( p, EntPrev, Ent ); + EntPrev = Ent; } } - *pNext = 0; + Cec_ObjSetNext( p, EntPrev, 0 ); } /**Function************************************************************* @@ -318,32 +475,28 @@ void Caig_ManClassCreate( Caig_Man_t * p, Vec_Int_t * vClass ) SeeAlso [] ***********************************************************************/ -int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims ) +int Cec_ManCswClassRefineOne( Cec_ManCsw_t * p, int i, int fFirst ) { unsigned * pSim0, * pSim1; - int Ent, c = 0, d = 0; + int Ent; Vec_IntClear( p->vClassOld ); Vec_IntClear( p->vClassNew ); - pSim0 = Vec_PtrEntry( vSims, c++ ); Vec_IntPush( p->vClassOld, i ); - for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] ) + pSim0 = fFirst? Cec_ObjSimP1(p, i) : Cec_ObjSimP(p, i); + Cec_ClassForEachObj1( p, i, Ent ) { - pSim1 = Vec_PtrEntry( vSims, c++ ); - if ( Caig_ManCompareEqual( pSim0, pSim1, p->nWords ) ) + pSim1 = fFirst? Cec_ObjSimP1(p, Ent) : Cec_ObjSimP(p, Ent); + if ( Cec_ManCswCompareEqual( pSim0, pSim1, p->nWords ) ) Vec_IntPush( p->vClassOld, Ent ); else - { Vec_IntPush( p->vClassNew, Ent ); - Vec_PtrWriteEntry( vSims, d++, pSim1 ); - } } - Vec_PtrShrink( vSims, d ); - if ( Vec_IntSize(p->vClassNew) == 0 ) + if ( Vec_IntSize( p->vClassNew ) == 0 ) return 0; - Caig_ManClassCreate( p, p->vClassOld ); - Caig_ManClassCreate( p, p->vClassNew ); + Cec_ManCswClassCreate( p, p->vClassOld ); + Cec_ManCswClassCreate( p, p->vClassNew ); if ( Vec_IntSize(p->vClassNew) > 1 ) - return 1 + Caig_ManClassRefineOne( p, Vec_IntEntry(p->vClassNew,0), vSims ); + return 1 + Cec_ManCswClassRefineOne( p, Vec_IntEntry(p->vClassNew,0), fFirst ); return 1; } @@ -358,7 +511,7 @@ int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims ) SeeAlso [] ***********************************************************************/ -int Caig_ManHashKey( unsigned * pSim, int nWords, int nTableSize ) +int Cec_ManCswHashKey( unsigned * pSim, int nWords, int nTableSize ) { static int s_Primes[16] = { 1291, 1699, 1999, 2357, 2953, 3313, 3907, 4177, @@ -386,49 +539,51 @@ int Caig_ManHashKey( unsigned * pSim, int nWords, int nTableSize ) SeeAlso [] ***********************************************************************/ -void Caig_ManClassesCreate( Caig_Man_t * p ) +void Cec_ManCswClassesCreate( Cec_ManCsw_t * p ) { int * pTable, nTableSize, i, Key; - nTableSize = Aig_PrimeCudd( 100 + p->nObjs / 10 ); - pTable = CALLOC( int, nTableSize ); - p->pReprs = ALLOC( int, p->nObjs ); - p->pNexts = CALLOC( int, p->nObjs ); - for ( i = 1; i < p->nObjs; i++ ) + p->nWords = 1; + nTableSize = Aig_PrimeCudd( 100 + Gia_ManObjNum(p->pAig) / 10 ); + pTable = ABC_CALLOC( int, nTableSize ); + Cec_ObjSetRepr( p, 0, -1 ); + Cec_ManForEachObj1( p, i ) { - if ( Caig_ManCompareConst( p->pSims + i, 1 ) ) + if ( Gia_ObjIsCo(Gia_ManObj(p->pAig, i)) ) + { + Cec_ObjSetRepr( p, i, -1 ); + continue; + } + if ( Cec_ManCswCompareConst( Cec_ObjSimP1(p, i), p->nWords ) ) { - p->pReprs[i] = 0; + Cec_ObjSetRepr( p, i, 0 ); continue; } - Key = Caig_ManHashKey( p->pSims + i, 1, nTableSize ); + Key = Cec_ManCswHashKey( Cec_ObjSimP1(p, i), p->nWords, nTableSize ); if ( pTable[Key] == 0 ) - p->pReprs[i] = -1; + Cec_ObjSetRepr( p, i, -1 ); else { - p->pNexts[ pTable[Key] ] = i; - p->pReprs[i] = p->pReprs[ pTable[Key] ]; - if ( p->pReprs[i] == -1 ) - p->pReprs[i] = pTable[Key]; + Cec_ObjSetNext( p, pTable[Key], i ); + Cec_ObjSetRepr( p, i, Cec_ObjRepr(p, pTable[Key]) ); + if ( Cec_ObjRepr(p, i) == -1 ) + Cec_ObjSetRepr( p, i, pTable[Key] ); } pTable[Key] = i; } - FREE( pTable ); -Caig_ManPrintClasses( p, 0 ); + ABC_FREE( pTable ); + if ( p->pPars->fVeryVerbose ) + Cec_ManCswPrintClasses( p, 0 ); // refine classes - p->vSims = Vec_PtrAlloc( 100 ); - p->vClassOld = Vec_IntAlloc( 100 ); - p->vClassNew = Vec_IntAlloc( 100 ); - for ( i = 1; i < p->nObjs; i++ ) - if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) - { - Caig_ManCollectSimsSimple( p, i ); - Caig_ManClassRefineOne( p, i, p->vSims ); - } + Cec_ManForEachClass( p, i ) + Cec_ManCswClassRefineOne( p, i, 1 ); // clean memory - memset( p->pSims, 0, sizeof(unsigned) * p->nObjs ); -Caig_ManPrintClasses( p, 0 ); + Cec_ManForEachObj( p, i ) + Cec_ObjSetSim( p, i, 0 ); + if ( p->pPars->fVeryVerbose ) + Cec_ManCswPrintClasses( p, 0 ); } + /**Function************************************************************* Synopsis [] @@ -440,27 +595,87 @@ Caig_ManPrintClasses( p, 0 ); SeeAlso [] ***********************************************************************/ -void Caig_ManSimulateSimple( Caig_Man_t * p ) +void Cec_ManCswSimulateSimple( Cec_ManCsw_t * p ) { + Gia_Obj_t * pObj; unsigned Res0, Res1; int i; - for ( i = 1; i < p->nObjs; i++ ) + Gia_ManForEachCi( p->pAig, pObj, i ) + Cec_ObjSetSim( p, i, Aig_ManRandom(0) ); + Gia_ManForEachAnd( p->pAig, pObj, i ) + { + Res0 = Cec_ObjSim( p, Gia_ObjFaninId0(pObj, i) ); + Res1 = Cec_ObjSim( p, Gia_ObjFaninId1(pObj, i) ); + Cec_ObjSetSim( p, i, (Gia_ObjFaninC0(pObj)? ~Res0: Res0) & + (Gia_ObjFaninC1(pObj)? ~Res1: Res1) ); + } +} + +/**Function************************************************************* + + Synopsis [References simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManCswSimMemRelink( Cec_ManCsw_t * p ) +{ + unsigned * pPlace, Ent; + pPlace = &p->MemFree; + for ( Ent = p->nMems * (p->nWords + 1); + Ent + p->nWords + 1 < (unsigned)p->nWordsAlloc; + Ent += p->nWords + 1 ) + { + *pPlace = Ent; + pPlace = p->pMems + Ent; + } + *pPlace = 0; +} + +/**Function************************************************************* + + Synopsis [References simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned * Cec_ManCswSimRef( Cec_ManCsw_t * p, int i ) +{ + unsigned * pSim; + assert( p->pObjs[i].SimNum == 0 ); + if ( p->MemFree == 0 ) { - if ( p->pFans0[i] == 0 ) // pi + if ( p->nWordsAlloc == 0 ) { - p->pSims[i] = Aig_ManRandom( 0 ); - continue; + assert( p->pMems == NULL ); + p->nWordsAlloc = (1<<17); // -> 1Mb + p->nMems = 1; } - Res0 = p->pSims[Cec_Lit2Var(p->pFans0[i])]; - Res1 = p->pSims[Cec_Lit2Var(p->pFans1[i])]; - p->pSims[i] = (Cec_LitIsCompl(p->pFans0[i]) ? ~Res0: Res0) & - (Cec_LitIsCompl(p->pFans1[i]) ? ~Res1: Res1); + p->nWordsAlloc *= 2; + p->pMems = ABC_REALLOC( unsigned, p->pMems, p->nWordsAlloc ); + Cec_ManCswSimMemRelink( p ); } + p->pObjs[i].SimNum = p->MemFree; + pSim = p->pMems + p->MemFree; + p->MemFree = pSim[0]; + pSim[0] = Gia_ObjValue( Gia_ManObj(p->pAig, i) ); + p->nMems++; + if ( p->nMemsMax < p->nMems ) + p->nMemsMax = p->nMems; + return pSim; } /**Function************************************************************* - Synopsis [] + Synopsis [Dereference simulaton info.] Description [] @@ -469,10 +684,19 @@ void Caig_ManSimulateSimple( Caig_Man_t * p ) SeeAlso [] ***********************************************************************/ -void Caig_ManProcessClass( Caig_Man_t * p, int i ) +unsigned * Cec_ManCswSimDeref( Cec_ManCsw_t * p, int i ) { - Caig_ManCollectSimsNormal( p, i ); - Caig_ManClassRefineOne( p, i, p->vSims ); + unsigned * pSim; + assert( p->pObjs[i].SimNum > 0 ); + pSim = p->pMems + p->pObjs[i].SimNum; + if ( --pSim[0] == 0 ) + { + pSim[0] = p->MemFree; + p->MemFree = p->pObjs[i].SimNum; + p->pObjs[i].SimNum = 0; + p->nMems--; + } + return pSim; } /**Function************************************************************* @@ -486,51 +710,179 @@ void Caig_ManProcessClass( Caig_Man_t * p, int i ) SeeAlso [] ***********************************************************************/ -void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined ) +void Cec_ManCswProcessRefined( Cec_ManCsw_t * p, Vec_Int_t * vRefined ) { - Vec_Int_t * vClasses; - int * pTable, nTableSize, i, Key, iNode; unsigned * pSim; + int * pTable, nTableSize, i, k, Key; if ( Vec_IntSize(vRefined) == 0 ) return; nTableSize = Aig_PrimeCudd( 100 + Vec_IntSize(vRefined) / 5 ); - pTable = CALLOC( int, nTableSize ); - vClasses = Vec_IntAlloc( 100 ); - Vec_IntForEachEntry( vRefined, iNode, i ) + pTable = ABC_CALLOC( int, nTableSize ); + Vec_IntForEachEntry( vRefined, i, k ) { - pSim = Caig_ManSimRead( p, iNode ); - assert( !Caig_ManCompareConst( pSim + 1, p->nWords ) ); - Key = Caig_ManHashKey( pSim + 1, p->nWords, nTableSize ); + if ( i == 7720 ) + { + int s = 0; + } + pSim = Cec_ObjSimP( p, i ); + assert( !Cec_ManCswCompareConst( pSim, p->nWords ) ); + Key = Cec_ManCswHashKey( pSim, p->nWords, nTableSize ); if ( pTable[Key] == 0 ) { - assert( p->pReprs[iNode] == 0 ); - assert( p->pNexts[iNode] == 0 ); - p->pReprs[iNode] = -1; - Vec_IntPush( vClasses, iNode ); + assert( Cec_ObjRepr(p, i) == 0 ); + assert( Cec_ObjNext(p, i) == 0 ); + Cec_ObjSetRepr( p, i, -1 ); } else { - p->pNexts[ pTable[Key] ] = iNode; - p->pReprs[iNode] = p->pReprs[ pTable[Key] ]; - if ( p->pReprs[iNode] == -1 ) - p->pReprs[iNode] = pTable[Key]; - assert( p->pReprs[iNode] > 0 ); + Cec_ObjSetNext( p, pTable[Key], i ); + Cec_ObjSetRepr( p, i, Cec_ObjRepr(p, pTable[Key]) ); + if ( Cec_ObjRepr(p, i) == -1 ) + Cec_ObjSetRepr( p, i, pTable[Key] ); + assert( Cec_ObjRepr(p, i) > 0 ); } - pTable[Key] = iNode; + pTable[Key] = i; } - FREE( pTable ); - // refine classes - Vec_IntForEachEntry( vClasses, iNode, i ) + Vec_IntForEachEntry( vRefined, i, k ) { - if ( p->pNexts[iNode] == 0 ) + if ( Cec_ObjIsHead( p, i ) ) + Cec_ManCswClassRefineOne( p, i, 0 ); + } + Vec_IntForEachEntry( vRefined, i, k ) + Cec_ManCswSimDeref( p, i ); + ABC_FREE( pTable ); +} + + +/**Function************************************************************* + + Synopsis [Simulates one round.] + + Description [Returns the number of PO entry if failed; 0 otherwise.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManCswSimulateRound( Cec_ManCsw_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * vInfoCos, int iSeries, int fRandomize ) +{ + static int nCountRand = 0; + Gia_Obj_t * pObj; + unsigned * pRes0, * pRes1, * pRes; + int i, k, w, Ent, iCiId = 0, iCoId = 0; + p->nMemsMax = 0; + Vec_IntClear( p->vRefinedC ); + if ( Gia_ObjValue(Gia_ManConst0(p->pAig)) ) + { + pRes = Cec_ManCswSimRef( p, 0 ); + for ( w = 1; w <= p->nWords; w++ ) + pRes[w] = 0; + } + Gia_ManForEachObj1( p->pAig, pObj, i ) + { + if ( Gia_ObjIsCi(pObj) ) + { + if ( Gia_ObjValue(pObj) == 0 ) + { + iCiId++; + continue; + } + pRes = Cec_ManCswSimRef( p, i ); + if ( vInfoCis ) + { + pRes0 = Vec_PtrEntry( vInfoCis, iCiId++ ); + for ( w = 1; w <= p->nWords; w++ ) + { + pRes[w] = pRes0[iSeries*p->nWords+w-1]; + if ( fRandomize ) + pRes[w] ^= (1 << (nCountRand++ & 0x1f)); + } + } + else + { + for ( w = 1; w <= p->nWords; w++ ) + pRes[w] = Aig_ManRandom( 0 ); + } + // make sure the first pattern is always zero + pRes[1] ^= (pRes[1] & 1); + goto references; + } + if ( Gia_ObjIsCo(pObj) ) // co always has non-zero 1st fanin and zero 2nd fanin { - Caig_ManSimDeref( p, iNode ); + pRes0 = Cec_ManCswSimDeref( p, Gia_ObjFaninId0(pObj,i) ); + if ( vInfoCos ) + { + pRes = Vec_PtrEntry( vInfoCos, iCoId++ ); + if ( Gia_ObjFaninC0(pObj) ) + for ( w = 1; w <= p->nWords; w++ ) + pRes[w-1] = ~pRes0[w]; + else + for ( w = 1; w <= p->nWords; w++ ) + pRes[w-1] = pRes0[w]; + } continue; } - Caig_ManCollectSimsNormal( p, iNode ); - Caig_ManClassRefineOne( p, iNode, p->vSims ); + assert( Gia_ObjValue(pObj) ); + pRes = Cec_ManCswSimRef( p, i ); + pRes0 = Cec_ManCswSimDeref( p, Gia_ObjFaninId0(pObj,i) ); + pRes1 = Cec_ManCswSimDeref( p, Gia_ObjFaninId1(pObj,i) ); + if ( Gia_ObjFaninC0(pObj) ) + { + if ( Gia_ObjFaninC1(pObj) ) + for ( w = 1; w <= p->nWords; w++ ) + pRes[w] = ~(pRes0[w] | pRes1[w]); + else + for ( w = 1; w <= p->nWords; w++ ) + pRes[w] = ~pRes0[w] & pRes1[w]; + } + else + { + if ( Gia_ObjFaninC1(pObj) ) + for ( w = 1; w <= p->nWords; w++ ) + pRes[w] = pRes0[w] & ~pRes1[w]; + else + for ( w = 1; w <= p->nWords; w++ ) + pRes[w] = pRes0[w] & pRes1[w]; + } +references: + // if this node is candidate constant, collect it + if ( Cec_ObjIsConst(p, i) && !Cec_ManCswCompareConst(pRes + 1, p->nWords) ) + { + pRes[0]++; + Vec_IntPush( p->vRefinedC, i ); + } + // if the node belongs to a class, save it + if ( Cec_ObjIsClass(p, i) ) + pRes[0]++; + // if this is the last node of the class, process it + if ( Cec_ObjIsTail(p, i) ) + { + Vec_IntClear( p->vClassTemp ); + Cec_ClassForEachObj( p, Cec_ObjRepr(p, i), Ent ) + Vec_IntPush( p->vClassTemp, Ent ); + Cec_ManCswClassRefineOne( p, Cec_ObjRepr(p, i), 0 ); + Vec_IntForEachEntry( p->vClassTemp, Ent, k ) + Cec_ManCswSimDeref( p, Ent ); + } } - Vec_IntFree( vClasses ); + if ( Vec_IntSize(p->vRefinedC) > 0 ) + Cec_ManCswProcessRefined( p, p->vRefinedC ); + assert( vInfoCis == NULL || iCiId == Gia_ManCiNum(p->pAig) ); + assert( vInfoCos == NULL || iCoId == Gia_ManCoNum(p->pAig) ); + assert( p->nMems == 1 ); + if ( p->pPars->fVeryVerbose ) + Cec_ManCswPrintClasses( p, 0 ); +/* + if ( p->nMems > 1 ) + { + for ( i = 1; i < p->nObjs; i++ ) + if ( p->pSims[i] ) + { + int x = 0; + } + } +*/ } /**Function************************************************************* @@ -544,24 +896,153 @@ void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined ) SeeAlso [] ***********************************************************************/ -Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters ) +int Cec_ManCswClassesPrepare( Cec_ManCsw_t * p ) { - Caig_Man_t * p; int i; - Aig_ManRandom( 1 ); - p = Caig_ManCreate( pAig ); - p->nWords = 1; - Caig_ManSimulateSimple( p ); - Caig_ManClassesCreate( p ); - p->nWords = nWords; - for ( i = 0; i < nIters; i++ ) + Gia_ManSetRefs( p->pAig ); + Cec_ManCswSimulateSimple( p ); + Cec_ManCswClassesCreate( p ); + for ( i = 0; i < p->pPars->nRounds; i++ ) + { + p->nWords = i + 1; + Cec_ManCswSimMemRelink( p ); + Cec_ManCswSimulateRound( p, NULL, NULL, 0, 0 ); + } + p->nWords = p->pPars->nWords; + Cec_ManCswSimMemRelink( p ); + for ( i = 0; i < p->pPars->nRounds; i++ ) + Cec_ManCswSimulateRound( p, NULL, NULL, 0, 0 ); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManCswClassesUpdate_rec( Gia_Obj_t * pObj ) +{ + int Result; + if ( pObj->fMark0 ) + return 1; + if ( Gia_ObjIsCi(pObj) || Gia_ObjIsConst0(pObj) ) + return 0; + Result = (Cec_ManCswClassesUpdate_rec( Gia_ObjFanin0(pObj) ) | + Cec_ManCswClassesUpdate_rec( Gia_ObjFanin1(pObj) )); + return pObj->fMark0 = Result; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManCswClassesUpdate( Cec_ManCsw_t * p, Cec_ManPat_t * pPat, Gia_Man_t * pNew ) +{ + Vec_Ptr_t * vInfo; + Gia_Obj_t * pObj, * pObjOld, * pReprOld; + int i, k, iRepr, iNode; + vInfo = Cec_ManPatCollectPatterns( pPat, Gia_ManCiNum(p->pAig), p->pPars->nWords ); + if ( vInfo != NULL ) { - Caig_ManSimulateRound( p, 0 ); -Caig_ManPrintClasses( p, 0 ); + for ( i = 0; i < pPat->nSeries; i++ ) + Cec_ManCswSimulateRound( p, vInfo, NULL, i, 0 ); + Vec_PtrFree( vInfo ); } - return p; + assert( Vec_IntSize(p->vXorNodes) == 2*Gia_ManCoNum(pNew) ); + // mark the transitive fanout of failed nodes + if ( p->pPars->nDepthMax != 1 ) + { + Gia_ManCleanMark0( p->pAig ); + Gia_ManCleanMark1( p->pAig ); + Gia_ManForEachCo( pNew, pObj, k ) + { + iRepr = Vec_IntEntry( p->vXorNodes, 2*k ); + iNode = Vec_IntEntry( p->vXorNodes, 2*k+1 ); + if ( pObj->fMark0 == 0 && pObj->fMark1 == 1 ) // proved + continue; +// Gia_ManObj(p->pAig, iRepr)->fMark0 = 1; + Gia_ManObj(p->pAig, iNode)->fMark0 = 1; + } + // mark the nodes reachable through the failed nodes + Gia_ManForEachAnd( p->pAig, pObjOld, k ) + pObjOld->fMark0 |= (Gia_ObjFanin0(pObjOld)->fMark0 | Gia_ObjFanin1(pObjOld)->fMark0); + // unmark the disproved nodes + Gia_ManForEachCo( pNew, pObj, k ) + { + iRepr = Vec_IntEntry( p->vXorNodes, 2*k ); + iNode = Vec_IntEntry( p->vXorNodes, 2*k+1 ); + if ( pObj->fMark0 == 0 && pObj->fMark1 == 1 ) // proved + continue; + pObjOld = Gia_ManObj(p->pAig, iNode); + assert( pObjOld->fMark0 == 1 ); + if ( Gia_ObjFanin0(pObjOld)->fMark0 == 0 && Gia_ObjFanin1(pObjOld)->fMark0 == 0 ) + pObjOld->fMark1 = 1; + } + // clean marks + Gia_ManForEachAnd( p->pAig, pObjOld, k ) + if ( pObjOld->fMark1 ) + { + pObjOld->fMark0 = 0; + pObjOld->fMark1 = 0; + } + } + // set the results + Gia_ManForEachCo( pNew, pObj, k ) + { + iRepr = Vec_IntEntry( p->vXorNodes, 2*k ); + iNode = Vec_IntEntry( p->vXorNodes, 2*k+1 ); + pReprOld = Gia_ManObj(p->pAig, iRepr); + pObjOld = Gia_ManObj(p->pAig, iNode); + if ( pObj->fMark1 ) + { // proved + assert( pObj->fMark0 == 0 ); + assert( !Cec_ObjProved(p, iNode) ); + if ( pReprOld->fMark0 == 0 && pObjOld->fMark0 == 0 ) +// if ( pObjOld->fMark0 == 0 ) + { + assert( iRepr == Cec_ObjRepr(p, iNode) ); + Cec_ObjSetProved( p, iNode ); + p->nAllProved++; + } + } + else if ( pObj->fMark0 ) + { // disproved + assert( pObj->fMark1 == 0 ); + if ( pReprOld->fMark0 == 0 && pObjOld->fMark0 == 0 ) +// if ( pObjOld->fMark0 == 0 ) + { + if ( iRepr == Cec_ObjRepr(p, iNode) ) + printf( "Cec_ManCswClassesUpdate(): Error! Node is not refined!\n" ); + p->nAllDisproved++; + } + } + else + { // failed + assert( pObj->fMark0 == 0 ); + assert( pObj->fMark1 == 0 ); + assert( !Cec_ObjFailed(p, iNode) ); + assert( !Cec_ObjProved(p, iNode) ); + Cec_ObjSetFailed( p, iNode ); + p->nAllFailed++; + } + } + return 0; } + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/cec/cecCnf.c b/src/aig/cec/cecCnf.c deleted file mode 100644 index 8b8c011d..00000000 --- a/src/aig/cec/cecCnf.c +++ /dev/null @@ -1,328 +0,0 @@ -/**CFile**************************************************************** - - FileName [cecCnf.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [Combinatinoal equivalence checking.] - - Synopsis [CNF computation.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: cecCnf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "cecInt.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Addes clauses to the solver.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_AddClausesMux( Cec_ManSat_t * p, Aig_Obj_t * pNode ) -{ - Aig_Obj_t * pNodeI, * pNodeT, * pNodeE; - int pLits[4], RetValue, VarF, VarI, VarT, VarE, fCompT, fCompE; - - assert( !Aig_IsComplement( pNode ) ); - assert( Aig_ObjIsMuxType( pNode ) ); - // get nodes (I = if, T = then, E = else) - pNodeI = Aig_ObjRecognizeMux( pNode, &pNodeT, &pNodeE ); - // get the variable numbers - VarF = Cec_ObjSatNum(p,pNode); - VarI = Cec_ObjSatNum(p,pNodeI); - VarT = Cec_ObjSatNum(p,Aig_Regular(pNodeT)); - VarE = Cec_ObjSatNum(p,Aig_Regular(pNodeE)); - // get the complementation flags - fCompT = Aig_IsComplement(pNodeT); - fCompE = Aig_IsComplement(pNodeE); - - // f = ITE(i, t, e) - - // i' + t' + f - // i' + t + f' - // i + e' + f - // i + e + f' - - // create four clauses - pLits[0] = toLitCond(VarI, 1); - pLits[1] = toLitCond(VarT, 1^fCompT); - pLits[2] = toLitCond(VarF, 0); - if ( p->pPars->fPolarFlip ) - { - if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); - if ( Aig_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] ); - if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); - assert( RetValue ); - pLits[0] = toLitCond(VarI, 1); - pLits[1] = toLitCond(VarT, 0^fCompT); - pLits[2] = toLitCond(VarF, 1); - if ( p->pPars->fPolarFlip ) - { - if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); - if ( Aig_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] ); - if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); - assert( RetValue ); - pLits[0] = toLitCond(VarI, 0); - pLits[1] = toLitCond(VarE, 1^fCompE); - pLits[2] = toLitCond(VarF, 0); - if ( p->pPars->fPolarFlip ) - { - if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); - if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); - if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); - assert( RetValue ); - pLits[0] = toLitCond(VarI, 0); - pLits[1] = toLitCond(VarE, 0^fCompE); - pLits[2] = toLitCond(VarF, 1); - if ( p->pPars->fPolarFlip ) - { - if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); - if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); - if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); - assert( RetValue ); - - // two additional clauses - // t' & e' -> f' - // t & e -> f - - // t + e + f' - // t' + e' + f - - if ( VarT == VarE ) - { -// assert( fCompT == !fCompE ); - return; - } - - pLits[0] = toLitCond(VarT, 0^fCompT); - pLits[1] = toLitCond(VarE, 0^fCompE); - pLits[2] = toLitCond(VarF, 1); - if ( p->pPars->fPolarFlip ) - { - if ( Aig_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] ); - if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); - if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); - assert( RetValue ); - pLits[0] = toLitCond(VarT, 1^fCompT); - pLits[1] = toLitCond(VarE, 1^fCompE); - pLits[2] = toLitCond(VarF, 0); - if ( p->pPars->fPolarFlip ) - { - if ( Aig_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] ); - if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); - if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); - assert( RetValue ); -} - -/**Function************************************************************* - - Synopsis [Addes clauses to the solver.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_AddClausesSuper( Cec_ManSat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) -{ - Aig_Obj_t * pFanin; - int * pLits, nLits, RetValue, i; - assert( !Aig_IsComplement(pNode) ); - assert( Aig_ObjIsNode( pNode ) ); - // create storage for literals - nLits = Vec_PtrSize(vSuper) + 1; - pLits = ALLOC( int, nLits ); - // suppose AND-gate is A & B = C - // add !A => !C or A + !C - Vec_PtrForEachEntry( vSuper, pFanin, i ) - { - pLits[0] = toLitCond(Cec_ObjSatNum(p,Aig_Regular(pFanin)), Aig_IsComplement(pFanin)); - pLits[1] = toLitCond(Cec_ObjSatNum(p,pNode), 1); - if ( p->pPars->fPolarFlip ) - { - if ( Aig_Regular(pFanin)->fPhase ) pLits[0] = lit_neg( pLits[0] ); - if ( pNode->fPhase ) pLits[1] = lit_neg( pLits[1] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 ); - assert( RetValue ); - } - // add A & B => C or !A + !B + C - Vec_PtrForEachEntry( vSuper, pFanin, i ) - { - pLits[i] = toLitCond(Cec_ObjSatNum(p,Aig_Regular(pFanin)), !Aig_IsComplement(pFanin)); - if ( p->pPars->fPolarFlip ) - { - if ( Aig_Regular(pFanin)->fPhase ) pLits[i] = lit_neg( pLits[i] ); - } - } - pLits[nLits-1] = toLitCond(Cec_ObjSatNum(p,pNode), 0); - if ( p->pPars->fPolarFlip ) - { - if ( pNode->fPhase ) pLits[nLits-1] = lit_neg( pLits[nLits-1] ); - } - RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits ); - assert( RetValue ); - free( pLits ); -} - -/**Function************************************************************* - - Synopsis [Collects the supergate.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_CollectSuper_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper, int fFirst, int fUseMuxes ) -{ - // if the new node is complemented or a PI, another gate begins - if ( Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) || - (!fFirst && Aig_ObjRefs(pObj) > 1) || - (fUseMuxes && Aig_ObjIsMuxType(pObj)) ) - { - Vec_PtrPushUnique( vSuper, pObj ); - return; - } - // go through the branches - Cec_CollectSuper_rec( Aig_ObjChild0(pObj), vSuper, 0, fUseMuxes ); - Cec_CollectSuper_rec( Aig_ObjChild1(pObj), vSuper, 0, fUseMuxes ); -} - -/**Function************************************************************* - - Synopsis [Collects the supergate.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_CollectSuper( Aig_Obj_t * pObj, int fUseMuxes, Vec_Ptr_t * vSuper ) -{ - assert( !Aig_IsComplement(pObj) ); - assert( !Aig_ObjIsPi(pObj) ); - Vec_PtrClear( vSuper ); - Cec_CollectSuper_rec( pObj, vSuper, 1, fUseMuxes ); -} - -/**Function************************************************************* - - Synopsis [Updates the solver clause database.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_ObjAddToFrontier( Cec_ManSat_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vFrontier ) -{ - assert( !Aig_IsComplement(pObj) ); - if ( Cec_ObjSatNum(p,pObj) ) - return; - assert( Cec_ObjSatNum(p,pObj) == 0 ); - if ( Aig_ObjIsConst1(pObj) ) - return; - Vec_PtrPush( p->vUsedNodes, pObj ); - Cec_ObjSetSatNum( p, pObj, p->nSatVars++ ); - if ( Aig_ObjIsNode(pObj) ) - Vec_PtrPush( vFrontier, pObj ); -} - -/**Function************************************************************* - - Synopsis [Updates the solver clause database.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Aig_Obj_t * pObj ) -{ - Vec_Ptr_t * vFrontier; - Aig_Obj_t * pNode, * pFanin; - int i, k, fUseMuxes = 1; - // quit if CNF is ready - if ( Cec_ObjSatNum(p,pObj) ) - return; - // start the frontier - vFrontier = Vec_PtrAlloc( 100 ); - Cec_ObjAddToFrontier( p, pObj, vFrontier ); - // explore nodes in the frontier - Vec_PtrForEachEntry( vFrontier, pNode, i ) - { - // create the supergate - assert( Cec_ObjSatNum(p,pNode) ); - if ( fUseMuxes && Aig_ObjIsMuxType(pNode) ) - { - Vec_PtrClear( p->vFanins ); - Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin0( Aig_ObjFanin0(pNode) ) ); - 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 ) - Cec_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier ); - Cec_AddClausesMux( p, pNode ); - } - else - { - Cec_CollectSuper( pNode, fUseMuxes, p->vFanins ); - Vec_PtrForEachEntry( p->vFanins, pFanin, k ) - Cec_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier ); - Cec_AddClausesSuper( p, pNode, p->vFanins ); - } - assert( Vec_PtrSize(p->vFanins) > 1 ); - } - Vec_PtrFree( vFrontier ); -} - - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/aig/cec/cecCore.c b/src/aig/cec/cecCore.c index 86287a96..ab8fd5cf 100644 --- a/src/aig/cec/cecCore.c +++ b/src/aig/cec/cecCore.c @@ -37,20 +37,20 @@ SideEffects [] SeeAlso [] - + ***********************************************************************/ void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p ) { memset( p, 0, sizeof(Cec_ParSat_t) ); - p->nBTLimit = 100; // conflict limit at a node - p->nSatVarMax = 2000; // the max number of SAT variables - p->nCallsRecycle = 10; // calls to perform before recycling SAT solver - p->fFirstStop = 0; // stop on the first sat output - p->fPolarFlip = 0; // uses polarity adjustment - p->fVerbose = 0; // verbose stats -} - -/**Function************************************************************* + p->nBTLimit = 10; // conflict limit at a node + p->nSatVarMax = 2000; // the max number of SAT variables + p->nCallsRecycle = 100; // calls to perform before recycling SAT solver + p->fPolarFlip = 1; // flops polarity of variables + p->fFirstStop = 0; // stop on the first sat output + p->fVerbose = 1; // verbose stats +} + +/**Function************ ************************************************* Synopsis [This procedure sets default parameters.] @@ -64,12 +64,19 @@ void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p ) void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p ) { memset( p, 0, sizeof(Cec_ParCsw_t) ); - p->nWords = 15; // the number of simulation words - p->nRounds = 10; // the number of simulation rounds - p->nBTlimit = 10; // conflict limit at a node - p->fRewriting = 0; // enables AIG rewriting - p->fVerbose = 1; // verbose stats -} + p->nWords = 20; // the number of simulation words + p->nRounds = 20; // the number of simulation rounds + p->nItersMax = 20; // the maximum number of iterations of SAT sweeping + p->nBTLimit = 10000; // conflict limit at a node + p->nSatVarMax = 2000; // the max number of SAT variables + p->nCallsRecycle = 100; // calls to perform before recycling SAT solver + p->nLevelMax = 0; // restriction on the level of nodes to be swept + p->nDepthMax = 1; // the depth in terms of steps of speculative reduction + p->fRewriting = 0; // enables AIG rewriting + p->fFirstStop = 0; // stop on the first sat output + p->fVeryVerbose = 0; // verbose stats + p->fVerbose = 0; // verbose stats +} /**Function************************************************************* @@ -85,20 +92,19 @@ void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p ) void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p ) { memset( p, 0, sizeof(Cec_ParCec_t) ); - p->nIters = 5; // iterations of SAT solving/sweeping - p->nBTLimitBeg = 2; // starting backtrack limit - p->nBTlimitMulti = 8; // multiple of backtrack limiter - p->fUseSmartCnf = 0; // use smart CNF computation - p->fRewriting = 0; // enables AIG rewriting - p->fSatSweeping = 0; // enables SAT sweeping - p->fFirstStop = 0; // stop on the first sat output - p->fVerbose = 1; // verbose stats -} - + p->nIters = 1; // iterations of SAT solving/sweeping + p->nBTLimitBeg = 2; // starting backtrack limit + p->nBTlimitMulti = 8; // multiple of backtrack limiter + p->fUseSmartCnf = 0; // use smart CNF computation + p->fRewriting = 0; // enables AIG rewriting + p->fSatSweeping = 0; // enables SAT sweeping + p->fFirstStop = 0; // stop on the first sat output + p->fVerbose = 1; // verbose stats +} /**Function************************************************************* - Synopsis [Performs equivalence checking.] + Synopsis [Core procedure for SAT sweeping.] Description [] @@ -107,39 +113,21 @@ void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p ) SeeAlso [] ***********************************************************************/ -int Cec_Sweep( Aig_Man_t * pAig, int nBTLimit ) +Gia_Man_t * Cec_ManSatSolving( Gia_Man_t * pAig, Cec_ParSat_t * pPars ) { - Cec_MtrStatus_t Status; - Cec_ParCsw_t ParsCsw, * pParsCsw = &ParsCsw; - Cec_ParSat_t ParsSat, * pParsSat = &ParsSat; - Caig_Man_t * pCaig; - Aig_Man_t * pSRAig; - int clk; - - Cec_ManCswSetDefaultParams( pParsCsw ); - pParsCsw->nBTlimit = nBTLimit; - pCaig = Caig_ManClassesPrepare( pAig, pParsCsw->nWords, pParsCsw->nRounds ); - - pSRAig = Caig_ManSpecReduce( pCaig ); - Aig_ManPrintStats( pSRAig ); - - Cec_ManSatSetDefaultParams( pParsSat ); - pParsSat->fFirstStop = 0; - pParsSat->nBTLimit = pParsCsw->nBTlimit; -clk = clock(); - Status = Cec_SatSolveOutputs( pSRAig, pParsSat ); - Cec_MiterStatusPrint( Status, "SRM ", clock() - clk ); - - Aig_ManStop( pSRAig ); - - Caig_ManDelete( pCaig ); - - return 1; + Gia_Man_t * pNew; + Cec_ManPat_t * pPat; + pPat = Cec_ManPatStart(); + Cec_ManSatSolve( pPat, pAig, pPars ); + pNew = Gia_ManDupDfsSkip( pAig ); + Cec_ManPatStop( pPat ); + return pNew; } + /**Function************************************************************* - Synopsis [Performs equivalence checking.] + Synopsis [Core procedure for SAT sweeping.] Description [] @@ -148,82 +136,94 @@ clk = clock(); SeeAlso [] ***********************************************************************/ -int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * pPars ) +Gia_Man_t * Cec_ManSatSweeping( Gia_Man_t * pAig, Cec_ParCsw_t * pPars ) { Cec_ParSat_t ParsSat, * pParsSat = &ParsSat; - Cec_MtrStatus_t Status; - Aig_Man_t * pMiter; - int i, clk = clock(); - if ( pPars->fVerbose ) - { - Status = Cec_MiterStatusTrivial( pAig0 ); - Status.nNodes += pAig1? Aig_ManNodeNum( pAig1 ) : 0; - Cec_MiterStatusPrint( Status, "Init ", 0 ); - } - // create combinational miter - if ( pAig1 == NULL ) + Gia_Man_t * pNew; + Cec_ManCsw_t * p; + Cec_ManPat_t * pPat; + int i, RetValue, clk, clk2, clkTotal = clock(); + Aig_ManRandom( 1 ); + Gia_ManSetPhase( pAig ); + Gia_ManCleanMark0( pAig ); + Gia_ManCleanMark1( pAig ); + p = Cec_ManCswStart( pAig, pPars ); +clk = clock(); + RetValue = Cec_ManCswClassesPrepare( p ); +p->timeSim += clock() - clk; + Cec_ManSatSetDefaultParams( pParsSat ); + pParsSat->nBTLimit = pPars->nBTLimit; + pParsSat->fVerbose = pPars->fVeryVerbose; + pPat = Cec_ManPatStart(); + pPat->fVerbose = pPars->fVeryVerbose; + for ( i = 1; i <= pPars->nItersMax; i++ ) { - Status = Cec_MiterStatus( pAig0 ); - if ( Status.nSat > 0 && pPars->fFirstStop ) + clk2 = clock(); + pNew = Cec_ManCswSpecReduction( p ); + if ( pPars->fVeryVerbose ) { - if ( pPars->fVerbose ) - printf( "Output %d is trivially SAT.\n", Status.iOut ); - return 0; + Gia_ManPrintStats( p->pAig ); + Gia_ManPrintStats( pNew ); } - if ( Status.nUndec == 0 ) + if ( Gia_ManCoNum(pNew) == 0 ) { - if ( pPars->fVerbose ) - printf( "The miter has no undecided outputs.\n" ); - return 1; + Gia_ManStop( pNew ); + break; } - pMiter = Cec_Duplicate( pAig0 ); - } - else - { - pMiter = Cec_DeriveMiter( pAig0, pAig1 ); - Status = Cec_MiterStatus( pMiter ); - if ( Status.nSat > 0 && pPars->fFirstStop ) +clk = clock(); + Cec_ManSatSolve( pPat, pNew, pParsSat ); +p->timeSat += clock() - clk; +clk = clock(); + Cec_ManCswClassesUpdate( p, pPat, pNew ); +p->timeSim += clock() - clk; + Gia_ManStop( pNew ); + pNew = Cec_ManCswDupWithClasses( p ); + Gia_WriteAiger( pNew, "gia_temp_new.aig", 0, 1 ); + if ( p->pPars->fVerbose ) { - if ( pPars->fVerbose ) - printf( "Output %d is trivially SAT.\n", Status.iOut ); - Aig_ManStop( pMiter ); - return 0; + printf( "%3d : P =%7d. D =%7d. F =%6d. Lit =%8d. And =%8d. ", + i, p->nAllProved, p->nAllDisproved, p->nAllFailed, + Cec_ManCswCountLitsAll(p), Gia_ManAndNum(pNew) ); + ABC_PRT( "Time", clock() - clk2 ); } - if ( Status.nUndec == 0 ) + if ( p->pPars->fVeryVerbose ) { - if ( pPars->fVerbose ) - printf( "The problem is solved by structrual hashing.\n" ); - Aig_ManStop( pMiter ); - return 1; + ABC_PRTP( "Sim ", p->timeSim, clock() - clkTotal ); + ABC_PRTP( "Sat ", p->timeSat, clock() - clkTotal ); + ABC_PRT( "Time", clock() - clkTotal ); + printf( "****** Intermedate result %3d ******\n", i ); + Gia_ManPrintStats( p->pAig ); + Gia_ManPrintStats( pNew ); + printf("The result is written into file \"%s\".\n", "gia_temp.aig" ); + printf( "************************************\n" ); } - } - if ( pPars->fVerbose ) - Cec_MiterStatusPrint( Status, "Strash", clock() - clk ); - // start parameter structures - Cec_ManSatSetDefaultParams( pParsSat ); - pParsSat->fFirstStop = pPars->fFirstStop; - pParsSat->nBTLimit = pPars->nBTLimitBeg; - for ( i = 0; i < pPars->nIters; i++ ) - { - // try SAT solving - clk = clock(); - pParsSat->nBTLimit *= pPars->nBTlimitMulti; - Status = Cec_SatSolveOutputs( pMiter, pParsSat ); - if ( pPars->fVerbose ) - Cec_MiterStatusPrint( Status, "SAT ", clock() - clk ); - if ( Status.nSat && pParsSat->fFirstStop ) - break; - if ( Status.nUndec == 0 ) + if ( Gia_ManAndNum(pNew) == 0 ) + { + Gia_ManStop( pNew ); break; + } + Gia_ManStop( pNew ); + } + Gia_ManCleanMark0( pAig ); + Gia_ManCleanMark1( pAig ); - // try rewriting - - // try SAT sweeping - Cec_Sweep( pMiter, 10 ); - i = i; + // verify the result + if ( p->pPars->fVerbose ) + { + printf( "Verifying the result:\n" ); + pNew = Cec_ManCswSpecReductionProved( p ); + pParsSat->nBTLimit = 1000000; + pParsSat->fVerbose = 1; + Cec_ManSatSolve( NULL, pNew, pParsSat ); + Gia_ManStop( pNew ); } - Aig_ManStop( pMiter ); - return 1; + + // create the resulting miter + pAig->pReprs = Cec_ManCswDeriveReprs( p ); + pNew = Gia_ManDupDfsClasses( pAig ); + Cec_ManCswStop( p ); + Cec_ManPatStop( pPat ); + return pNew; } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/cec/cecInt.h b/src/aig/cec/cecInt.h index 93221f83..309f4292 100644 --- a/src/aig/cec/cecInt.h +++ b/src/aig/cec/cecInt.h @@ -21,34 +21,60 @@ #ifndef __CEC_INT_H__ #define __CEC_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// -#include "aig.h" #include "satSolver.h" #include "bar.h" +#include "gia.h" #include "cec.h" //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// +// simulation pattern manager +typedef struct Cec_ManPat_t_ Cec_ManPat_t; +struct Cec_ManPat_t_ +{ + Vec_Int_t * vPattern1; // pattern in terms of primary inputs + Vec_Int_t * vPattern2; // pattern in terms of primary inputs + Vec_Str_t * vStorage; // storage for compressed patterns + int iStart; // position in the array where recent patterns begin + int nPats; // total number of recent patterns + int nPatsAll; // total number of all patterns + int nPatLits; // total number of literals in recent patterns + int nPatLitsAll; // total number of literals in all patterns + int nPatLitsMin; // total number of literals in minimized recent patterns + int nPatLitsMinAll; // total number of literals in minimized all patterns + int nSeries; // simulation series + int fVerbose; // verbose stats + // runtime statistics + int timeFind; // detecting the pattern + int timeShrink; // minimizing the pattern + int timeVerify; // verifying the result of minimisation + int timeSort; // sorting literals + int timePack; // packing into sim info structures + int timeTotal; // total runtime +}; + +// SAT solving manager typedef struct Cec_ManSat_t_ Cec_ManSat_t; struct Cec_ManSat_t_ { // parameters Cec_ParSat_t * pPars; // AIGs used in the package - Aig_Man_t * pAig; // the AIG whose outputs are considered + Gia_Man_t * pAig; // the AIG whose outputs are considered Vec_Int_t * vStatus; // status for each output // SAT solving sat_solver * pSat; // recyclable SAT solver @@ -62,6 +88,11 @@ struct Cec_ManSat_t_ 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; + int nConfSat; + int nConfUndec; // runtime stats int timeSatUnsat; // unsat int timeSatSat; // sat @@ -69,144 +100,82 @@ struct Cec_ManSat_t_ int timeTotal; // total runtime }; -typedef struct Cec_ManCla_t_ Cec_ManCla_t; - -typedef struct Cec_ManCsw_t_ Cec_ManCsw_t; -struct Cec_ManCsw_t_ +// combinational sweeping object +typedef struct Cec_ObjCsw_t_ Cec_ObjCsw_t; +struct Cec_ObjCsw_t_ { - // parameters - Cec_ParCsw_t * pPars; - // AIGs used in the package - Aig_Man_t * pAig; // the AIG for SAT sweeping - Aig_Man_t * pFraig; // the AIG after SAT sweeping - // equivalence classes - Cec_ManCla_t * ppClasses; // equivalence classes of nodes - // choice node statistics - int nLits; // the number of lits in the cand equiv classes - int nReprs; // the number of proved equivalent pairs - int nEquivs; // the number of final equivalences - int nChoices; // the number of final choice nodes -}; - -typedef struct Cec_ManCec_t_ Cec_ManCec_t; -struct Cec_ManCec_t_ -{ - // parameters - Cec_ParCec_t * pPars; - // AIGs used in the package - Aig_Man_t * pAig; // the miter for equivalence checking - // mapping of PI/PO nodes - - // counter-example - int * pCex; // counter-example - int iOutput; // the output for this counter-example - - // statistics - -}; - -typedef struct Cec_MtrStatus_t_ Cec_MtrStatus_t; -struct Cec_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 iRepr; // representative node + unsigned iNext : 30; // next node in the class + unsigned iProved : 1; // this node is proved + unsigned iFailed : 1; // this node is failed + unsigned SimNum; // simulation info number }; // combinational simulation manager -typedef struct Caig_Man_t_ Caig_Man_t; -struct Caig_Man_t_ +typedef struct Cec_ManCsw_t_ Cec_ManCsw_t; +struct Cec_ManCsw_t_ { // parameters - Aig_Man_t * pAig; // the AIG to be used for simulation - int nWords; // the number of words to simulate - // AIG representation - int nPis; // the number of primary inputs - int nPos; // the number of primary outputs - int nNodes; // the number of internal nodes - int nObjs; // nPis + nNodes + nPos + 1 - int * pFans0; // fanin0 for all objects - int * pFans1; // fanin1 for all objects - // simulation info - unsigned short* pRefs; // reference counter for each node - unsigned * pSims; // simlulation information for each node + Gia_Man_t * pAig; // the AIG to be used for simulation + Cec_ParCsw_t * pPars; // SAT sweeping parameters + int nWords; // the number of simulation words + // equivalence classes + Cec_ObjCsw_t * pObjs; // objects used for SAT sweeping // recycable memory - unsigned * pMems; // allocated simulaton memory - 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 free entry - // equivalence class representation - int * pReprs; // representatives of each node - int * pNexts; // nexts for each node + unsigned * pMems; // allocated simulaton memory + 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 free entry // temporaries - Vec_Ptr_t * vSims; // pointers to sim info - Vec_Int_t * vClassOld; // old class numbers - Vec_Int_t * vClassNew; // new class numbers + 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 + // simulation patterns + Vec_Int_t * vXorNodes; // nodes used in speculative reduction + int nAllProved; // total number of proved nodes + int nAllDisproved; // total number of disproved nodes + int nAllFailed; // total number of failed nodes + // runtime stats + int timeSim; // unsat + int timeSat; // sat + int timeTotal; // total runtime }; //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -static inline int Cec_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; } -static inline int Cec_Lit2Var( int Lit ) { return Lit >> 1; } -static inline int Cec_LitIsCompl( int Lit ) { return Lit & 1; } -static inline int Cec_LitNot( int Lit ) { return Lit ^ 1; } -static inline int Cec_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); } -static inline int Cec_LitRegular( int Lit ) { return Lit & ~01; } - -static inline int Cec_ObjSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj ) { return p->pSatVars[pObj->Id]; } -static inline void Cec_ObjSetSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj, int Num ) { p->pSatVars[pObj->Id] = Num; } - -static inline Aig_Obj_t * Cec_ObjFraig( Aig_Obj_t * pObj ) { return pObj->pData; } -static inline void Cec_ObjSetFraig( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { pObj->pData = pNode; } - -static inline int Cec_ObjIsConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj ) -{ - return Aig_ObjRepr(pAig, pObj) == Aig_ManConst1(pAig); -} -static inline void Cec_ObjSetConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj ) -{ - assert( !Cec_ObjIsConst1Cand( pAig, pObj ) ); - Aig_ObjSetRepr( pAig, pObj, Aig_ManConst1(pAig) ); -} - //////////////////////////////////////////////////////////////////////// /// FUNCTION DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -/*=== cecAig.c ==========================================================*/ -extern Aig_Man_t * Cec_Duplicate( Aig_Man_t * p ); -extern Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 ); -/*=== cecClass.c ==========================================================*/ -extern Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p ); -extern int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords ); -extern int Caig_ManCompareConst( unsigned * p, int nWords ); -extern void Caig_ManProcessClass( Caig_Man_t * p, int i ); -extern void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined ); -extern Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters ); -/*=== cecCnf.c ==========================================================*/ -extern void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Aig_Obj_t * pObj ); -/*=== cecSat.c ==========================================================*/ -extern Cec_MtrStatus_t Cec_SatSolveOutputs( Aig_Man_t * pAig, Cec_ParSat_t * pPars ); -/*=== cecSim.c ==========================================================*/ -extern Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig ); -extern void Caig_ManDelete( Caig_Man_t * p ); -extern unsigned * Caig_ManSimRead( Caig_Man_t * p, int i ); -extern unsigned * Caig_ManSimRef( Caig_Man_t * p, int i ); -extern unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i ); -extern int Caig_ManSimulateRound( Caig_Man_t * p, int fMiter ); -extern int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose ); -/*=== cecStatus.c ==========================================================*/ -extern int Cec_OutputStatus( Aig_Man_t * p, Aig_Obj_t * pObj ); -extern Cec_MtrStatus_t Cec_MiterStatus( Aig_Man_t * p ); -extern Cec_MtrStatus_t Cec_MiterStatusTrivial( Aig_Man_t * p ); -extern void Cec_MiterStatusPrint( Cec_MtrStatus_t S, char * pString, int Time ); +/*=== cecCore.c ============================================================*/ +/*=== cecClass.c ============================================================*/ +extern int Cec_ManCswCountLitsAll( Cec_ManCsw_t * p ); +extern int * Cec_ManCswDeriveReprs( Cec_ManCsw_t * p ); +extern Gia_Man_t * Cec_ManCswSpecReduction( Cec_ManCsw_t * p ); +extern Gia_Man_t * Cec_ManCswSpecReductionProved( Cec_ManCsw_t * p ); +extern Gia_Man_t * Cec_ManCswDupWithClasses( Cec_ManCsw_t * p ); +extern int Cec_ManCswClassesPrepare( Cec_ManCsw_t * p ); +extern int Cec_ManCswClassesUpdate( Cec_ManCsw_t * p, Cec_ManPat_t * pPat, Gia_Man_t * pNew ); +/*=== cecMan.c ============================================================*/ +extern Cec_ManCsw_t * Cec_ManCswStart( Gia_Man_t * pAig, Cec_ParCsw_t * pPars ); +extern void Cec_ManCswStop( Cec_ManCsw_t * p ); +extern Cec_ManPat_t * Cec_ManPatStart(); +extern void Cec_ManPatPrintStats( Cec_ManPat_t * p ); +extern void Cec_ManPatStop( Cec_ManPat_t * p ); +extern Cec_ManSat_t * Cec_ManSatCreate( Gia_Man_t * pAig, Cec_ParSat_t * pPars ); +extern void Cec_ManSatPrintStats( Cec_ManSat_t * p ); +extern void Cec_ManSatStop( Cec_ManSat_t * p ); +/*=== cecPat.c ============================================================*/ +extern void Cec_ManPatSavePattern( Cec_ManPat_t * pPat, Cec_ManSat_t * p, Gia_Obj_t * pObj ); +extern Vec_Ptr_t * Cec_ManPatCollectPatterns( Cec_ManPat_t * pMan, int nInputs, int nWords ); +/*=== cecSolve.c ============================================================*/ +extern int Cec_ObjSatVarValue( Cec_ManSat_t * p, Gia_Obj_t * pObj ); +extern void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPars ); +/*=== cecUtil.c ============================================================*/ #ifdef __cplusplus } diff --git a/src/aig/cec/cecMan.c b/src/aig/cec/cecMan.c index 86415c53..b8ee75b2 100644 --- a/src/aig/cec/cecMan.c +++ b/src/aig/cec/cecMan.c @@ -30,7 +30,7 @@ /**Function************************************************************* - Synopsis [] + Synopsis [Creates AIG.] Description [] @@ -39,10 +39,26 @@ SeeAlso [] ***********************************************************************/ +Cec_ManCsw_t * Cec_ManCswStart( Gia_Man_t * pAig, Cec_ParCsw_t * pPars ) +{ + Cec_ManCsw_t * p; + p = ABC_ALLOC( Cec_ManCsw_t, 1 ); + memset( p, 0, sizeof(Cec_ManCsw_t) ); + p->pAig = pAig; + p->pPars = pPars; + p->pObjs = ABC_CALLOC( Cec_ObjCsw_t, Gia_ManObjNum(pAig) ); + // temporaries + p->vClassOld = Vec_IntAlloc( 1000 ); + p->vClassNew = Vec_IntAlloc( 1000 ); + p->vClassTemp = Vec_IntAlloc( 1000 ); + p->vRefinedC = Vec_IntAlloc( 10000 ); + p->vXorNodes = Vec_IntAlloc( 1000 ); + return p; +} /**Function************************************************************* - Synopsis [] + Synopsis [Deletes AIG.] Description [] @@ -51,6 +67,161 @@ SeeAlso [] ***********************************************************************/ +void Cec_ManCswStop( Cec_ManCsw_t * p ) +{ + Vec_IntFree( p->vXorNodes ); + Vec_IntFree( p->vClassOld ); + Vec_IntFree( p->vClassNew ); + Vec_IntFree( p->vClassTemp ); + Vec_IntFree( p->vRefinedC ); + ABC_FREE( p->pMems ); + ABC_FREE( p->pObjs ); + ABC_FREE( p ); +} + + +/**Function************************************************************* + + Synopsis [Creates AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cec_ManPat_t * Cec_ManPatStart() +{ + Cec_ManPat_t * p; + p = ABC_CALLOC( Cec_ManPat_t, 1 ); + p->vStorage = Vec_StrAlloc( 1<<20 ); + p->vPattern1 = Vec_IntAlloc( 1000 ); + p->vPattern2 = Vec_IntAlloc( 1000 ); + return p; +} + +/**Function************************************************************* + + Synopsis [Creates AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatPrintStats( Cec_ManPat_t * p ) +{ + printf( "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", + 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 ); +} + +/**Function************************************************************* + + Synopsis [Deletes AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatStop( Cec_ManPat_t * p ) +{ + Vec_StrFree( p->vStorage ); + Vec_IntFree( p->vPattern1 ); + Vec_IntFree( p->vPattern2 ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [Creates the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cec_ManSat_t * Cec_ManSatCreate( Gia_Man_t * pAig, Cec_ParSat_t * pPars ) +{ + Cec_ManSat_t * p; + // create interpolation manager + p = ABC_ALLOC( Cec_ManSat_t, 1 ); + memset( p, 0, sizeof(Cec_ManSat_t) ); + p->pPars = pPars; + p->pAig = pAig; + // SAT solving + p->nSatVars = 1; + p->pSatVars = ABC_CALLOC( int, Gia_ManObjNum(pAig) ); + p->vUsedNodes = Vec_PtrAlloc( 1000 ); + p->vFanins = Vec_PtrAlloc( 100 ); + return p; +} + +/**Function************************************************************* + + Synopsis [Prints statistics of the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatPrintStats( Cec_ManSat_t * p ) +{ + printf( "CO = %6d ", Gia_ManCoNum(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 ", + p->nSatUnsat, 100.0*p->nSatUnsat/p->nSatTotal, 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, 100.0*p->nSatSat/p->nSatTotal, 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, 100.0*p->nSatUndec/p->nSatTotal, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 ); + ABC_PRTP( "Time", p->timeSatUndec, p->timeTotal ); +} + +/**Function************************************************************* + + Synopsis [Frees the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatStop( Cec_ManSat_t * p ) +{ + if ( p->pSat ) + sat_solver_delete( p->pSat ); + Vec_PtrFree( p->vUsedNodes ); + Vec_PtrFree( p->vFanins ); + ABC_FREE( p->pSatVars ); + ABC_FREE( p ); +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// diff --git a/src/aig/cec/cecPat.c b/src/aig/cec/cecPat.c new file mode 100644 index 00000000..1af4f333 --- /dev/null +++ b/src/aig/cec/cecPat.c @@ -0,0 +1,493 @@ +/**CFile**************************************************************** + + FileName [cec.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cec.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Cec_ManPatStoreNum( Cec_ManPat_t * p, int Num ) +{ + unsigned x = (unsigned)Num; + assert( Num >= 0 ); + while ( x & ~0x7f ) + { + Vec_StrPush( p->vStorage, (char)((x & 0x7f) | 0x80) ); + x >>= 7; + } + Vec_StrPush( p->vStorage, (char)x ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Cec_ManPatRestoreNum( Cec_ManPat_t * p ) +{ + int ch, i, x = 0; + for ( i = 0; (ch = Vec_StrEntry(p->vStorage, p->iStart++)) & 0x80; i++ ) + x |= (ch & 0x7f) << (7 * i); + return x | (ch << (7 * i)); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Cec_ManPatStore( Cec_ManPat_t * p, Vec_Int_t * vPat ) +{ + int i, Number, NumberPrev; + assert( Vec_IntSize(vPat) > 0 ); + Cec_ManPatStoreNum( p, Vec_IntSize(vPat) ); + NumberPrev = Vec_IntEntry( vPat, 0 ); + Cec_ManPatStoreNum( p, NumberPrev ); + Vec_IntForEachEntryStart( vPat, Number, i, 1 ) + { + assert( NumberPrev < Number ); + Cec_ManPatStoreNum( p, Number - NumberPrev ); + NumberPrev = Number; + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Cec_ManPatRestore( Cec_ManPat_t * p, Vec_Int_t * vPat ) +{ + int i, Size, Number; + Vec_IntClear( vPat ); + Size = Cec_ManPatRestoreNum( p ); + Number = Cec_ManPatRestoreNum( p ); + Vec_IntPush( vPat, Number ); + for ( i = 1; i < Size; i++ ) + { + Number += Cec_ManPatRestoreNum( p ); + Vec_IntPush( vPat, Number ); + } + assert( Vec_IntSize(vPat) == Size ); +} + + +/**Function************************************************************* + + Synopsis [Derives satisfying assignment.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManPatComputePattern_rec( Cec_ManSat_t * pSat, Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + int Counter = 0; + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return 0; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + { + pObj->fMark1 = Cec_ObjSatVarValue( pSat, pObj ); + return 1; + } + assert( Gia_ObjIsAnd(pObj) ); + Counter += Cec_ManPatComputePattern_rec( pSat, p, Gia_ObjFanin0(pObj) ); + Counter += Cec_ManPatComputePattern_rec( pSat, p, Gia_ObjFanin1(pObj) ); + pObj->fMark1 = (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) & + (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj)); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Derives satisfying assignment.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatComputePattern1_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + { + Vec_IntPush( vPat, Gia_Var2Lit( Gia_ObjCioId(pObj), pObj->fMark1==0 ) ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + if ( pObj->fMark1 == 1 ) + { + Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin0(pObj), vPat ); + Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin1(pObj), vPat ); + } + else + { + assert( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 0 || + (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj)) == 0 ); + if ( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 0 ) + Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin0(pObj), vPat ); + else + Cec_ManPatComputePattern1_rec( p, Gia_ObjFanin1(pObj), vPat ); + } +} + +/**Function************************************************************* + + Synopsis [Derives satisfying assignment.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatComputePattern2_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + { + Vec_IntPush( vPat, Gia_Var2Lit( Gia_ObjCioId(pObj), pObj->fMark1==0 ) ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + if ( pObj->fMark1 == 1 ) + { + Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin0(pObj), vPat ); + Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin1(pObj), vPat ); + } + else + { + assert( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 0 || + (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj)) == 0 ); + if ( (Gia_ObjFanin1(pObj)->fMark1 ^ Gia_ObjFaninC1(pObj)) == 0 ) + Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin1(pObj), vPat ); + else + Cec_ManPatComputePattern2_rec( p, Gia_ObjFanin0(pObj), vPat ); + } +} + +/**Function************************************************************* + + Synopsis [Derives satisfying assignment.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManPatComputePattern3_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + int Value0, Value1, Value; + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return (pObj->fMark1 << 1) | pObj->fMark0; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + { + pObj->fMark0 = 1; + pObj->fMark1 = 1; + return GIA_UND; + } + assert( Gia_ObjIsAnd(pObj) ); + Value0 = Cec_ManPatComputePattern3_rec( p, Gia_ObjFanin0(pObj) ); + Value1 = Cec_ManPatComputePattern3_rec( p, Gia_ObjFanin1(pObj) ); + Value = Gia_XsimAndCond( Value0, Gia_ObjFaninC0(pObj), Value1, Gia_ObjFaninC1(pObj) ); + pObj->fMark0 = (Value & 1); + pObj->fMark1 = ((Value >> 1) & 1); + return Value; +} + +/**Function************************************************************* + + Synopsis [Derives satisfying assignment.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat ) +{ + Gia_Obj_t * pTemp; + int i, Value; + Gia_ManIncrementTravId( p ); + Vec_IntForEachEntry( vPat, Value, i ) + { + pTemp = Gia_ManCi( p, Gia_Lit2Var(Value) ); +// assert( Gia_LitIsCompl(Value) != (int)pTemp->fMark1 ); + if ( pTemp->fMark1 ) + { + pTemp->fMark0 = 0; + pTemp->fMark1 = 1; + } + else + { + pTemp->fMark0 = 1; + pTemp->fMark1 = 0; + } + Gia_ObjSetTravIdCurrent( p, pTemp ); + } + 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" ); + assert( Value == GIA_ONE ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatComputePattern4_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return; + Gia_ObjSetTravIdCurrent(p, pObj); + pObj->fMark0 = 0; + if ( Gia_ObjIsCi(pObj) ) + return; + assert( Gia_ObjIsAnd(pObj) ); + Cec_ManPatComputePattern4_rec( p, Gia_ObjFanin0(pObj) ); + Cec_ManPatComputePattern4_rec( p, Gia_ObjFanin1(pObj) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatCleanMark0( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + assert( Gia_ObjIsCo(pObj) ); + Gia_ManIncrementTravId( p ); + Cec_ManPatComputePattern4_rec( p, Gia_ObjFanin0(pObj) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManPatSavePattern( Cec_ManPat_t * pMan, Cec_ManSat_t * p, Gia_Obj_t * pObj ) +{ + Vec_Int_t * vPat; + int nPatLits, clk, clkTotal = clock(); + assert( Gia_ObjIsCo(pObj) ); + pMan->nPats++; + pMan->nPatsAll++; + // compute values in the cone of influence +clk = clock(); + Gia_ManIncrementTravId( p->pAig ); + nPatLits = Cec_ManPatComputePattern_rec( p, p->pAig, Gia_ObjFanin0(pObj) ); + assert( (Gia_ObjFanin0(pObj)->fMark1 ^ Gia_ObjFaninC0(pObj)) == 1 ); + pMan->nPatLits += nPatLits; + pMan->nPatLitsAll += nPatLits; +pMan->timeFind += clock() - clk; + // compute sensitizing path +clk = clock(); + Vec_IntClear( pMan->vPattern1 ); + Gia_ManIncrementTravId( p->pAig ); + Cec_ManPatComputePattern1_rec( p->pAig, Gia_ObjFanin0(pObj), pMan->vPattern1 ); + // compute sensitizing path + Vec_IntClear( pMan->vPattern2 ); + Gia_ManIncrementTravId( p->pAig ); + Cec_ManPatComputePattern2_rec( p->pAig, Gia_ObjFanin0(pObj), pMan->vPattern2 ); + // compare patterns + vPat = Vec_IntSize(pMan->vPattern1) < Vec_IntSize(pMan->vPattern2) ? pMan->vPattern1 : pMan->vPattern2; + pMan->nPatLitsMin += Vec_IntSize(vPat); + pMan->nPatLitsMinAll += Vec_IntSize(vPat); +pMan->timeShrink += clock() - clk; + // verify pattern using ternary simulation +clk = clock(); + Cec_ManPatVerifyPattern( p->pAig, pObj, vPat ); +pMan->timeVerify += clock() - clk; + // sort pattern +clk = clock(); + Vec_IntSort( vPat, 0 ); +pMan->timeSort += clock() - clk; + // save pattern + Cec_ManPatStore( pMan, vPat ); + pMan->timeTotal += clock() - clkTotal; +} + +/**Function************************************************************* + + Synopsis [Packs patterns into array of simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +*************************************`**********************************/ +int Cec_ManPatCollectTry( 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 = Vec_PtrEntry(vInfo, Gia_Lit2Var(pLits[i])); + pPres = Vec_PtrEntry(vPres, Gia_Lit2Var(pLits[i])); + if ( Aig_InfoHasBit( pPres, iBit ) && + Aig_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])); + Aig_InfoSetBit( pPres, iBit ); + if ( Aig_InfoHasBit( pInfo, iBit ) == Gia_LitIsCompl(pLits[i]) ) + Aig_InfoXorBit( pInfo, iBit ); + } + return 1; +} + +/**Function************************************************************* + + Synopsis [Packs patterns into array of simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Ptr_t * Cec_ManPatCollectPatterns( Cec_ManPat_t * pMan, int nInputs, int nWordsInit ) +{ + Vec_Int_t * vPat = pMan->vPattern1; + Vec_Ptr_t * vInfo, * vPres; + int k, kMax = -1, nPatterns = 0; + int iStartOld = pMan->iStart; + int nWords = nWordsInit; + int nBits = 32 * nWords; + int clk = clock(); + vInfo = Vec_PtrAllocSimInfo( nInputs, nWords ); + Aig_ManRandomInfo( vInfo, 0, nWords ); + vPres = Vec_PtrAllocSimInfo( nInputs, nWords ); + Vec_PtrCleanSimInfo( vPres, 0, nWords ); + while ( pMan->iStart < Vec_StrSize(pMan->vStorage) ) + { + nPatterns++; + Cec_ManPatRestore( pMan, vPat ); + for ( k = 1; k < nBits; k++, k += ((k % (32 * nWordsInit)) == 0) ) + if ( Cec_ManPatCollectTry( vInfo, vPres, k, (int *)Vec_IntArray(vPat), Vec_IntSize(vPat) ) ) + break; + kMax = AIG_MAX( kMax, k ); + if ( k == nBits-1 ) + { + Vec_PtrReallocSimInfo( vInfo ); + Aig_ManRandomInfo( vInfo, nWords, 2*nWords ); + Vec_PtrReallocSimInfo( vPres ); + Vec_PtrCleanSimInfo( vPres, nWords, 2*nWords ); + nWords *= 2; + nBits *= 2; + } + } + Vec_PtrFree( vPres ); + pMan->nSeries = Vec_PtrReadWordsSimInfo(vInfo) / nWordsInit; + pMan->timePack += clock() - clk; + pMan->timeTotal += clock() - clk; + pMan->iStart = iStartOld; + if ( pMan->fVerbose ) + { + printf( "Total = %5d. Max used = %5d. Full = %5d. Series = %d. ", + nPatterns, kMax, nWordsInit*32, pMan->nSeries ); + ABC_PRT( "Time", clock() - clk ); + Cec_ManPatPrintStats( pMan ); + } + return vInfo; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec/cecSat.c b/src/aig/cec/cecSat.c deleted file mode 100644 index 9cf13ebc..00000000 --- a/src/aig/cec/cecSat.c +++ /dev/null @@ -1,250 +0,0 @@ -/**CFile**************************************************************** - - FileName [cecSat.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [Combinatinoal equivalence checking.] - - Synopsis [SAT solver calls.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: cecSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "cecInt.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Creates the manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Cec_ManSat_t * Cec_ManCreate( Aig_Man_t * pAig, Cec_ParSat_t * pPars ) -{ - Cec_ManSat_t * p; - // create interpolation manager - p = ALLOC( Cec_ManSat_t, 1 ); - memset( p, 0, sizeof(Cec_ManSat_t) ); - p->pPars = pPars; - p->pAig = pAig; - // SAT solving - p->nSatVars = 1; - p->pSatVars = CALLOC( int, Aig_ManObjNumMax(pAig) ); - p->vUsedNodes = Vec_PtrAlloc( 1000 ); - p->vFanins = Vec_PtrAlloc( 100 ); - return p; -} - -/**Function************************************************************* - - Synopsis [Frees the manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_ManStop( Cec_ManSat_t * p ) -{ - if ( p->pSat ) - sat_solver_delete( p->pSat ); - Vec_PtrFree( p->vUsedNodes ); - Vec_PtrFree( p->vFanins ); - FREE( p->pSatVars ); - free( p ); -} - -/**Function************************************************************* - - Synopsis [Recycles the SAT solver.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_ManSatSolverRecycle( Cec_ManSat_t * p ) -{ - int Lit; - if ( p->pSat ) - { - Aig_Obj_t * pObj; - int i; - Vec_PtrForEachEntry( p->vUsedNodes, pObj, i ) - Cec_ObjSetSatNum( p, pObj, 0 ); - Vec_PtrClear( p->vUsedNodes ); -// memset( p->pSatVars, 0, sizeof(int) * Aig_ManObjNumMax(p->pAigTotal) ); - sat_solver_delete( p->pSat ); - } - p->pSat = sat_solver_new(); - sat_solver_setnvars( p->pSat, 1000 ); - // var 0 is not used - // var 1 is reserved for const1 node - add the clause - p->nSatVars = 1; -// p->nSatVars = 0; - Lit = toLit( p->nSatVars ); - if ( p->pPars->fPolarFlip ) - Lit = lit_neg( Lit ); - sat_solver_addclause( p->pSat, &Lit, &Lit + 1 ); - Cec_ObjSetSatNum( p, Aig_ManConst1(p->pAig), p->nSatVars++ ); - - p->nRecycles++; - p->nCallsSince = 0; -} - -/**Function************************************************************* - - Synopsis [Runs equivalence test for the two nodes.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Cec_ManSatCheckNode( Cec_ManSat_t * p, Aig_Obj_t * pNode ) -{ - int nBTLimit = p->pPars->nBTLimit; - int Lit, RetValue, status, clk; - - // sanity checks - assert( !Aig_IsComplement(pNode) ); - - p->nCallsSince++; // experiment with this!!! - - // check if SAT solver needs recycling - if ( p->pSat == NULL || - (p->pPars->nSatVarMax && - p->nSatVars > p->pPars->nSatVarMax && - p->nCallsSince > p->pPars->nCallsRecycle) ) - Cec_ManSatSolverRecycle( p ); - - // if the nodes do not have SAT variables, allocate them - Cec_CnfNodeAddToSolver( p, pNode ); - - // propage unit clauses - if ( p->pSat->qtail != p->pSat->qhead ) - { - status = sat_solver_simplify(p->pSat); - assert( status != 0 ); - assert( p->pSat->qtail == p->pSat->qhead ); - } - - // solve under assumptions - // A = 1; B = 0 OR A = 1; B = 1 - Lit = toLitCond( Cec_ObjSatNum(p,pNode), pNode->fPhase ); - if ( p->pPars->fPolarFlip ) - { - if ( pNode->fPhase ) Lit = lit_neg( Lit ); - } -//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); -clk = clock(); - RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, - (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); - if ( RetValue == l_False ) - { -p->timeSatUnsat += clock() - clk; - Lit = lit_neg( Lit ); - RetValue = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 ); - assert( RetValue ); - p->timeSatUnsat++; - return 1; - } - else if ( RetValue == l_True ) - { -p->timeSatSat += clock() - clk; - p->timeSatSat++; - return 0; - } - else // if ( RetValue == l_Undef ) - { -p->timeSatUndec += clock() - clk; - p->timeSatUndec++; - return -1; - } -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Cec_MtrStatus_t Cec_SatSolveOutputs( Aig_Man_t * pAig, Cec_ParSat_t * pPars ) -{ - Bar_Progress_t * pProgress = NULL; - Cec_MtrStatus_t Status; - Cec_ManSat_t * p; - Aig_Obj_t * pObj; - int i, status; - Status = Cec_MiterStatus( pAig ); - p = Cec_ManCreate( pAig, pPars ); - pProgress = Bar_ProgressStart( stdout, Aig_ManPoNum(pAig) ); - Aig_ManForEachPo( pAig, pObj, i ) - { - Bar_ProgressUpdate( pProgress, i, "SAT..." ); - if ( Cec_OutputStatus(pAig, pObj) ) - continue; - status = Cec_ManSatCheckNode( p, Aig_ObjFanin0(pObj) ); - if ( status == 1 ) - { - Status.nUndec--, Status.nUnsat++; - Aig_ObjPatchFanin0( pAig, pObj, Aig_ManConst0(pAig) ); - } - if ( status == 0 ) - { - Status.nUndec--, Status.nSat++; - Aig_ObjPatchFanin0( pAig, pObj, Aig_ManConst1(pAig) ); - } - if ( status == -1 ) - continue; - // save the pattern (if it is first) - if ( Status.iOut == -1 ) - { - } - // quit if at least one of them is solved - if ( status == 0 && pPars->fFirstStop ) - break; - } - Aig_ManCleanup( pAig ); - Bar_ProgressStop( pProgress ); - printf( " Confs = %8d. Recycles = %6d.\n", p->pPars->nBTLimit, p->nRecycles ); - Cec_ManStop( p ); - return Status; -} - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/aig/cec/cecSim.c b/src/aig/cec/cecSim.c deleted file mode 100644 index 8a5f3cd5..00000000 --- a/src/aig/cec/cecSim.c +++ /dev/null @@ -1,459 +0,0 @@ -/**CFile**************************************************************** - - FileName [cecSim.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [Combinatinoal equivalence checking.] - - Synopsis [AIG simulation.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: cecSim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "cecInt.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Count PIs with fanout.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Caig_ManCountRelevantPis( Aig_Man_t * pAig ) -{ - Aig_Obj_t * pObj; - int i, Counter = 0; - Aig_ManForEachPi( pAig, pObj, i ) - if ( Aig_ObjRefs(pObj) ) - Counter++; - else - pObj->iData = -1; - return Counter; -} - -/**Function************************************************************* - - Synopsis [Count PIs with fanout.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Caig_ManCountRelevantPos( Aig_Man_t * pAig ) -{ - Aig_Obj_t * pObj; - int i, Counter = 0; - Aig_ManForEachPo( pAig, pObj, i ) - if ( !Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) ) - Counter++; - else - pObj->iData = -1; - return Counter; -} - -/**Function************************************************************* - - Synopsis [Find the PO corresponding to the PO driver.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Caig_ManFindPo( Aig_Man_t * pAig, int iNode ) -{ - Aig_Obj_t * pObj; - int i; - Aig_ManForEachPo( pAig, pObj, i ) - if ( pObj->iData == iNode ) - return i; - return -1; -} - -/**Function************************************************************* - - Synopsis [Creates fast simulation manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Caig_ManCreate_rec( Caig_Man_t * p, Aig_Obj_t * pObj ) -{ - int iFan0, iFan1; - assert( !Aig_IsComplement(pObj) ); - assert( !Aig_ObjIsConst1(pObj) ); - if ( pObj->iData ) - return pObj->iData; - if ( Aig_ObjIsNode(pObj) ) - { - iFan0 = Caig_ManCreate_rec( p, Aig_ObjFanin0(pObj) ); - iFan0 = (iFan0 << 1) | Aig_ObjFaninC0(pObj); - iFan1 = Caig_ManCreate_rec( p, Aig_ObjFanin1(pObj) ); - iFan1 = (iFan1 << 1) | Aig_ObjFaninC1(pObj); - } - else if ( Aig_ObjIsPo(pObj) ) - { - iFan0 = Caig_ManCreate_rec( p, Aig_ObjFanin0(pObj) ); - iFan0 = (iFan0 << 1) | Aig_ObjFaninC0(pObj); - iFan1 = 0; - } - else - iFan0 = iFan1 = 0; - assert( Aig_ObjRefs(pObj) < (1<<16) ); - p->pFans0[p->nObjs] = iFan0; - p->pFans1[p->nObjs] = iFan1; - p->pRefs[p->nObjs] = (unsigned short)Aig_ObjRefs(pObj); - return pObj->iData = p->nObjs++; -} - -/**Function************************************************************* - - Synopsis [Creates fast simulation manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig ) -{ - Caig_Man_t * p; - Aig_Obj_t * pObj; - int i, nObjs; - Aig_ManCleanData( pAig ); - p = (Caig_Man_t *)ALLOC( Caig_Man_t, 1 ); - memset( p, 0, sizeof(Caig_Man_t) ); - p->pAig = pAig; - p->nPis = Caig_ManCountRelevantPis(pAig); - p->nPos = Caig_ManCountRelevantPos(pAig); - p->nNodes = Aig_ManNodeNum(pAig); - nObjs = p->nPis + p->nPos + p->nNodes + 1; - p->pFans0 = ALLOC( int, nObjs ); - p->pFans1 = ALLOC( int, nObjs ); - p->pRefs = ALLOC( unsigned short, nObjs ); - p->pSims = CALLOC( unsigned, nObjs ); - // add objects - p->nObjs = 1; - Aig_ManForEachPo( pAig, pObj, i ) - if ( !Aig_ObjIsConst1(Aig_ObjFanin0(pObj)) ) - Caig_ManCreate_rec( p, pObj ); - assert( p->nObjs == nObjs ); - return p; -} - -/**Function************************************************************* - - Synopsis [Creates fast simulation manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Caig_ManDelete( Caig_Man_t * p ) -{ - if ( p->vSims ) Vec_PtrFree( p->vSims ); - if ( p->vClassOld ) Vec_IntFree( p->vClassOld ); - if ( p->vClassNew ) Vec_IntFree( p->vClassNew ); - FREE( p->pFans0 ); - FREE( p->pFans1 ); - FREE( p->pRefs ); - FREE( p->pSims ); - FREE( p->pMems ); - FREE( p->pReprs ); - FREE( p->pNexts ); - FREE( p ); -} - -/**Function************************************************************* - - Synopsis [References simulation info.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -unsigned * Caig_ManSimRead( Caig_Man_t * p, int i ) -{ - assert( i && p->pSims[i] > 0 ); - return p->pMems + p->pSims[i]; -} - -/**Function************************************************************* - - Synopsis [References simulation info.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -unsigned * Caig_ManSimRef( Caig_Man_t * p, int i ) -{ - unsigned * pSim; - assert( i ); - assert( p->pSims[i] == 0 ); - if ( p->MemFree == 0 ) - { - int * pPlace, Ent; - if ( p->nWordsAlloc == 0 ) - { - assert( p->pMems == NULL ); - p->nWordsAlloc = (1<<17); // -> 1Mb - p->nMems = 1; - } - p->nWordsAlloc *= 2; - p->pMems = REALLOC( unsigned, p->pMems, p->nWordsAlloc ); - pPlace = &p->MemFree; - for ( Ent = p->nMems * (p->nWords + 1); - Ent + p->nWords + 1 < p->nWordsAlloc; - Ent += p->nWords + 1 ) - { - *pPlace = Ent; - pPlace = p->pMems + Ent; - } - *pPlace = 0; - } - p->pSims[i] = p->MemFree; - pSim = p->pMems + p->MemFree; - p->MemFree = pSim[0]; - pSim[0] = p->pRefs[i]; - p->nMems++; - if ( p->nMemsMax < p->nMems ) - p->nMemsMax = p->nMems; - return pSim; -} - -/**Function************************************************************* - - Synopsis [Dereference simulaton info.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i ) -{ - unsigned * pSim; - assert( i ); - assert( p->pSims[i] > 0 ); - pSim = p->pMems + p->pSims[i]; - if ( --pSim[0] == 0 ) - { - pSim[0] = p->MemFree; - p->MemFree = p->pSims[i]; - p->pSims[i] = 0; - p->nMems--; - } - return pSim; -} - -/**Function************************************************************* - - Synopsis [Simulates one round.] - - Description [Returns the number of PO entry if failed; 0 otherwise.] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Caig_ManSimulateRound( Caig_Man_t * p, int fMiter ) -{ - Vec_Int_t * vRefined = NULL; - unsigned * pRes0, * pRes1, * pRes; - int i, w, iFan0, iFan1; - if ( p->pReprs ) - vRefined = Vec_IntAlloc( 1000 ); - for ( i = 1; i < p->nObjs; i++ ) - { - if ( p->pFans0[i] == 0 ) // pi always has zero first fanin - { - pRes = Caig_ManSimRef( p, i ); - for ( w = 1; w <= p->nWords; w++ ) - pRes[w] = Aig_ManRandom( 0 ); - goto references; - } - if ( p->pFans1[i] == 0 ) // po always has non-zero 1st fanin and zero 2nd fanin - { - if ( fMiter ) - { - unsigned Const = Cec_LitIsCompl(p->pFans0[i])? ~0 : 0; - pRes0 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans0[i]) ); - for ( w = 1; w <= p->nWords; w++ ) - if ( pRes0[w] != Const ) - return i; - } - continue; - } - pRes = Caig_ManSimRef( p, i ); - iFan0 = p->pFans0[i]; - iFan1 = p->pFans1[i]; - pRes0 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans0[i]) ); - pRes1 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans1[i]) ); - if ( Cec_LitIsCompl(iFan0) && Cec_LitIsCompl(iFan1) ) - for ( w = 1; w <= p->nWords; w++ ) - pRes[w] = ~(pRes0[w] | pRes1[w]); - else if ( Cec_LitIsCompl(iFan0) && !Cec_LitIsCompl(iFan1) ) - for ( w = 1; w <= p->nWords; w++ ) - pRes[w] = ~pRes0[w] & pRes1[w]; - else if ( !Cec_LitIsCompl(iFan0) && Cec_LitIsCompl(iFan1) ) - for ( w = 1; w <= p->nWords; w++ ) - pRes[w] = pRes0[w] & ~pRes1[w]; - else if ( !Cec_LitIsCompl(iFan0) && !Cec_LitIsCompl(iFan1) ) - for ( w = 1; w <= p->nWords; w++ ) - pRes[w] = pRes0[w] & pRes1[w]; -references: - if ( p->pReprs == NULL ) - continue; - // if this node is candidate constant, collect it - if ( p->pReprs[i] == 0 && !Caig_ManCompareConst(pRes + 1, p->nWords) ) - { - pRes[0]++; - Vec_IntPush( vRefined, i ); - } - // if the node belongs to a class, save it - if ( p->pReprs[i] > 0 || p->pNexts[i] > 0 ) - pRes[0]++; - // if this is the last node of the class, process it - if ( p->pReprs[i] > 0 && p->pNexts[i] == 0 ) - Caig_ManProcessClass( p, p->pReprs[i] ); - } - if ( p->pReprs ) - Caig_ManProcessRefined( p, vRefined ); - if ( p->pReprs ) - Vec_IntFree( vRefined ); - assert( p->nMems == 1 ); -/* - if ( p->nMems > 1 ) - { - for ( i = 1; i < p->nObjs; i++ ) - if ( p->pSims[i] ) - { - int x = 0; - } - } -*/ - return 0; -} - -/**Function************************************************************* - - Synopsis [Returns 1 if the bug is detected, 0 otherwise.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose ) -{ - Caig_Man_t * p; - Cec_MtrStatus_t Status; - int i, RetValue = 0, clk, clkTotal = clock(); -/* - p = Caig_ManClassesPrepare( pAig, nWords, nIters ); -// if ( fVerbose ) - printf( "Maxcut = %6d. AIG mem = %8.3f Mb. Sim mem = %8.3f Mb.\n", - p->nMemsMax, - 1.0*(p->nObjs * 14)/(1<<20), - 1.0*(p->nMemsMax * (nWords+1))/(1<<20) ); - Caig_ManDelete( p ); - return 0; -*/ - Status = Cec_MiterStatus( pAig ); - if ( Status.nSat > 0 ) - { - printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut ); - return 1; - } - if ( Status.nUndec == 0 ) - { - printf( "Miter is trivially unsatisfiable.\n" ); - return 0; - } - Aig_ManRandom( 1 ); - p = Caig_ManCreate( pAig ); - p->nWords = nWords; - for ( i = 0; i < nIters; i++ ) - { - clk = clock(); - RetValue = Caig_ManSimulateRound( p, fMiter ); - if ( fVerbose ) - { - printf( "Iter %3d out of %3d and timeout %3d sec. ", i+1, nIters, TimeLimit ); - printf("Time = %7.2f sec\r", (1.0*clock()-clkTotal)/CLOCKS_PER_SEC); - } - if ( RetValue > 0 ) - { - int iOut = Caig_ManFindPo(p->pAig, RetValue); - if ( fVerbose ) - printf( "Miter is satisfiable after simulation (output %d).\n", iOut ); - break; - } - if ( (clock() - clk)/CLOCKS_PER_SEC >= TimeLimit ) - { - printf( "No bug detected after %d rounds with time limit %d seconds.\n", i+1, TimeLimit ); - break; - } - } - if ( fVerbose ) - printf( "Maxcut = %6d. AIG mem = %8.3f Mb. Sim mem = %8.3f Mb.\n", - p->nMemsMax, - 1.0*(p->nObjs * 14)/(1<<20), - 1.0*(p->nMemsMax * 4 * (nWords+1))/(1<<20) ); - Caig_ManDelete( p ); - return RetValue > 0; -} - - - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/aig/cec/cecSolve.c b/src/aig/cec/cecSolve.c new file mode 100644 index 00000000..0ec7df45 --- /dev/null +++ b/src/aig/cec/cecSolve.c @@ -0,0 +1,537 @@ +/**CFile**************************************************************** + + FileName [cecSolve.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [Performs one round of SAT solving.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecSolve.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +static inline int Cec_ObjSatNum( Cec_ManSat_t * p, Gia_Obj_t * pObj ) { return p->pSatVars[Gia_ObjId(p->pAig,pObj)]; } +static inline void Cec_ObjSetSatNum( Cec_ManSat_t * p, Gia_Obj_t * pObj, int Num ) { p->pSatVars[Gia_ObjId(p->pAig,pObj)] = Num; } + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Returns value of the SAT variable.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ObjSatVarValue( Cec_ManSat_t * p, Gia_Obj_t * pObj ) +{ + return sat_solver_var_value( p->pSat, Cec_ObjSatNum(p, pObj) ); +} + +/**Function************************************************************* + + Synopsis [Addes clauses to the solver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_AddClausesMux( Cec_ManSat_t * p, Gia_Obj_t * pNode ) +{ + Gia_Obj_t * pNodeI, * pNodeT, * pNodeE; + int pLits[4], RetValue, VarF, VarI, VarT, VarE, fCompT, fCompE; + + assert( !Gia_IsComplement( pNode ) ); + assert( Gia_ObjIsMuxType( pNode ) ); + // get nodes (I = if, T = then, E = else) + pNodeI = Gia_ObjRecognizeMux( pNode, &pNodeT, &pNodeE ); + // get the variable numbers + VarF = Cec_ObjSatNum(p,pNode); + VarI = Cec_ObjSatNum(p,pNodeI); + VarT = Cec_ObjSatNum(p,Gia_Regular(pNodeT)); + VarE = Cec_ObjSatNum(p,Gia_Regular(pNodeE)); + // get the complementation flags + fCompT = Gia_IsComplement(pNodeT); + fCompE = Gia_IsComplement(pNodeE); + + // f = ITE(i, t, e) + + // i' + t' + f + // i' + t + f' + // i + e' + f + // i + e + f' + + // create four clauses + pLits[0] = toLitCond(VarI, 1); + pLits[1] = toLitCond(VarT, 1^fCompT); + pLits[2] = toLitCond(VarF, 0); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Gia_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarI, 1); + pLits[1] = toLitCond(VarT, 0^fCompT); + pLits[2] = toLitCond(VarF, 1); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Gia_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarI, 0); + pLits[1] = toLitCond(VarE, 1^fCompE); + pLits[2] = toLitCond(VarF, 0); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarI, 0); + pLits[1] = toLitCond(VarE, 0^fCompE); + pLits[2] = toLitCond(VarF, 1); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + + // two additional clauses + // t' & e' -> f' + // t & e -> f + + // t + e + f' + // t' + e' + f + + if ( VarT == VarE ) + { +// assert( fCompT == !fCompE ); + return; + } + + pLits[0] = toLitCond(VarT, 0^fCompT); + pLits[1] = toLitCond(VarE, 0^fCompE); + pLits[2] = toLitCond(VarF, 1); + if ( p->pPars->fPolarFlip ) + { + if ( Gia_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarT, 1^fCompT); + pLits[1] = toLitCond(VarE, 1^fCompE); + pLits[2] = toLitCond(VarF, 0); + if ( p->pPars->fPolarFlip ) + { + if ( Gia_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Gia_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); +} + +/**Function************************************************************* + + Synopsis [Addes clauses to the solver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_AddClausesSuper( Cec_ManSat_t * p, Gia_Obj_t * pNode, Vec_Ptr_t * vSuper ) +{ + Gia_Obj_t * pFanin; + int * pLits, nLits, RetValue, i; + assert( !Gia_IsComplement(pNode) ); + assert( Gia_ObjIsAnd( pNode ) ); + // create storage for literals + nLits = Vec_PtrSize(vSuper) + 1; + pLits = ABC_ALLOC( int, nLits ); + // suppose AND-gate is A & B = C + // add !A => !C or A + !C + Vec_PtrForEachEntry( vSuper, pFanin, i ) + { + pLits[0] = toLitCond(Cec_ObjSatNum(p,Gia_Regular(pFanin)), Gia_IsComplement(pFanin)); + pLits[1] = toLitCond(Cec_ObjSatNum(p,pNode), 1); + if ( p->pPars->fPolarFlip ) + { + if ( Gia_Regular(pFanin)->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( pNode->fPhase ) pLits[1] = lit_neg( pLits[1] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 ); + assert( RetValue ); + } + // add A & B => C or !A + !B + C + Vec_PtrForEachEntry( vSuper, pFanin, i ) + { + pLits[i] = toLitCond(Cec_ObjSatNum(p,Gia_Regular(pFanin)), !Gia_IsComplement(pFanin)); + if ( p->pPars->fPolarFlip ) + { + if ( Gia_Regular(pFanin)->fPhase ) pLits[i] = lit_neg( pLits[i] ); + } + } + pLits[nLits-1] = toLitCond(Cec_ObjSatNum(p,pNode), 0); + if ( p->pPars->fPolarFlip ) + { + if ( pNode->fPhase ) pLits[nLits-1] = lit_neg( pLits[nLits-1] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits ); + assert( RetValue ); + ABC_FREE( pLits ); +} + +/**Function************************************************************* + + Synopsis [Collects the supergate.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_CollectSuper_rec( Gia_Obj_t * pObj, Vec_Ptr_t * vSuper, int fFirst, int fUseMuxes ) +{ + // if the new node is complemented or a PI, another gate begins + if ( Gia_IsComplement(pObj) || Gia_ObjIsCi(pObj) || + (!fFirst && Gia_ObjValue(pObj) > 1) || + (fUseMuxes && Gia_ObjIsMuxType(pObj)) ) + { + Vec_PtrPushUnique( vSuper, pObj ); + return; + } + // go through the branches + Cec_CollectSuper_rec( Gia_ObjChild0(pObj), vSuper, 0, fUseMuxes ); + Cec_CollectSuper_rec( Gia_ObjChild1(pObj), vSuper, 0, fUseMuxes ); +} + +/**Function************************************************************* + + Synopsis [Collects the supergate.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_CollectSuper( Gia_Obj_t * pObj, int fUseMuxes, Vec_Ptr_t * vSuper ) +{ + assert( !Gia_IsComplement(pObj) ); + assert( !Gia_ObjIsCi(pObj) ); + Vec_PtrClear( vSuper ); + Cec_CollectSuper_rec( pObj, vSuper, 1, fUseMuxes ); +} + +/**Function************************************************************* + + Synopsis [Updates the solver clause database.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ObjAddToFrontier( Cec_ManSat_t * p, Gia_Obj_t * pObj, Vec_Ptr_t * vFrontier ) +{ + assert( !Gia_IsComplement(pObj) ); + if ( Cec_ObjSatNum(p,pObj) ) + return; + assert( Cec_ObjSatNum(p,pObj) == 0 ); + if ( Gia_ObjIsConst0(pObj) ) + return; + Vec_PtrPush( p->vUsedNodes, pObj ); + Cec_ObjSetSatNum( p, pObj, p->nSatVars++ ); + if ( Gia_ObjIsAnd(pObj) ) + Vec_PtrPush( vFrontier, pObj ); +} + +/**Function************************************************************* + + Synopsis [Updates the solver clause database.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Gia_Obj_t * pObj ) +{ + Vec_Ptr_t * vFrontier; + Gia_Obj_t * pNode, * pFanin; + int i, k, fUseMuxes = 1; + // quit if CNF is ready + if ( Cec_ObjSatNum(p,pObj) ) + return; + if ( Gia_ObjIsCi(pObj) ) + { + Vec_PtrPush( p->vUsedNodes, pObj ); + Cec_ObjSetSatNum( p, pObj, p->nSatVars++ ); + sat_solver_setnvars( p->pSat, p->nSatVars ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + // start the frontier + vFrontier = Vec_PtrAlloc( 100 ); + Cec_ObjAddToFrontier( p, pObj, vFrontier ); + // explore nodes in the frontier + Vec_PtrForEachEntry( vFrontier, pNode, i ) + { + // create the supergate + assert( Cec_ObjSatNum(p,pNode) ); + if ( fUseMuxes && Gia_ObjIsMuxType(pNode) ) + { + Vec_PtrClear( p->vFanins ); + Vec_PtrPushUnique( p->vFanins, Gia_ObjFanin0( Gia_ObjFanin0(pNode) ) ); + 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 ) + Cec_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier ); + Cec_AddClausesMux( p, pNode ); + } + else + { + Cec_CollectSuper( pNode, fUseMuxes, p->vFanins ); + Vec_PtrForEachEntry( p->vFanins, pFanin, k ) + Cec_ObjAddToFrontier( p, Gia_Regular(pFanin), vFrontier ); + Cec_AddClausesSuper( p, pNode, p->vFanins ); + } + assert( Vec_PtrSize(p->vFanins) > 1 ); + } + Vec_PtrFree( vFrontier ); +} + + +/**Function************************************************************* + + Synopsis [Recycles the SAT solver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatSolverRecycle( Cec_ManSat_t * p ) +{ + int Lit; + if ( p->pSat ) + { + Gia_Obj_t * pObj; + int i; + Vec_PtrForEachEntry( p->vUsedNodes, pObj, i ) + Cec_ObjSetSatNum( p, pObj, 0 ); + Vec_PtrClear( p->vUsedNodes ); +// memset( p->pSatVars, 0, sizeof(int) * Aig_ManObjNumMax(p->pAigTotal) ); + sat_solver_delete( p->pSat ); + } + p->pSat = sat_solver_new(); + sat_solver_setnvars( p->pSat, 1000 ); + // var 0 is not used + // var 1 is reserved for const0 node - add the clause + p->nSatVars = 1; +// p->nSatVars = 0; + Lit = toLitCond( p->nSatVars, 1 ); + if ( p->pPars->fPolarFlip ) + Lit = lit_neg( Lit ); + sat_solver_addclause( p->pSat, &Lit, &Lit + 1 ); + Cec_ObjSetSatNum( p, Gia_ManConst0(p->pAig), p->nSatVars++ ); + + p->nRecycles++; + p->nCallsSince = 0; +} + +/**Function************************************************************* + + Synopsis [Runs equivalence test for the two nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManSatCheckNode( Cec_ManSat_t * p, Gia_Obj_t * pObj ) +{ + int nBTLimit = p->pPars->nBTLimit; + int Lit, RetValue, status, clk, nConflicts; + + p->nCallsSince++; // experiment with this!!! + p->nSatTotal++; + + // check if SAT solver needs recycling + if ( p->pSat == NULL || + (p->pPars->nSatVarMax && + p->nSatVars > p->pPars->nSatVarMax && + p->nCallsSince > p->pPars->nCallsRecycle) ) + Cec_ManSatSolverRecycle( p ); + + // if the nodes do not have SAT variables, allocate them + Cec_CnfNodeAddToSolver( p, Gia_ObjFanin0(pObj) ); + + // propage unit clauses + if ( p->pSat->qtail != p->pSat->qhead ) + { + status = sat_solver_simplify(p->pSat); + assert( status != 0 ); + assert( p->pSat->qtail == p->pSat->qhead ); + } + + // solve under assumptions + // A = 1; B = 0 OR A = 1; B = 1 + Lit = toLitCond( Cec_ObjSatNum(p,Gia_ObjFanin0(pObj)), Gia_ObjFaninC0(pObj) ); + if ( p->pPars->fPolarFlip ) + { + if ( Gia_ObjFanin0(pObj)->fPhase ) Lit = lit_neg( Lit ); + } +//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); +clk = clock(); + nConflicts = p->pSat->stats.conflicts; + RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); + if ( RetValue == l_False ) + { +p->timeSatUnsat += clock() - clk; + Lit = lit_neg( Lit ); + RetValue = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 ); + assert( RetValue ); + p->nSatUnsat++; + p->nConfUnsat += p->pSat->stats.conflicts - nConflicts; + return 1; + } + else if ( RetValue == l_True ) + { +p->timeSatSat += clock() - clk; + p->nSatSat++; + p->nConfSat += p->pSat->stats.conflicts - nConflicts; + return 0; + } + else // if ( RetValue == l_Undef ) + { +p->timeSatUndec += clock() - clk; + p->nSatUndec++; + p->nConfUndec += p->pSat->stats.conflicts - nConflicts; + return -1; + } +} + +/**Function************************************************************* + + Synopsis [Performs one round of solving for the POs of the AIG.] + + Description [Labels the nodes that have been proved (pObj->fMark1) + and returns the set of satisfying assignments.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatSolve( Cec_ManPat_t * pPat, Gia_Man_t * pAig, Cec_ParSat_t * pPars ) +{ + Bar_Progress_t * pProgress = NULL; + Cec_ManSat_t * p; + Gia_Obj_t * pObj; + int i, status, clk = clock(); + // reset the manager + if ( pPat ) + { + pPat->iStart = Vec_StrSize(pPat->vStorage); + pPat->nPats = 0; + pPat->nPatLits = 0; + pPat->nPatLitsMin = 0; + } + Gia_ManSetPhase( pAig ); + Gia_ManResetTravId( pAig ); + p = Cec_ManSatCreate( pAig, pPars ); + pProgress = Bar_ProgressStart( stdout, Gia_ManPoNum(pAig) ); + Gia_ManForEachCo( pAig, pObj, i ) + { + if ( Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) ) + { + pObj->fMark0 = 0; + pObj->fMark1 = 1; + continue; + } + Bar_ProgressUpdate( pProgress, i, "SAT..." ); + status = Cec_ManSatCheckNode( p, pObj ); + pObj->fMark0 = (status == 0); + pObj->fMark1 = (status == 1); +/* + if ( status == -1 ) + { + 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" ); + } +*/ + if ( status != 0 ) + continue; + // save the pattern + if ( pPat ) + Cec_ManPatSavePattern( pPat, p, pObj ); + // quit if one of them is solved + if ( pPars->fFirstStop ) + break; + } + p->timeTotal = clock() - clk; + Bar_ProgressStop( pProgress ); + if ( pPars->fVerbose ) + Cec_ManSatPrintStats( p ); + Cec_ManSatStop( p ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec/cecStatus.c b/src/aig/cec/cecStatus.c deleted file mode 100644 index 79d6ec66..00000000 --- a/src/aig/cec/cecStatus.c +++ /dev/null @@ -1,187 +0,0 @@ -/**CFile**************************************************************** - - FileName [cecStatus.c] - - SystemName [ABC: Logic synthesis and verification system.] - - PackageName [Combinatinoal equivalence checking.] - - Synopsis [Miter status.] - - Author [Alan Mishchenko] - - Affiliation [UC Berkeley] - - Date [Ver. 1.0. Started - June 20, 2005.] - - Revision [$Id: cecStatus.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] - -***********************************************************************/ - -#include "cecInt.h" - -//////////////////////////////////////////////////////////////////////// -/// DECLARATIONS /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// FUNCTION DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -/**Function************************************************************* - - Synopsis [Returns 1 if the output is known.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Cec_OutputStatus( Aig_Man_t * p, Aig_Obj_t * pObj ) -{ - Aig_Obj_t * pChild; - assert( Aig_ObjIsPo(pObj) ); - pChild = Aig_ObjChild0(pObj); - // check if the output is constant 0 - if ( pChild == Aig_ManConst0(p) ) - return 1; - // check if the output is constant 1 - if ( pChild == Aig_ManConst1(p) ) - return 1; - // check if the output is a primary input - if ( Aig_ObjIsPi(Aig_Regular(pChild)) ) - return 1; - // check if the output is 1 for the 0000 pattern - if ( Aig_Regular(pChild)->fPhase != (unsigned)Aig_IsComplement(pChild) ) - return 1; - return 0; -} - -/**Function************************************************************* - - Synopsis [Returns number of used inputs.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Cec_CountInputs( Aig_Man_t * p ) -{ - Aig_Obj_t * pObj; - int i, Counter = 0; - Aig_ManForEachPi( p, pObj, i ) - Counter += (int)(pObj->nRefs > 0); - return Counter; -} - -/**Function************************************************************* - - Synopsis [Checks the status of the miter.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Cec_MtrStatus_t Cec_MiterStatus( Aig_Man_t * p ) -{ - Cec_MtrStatus_t Status; - Aig_Obj_t * pObj, * pChild; - int i; - assert( p->nRegs == 0 ); - memset( &Status, 0, sizeof(Cec_MtrStatus_t) ); - Status.iOut = -1; - Status.nInputs = Cec_CountInputs( p ); - Status.nNodes = Aig_ManNodeNum( p ); - Status.nOutputs = Aig_ManPoNum(p); - Aig_ManForEachPo( p, pObj, i ) - { - pChild = Aig_ObjChild0(pObj); - // check if the output is constant 0 - if ( pChild == Aig_ManConst0(p) ) - Status.nUnsat++; - // check if the output is constant 1 - else if ( pChild == Aig_ManConst1(p) ) - { - Status.nSat++; - if ( Status.iOut == -1 ) - Status.iOut = i; - } - // check if the output is a primary input - else if ( Aig_ObjIsPi(Aig_Regular(pChild)) ) - { - Status.nSat++; - if ( Status.iOut == -1 ) - Status.iOut = i; - } - // check if the output is 1 for the 0000 pattern - else if ( Aig_Regular(pChild)->fPhase != (unsigned)Aig_IsComplement(pChild) ) - { - Status.nSat++; - if ( Status.iOut == -1 ) - Status.iOut = i; - } - else - Status.nUndec++; - } - return Status; -} - -/**Function************************************************************* - - Synopsis [Checks the status of the miter.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Cec_MtrStatus_t Cec_MiterStatusTrivial( Aig_Man_t * p ) -{ - Cec_MtrStatus_t Status; - memset( &Status, 0, sizeof(Cec_MtrStatus_t) ); - Status.iOut = -1; - Status.nInputs = Aig_ManPiNum(p); - Status.nNodes = Aig_ManNodeNum( p ); - Status.nOutputs = Aig_ManPoNum(p); - Status.nUndec = Aig_ManPoNum(p); - return Status; -} - -/**Function************************************************************* - - Synopsis [Prints the status of the miter.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Cec_MiterStatusPrint( Cec_MtrStatus_t S, char * pString, int Time ) -{ - printf( "%s:", pString ); - printf( " I =%6d", S.nInputs ); - printf( " N =%7d", S.nNodes ); - printf( " " ); - printf( " ? =%6d", S.nUndec ); - printf( " U =%6d", S.nUnsat ); - printf( " S =%6d", S.nSat ); - printf(" %7.2f sec\n", (float)(Time)/(float)(CLOCKS_PER_SEC)); -} - -//////////////////////////////////////////////////////////////////////// -/// END OF FILE /// -//////////////////////////////////////////////////////////////////////// - - diff --git a/src/aig/cec/module.make b/src/aig/cec/module.make index 29f8c859..f8e2602a 100644 --- a/src/aig/cec/module.make +++ b/src/aig/cec/module.make @@ -1,8 +1,5 @@ -SRC += src/aig/cec/cecAig.c \ - src/aig/cec/cecClass.c \ - src/aig/cec/cecCnf.c \ +SRC += src/aig/cec/cecClass.c \ src/aig/cec/cecCore.c \ src/aig/cec/cecMan.c \ - src/aig/cec/cecSat.c \ - src/aig/cec/cecSim.c \ - src/aig/cec/cecStatus.c + src/aig/cec/cecPat.c \ + src/aig/cec/cecSolve.c diff --git a/src/aig/cec2/cec.h b/src/aig/cec2/cec.h new file mode 100644 index 00000000..3586b535 --- /dev/null +++ b/src/aig/cec2/cec.h @@ -0,0 +1,104 @@ +/**CFile**************************************************************** + + FileName [cec.h] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [External declarations.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#ifndef __CEC_H__ +#define __CEC_H__ + +//////////////////////////////////////////////////////////////////////// +/// INCLUDES /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// PARAMETERS /// +//////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////////////////////////////////////// +/// BASIC TYPES /// +//////////////////////////////////////////////////////////////////////// + +// dynamic SAT parameters +typedef struct Cec_ParSat_t_ Cec_ParSat_t; +struct Cec_ParSat_t_ +{ + int nBTLimit; // conflict limit at a node + int nSatVarMax; // the max number of SAT variables + int nCallsRecycle; // calls to perform before recycling SAT solver + int fFirstStop; // stop on the first sat output + int fPolarFlip; // uses polarity adjustment + int fVerbose; // verbose stats +}; + +// combinational SAT sweeping parameters +typedef struct Cec_ParCsw_t_ Cec_ParCsw_t; +struct Cec_ParCsw_t_ +{ + int nWords; // the number of simulation words + int nRounds; // the number of simulation rounds + int nBTLimit; // conflict limit at a node + int nSatVarMax; // the max number of SAT variables + int nCallsRecycle; // calls to perform before recycling SAT solver + int nLevelMax; // restriction on the level nodes to be swept + int fRewriting; // enables AIG rewriting + int fFirstStop; // stop on the first sat output + int fVerbose; // verbose stats +}; + +// combinational equivalence checking parameters +typedef struct Cec_ParCec_t_ Cec_ParCec_t; +struct Cec_ParCec_t_ +{ + int nIters; // iterations of SAT solving/sweeping + int nBTLimitBeg; // starting backtrack limit + int nBTlimitMulti; // multiple of backtrack limit + int fUseSmartCnf; // use smart CNF computation + int fRewriting; // enables AIG rewriting + int fSatSweeping; // enables SAT sweeping + int fFirstStop; // stop on the first sat output + int fVerbose; // verbose stats +}; + +//////////////////////////////////////////////////////////////////////// +/// MACRO DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +/*=== cecCore.c ==========================================================*/ +extern void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p ); +extern void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p ); +extern void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p ); +extern int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * p ); + +#ifdef __cplusplus +} +#endif + +#endif + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + diff --git a/src/aig/cec2/cecAig.c b/src/aig/cec2/cecAig.c new file mode 100644 index 00000000..c322ead8 --- /dev/null +++ b/src/aig/cec2/cecAig.c @@ -0,0 +1,168 @@ +/**CFile**************************************************************** + + FileName [cecAig.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [AIG manipulation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecAig.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Derives combinational miter of the two AIGs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Obj_t * Cec_DeriveMiter_rec( Aig_Man_t * pNew, Aig_Obj_t * pObj ) +{ + if ( pObj->pData ) + return pObj->pData; + if ( Aig_ObjIsPi(pObj) ) + { + pObj->pData = Aig_ObjCreatePi( pNew ); + if ( pObj->pHaig ) + { + assert( pObj->pHaig->pData == NULL ); + pObj->pHaig->pData = pObj->pData; + } + return pObj->pData; + } + assert( Aig_ObjIsNode(pObj) ); + Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj) ); + Cec_DeriveMiter_rec( pNew, Aig_ObjFanin1(pObj) ); + pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ); + return pObj->pData; +} + +/**Function************************************************************* + + Synopsis [Derives combinational miter of the two AIGs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 ) +{ + Bar_Progress_t * pProgress = NULL; + Aig_Man_t * pNew; + Aig_Obj_t * pObj0, * pObj1, * pObjNew; + int i; + assert( Aig_ManPiNum(p0) == Aig_ManPiNum(p1) ); + assert( Aig_ManPoNum(p0) == Aig_ManPoNum(p1) ); + // create the new manager + pNew = Aig_ManStart( Aig_ManNodeNum(p0) + Aig_ManNodeNum(p1) ); + pNew->pName = Aig_UtilStrsav( p0->pName ); + // create the PIs + Aig_ManCleanData( p0 ); + Aig_ManCleanData( p1 ); + Aig_ManConst1(p0)->pData = Aig_ManConst1(pNew); + Aig_ManConst1(p1)->pData = Aig_ManConst1(pNew); + Aig_ManForEachPi( p0, pObj0, i ) + { + pObj1 = Aig_ManPi( p1, i ); + pObj0->pHaig = pObj1; + pObj1->pHaig = pObj0; + if ( Aig_ObjRefs(pObj0) || Aig_ObjRefs(pObj1) ) + continue; + pObjNew = Aig_ObjCreatePi( pNew ); + pObj0->pData = pObjNew; + pObj1->pData = pObjNew; + } + // add logic for the POs + pProgress = Bar_ProgressStart( stdout, Aig_ManPoNum(p0) ); + Aig_ManForEachPo( p0, pObj0, i ) + { + Bar_ProgressUpdate( pProgress, i, "Miter..." ); + pObj1 = Aig_ManPo( p1, i ); + Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj0) ); + Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj1) ); + pObjNew = Aig_Exor( pNew, Aig_ObjChild0Copy(pObj0), Aig_ObjChild0Copy(pObj1) ); + Aig_ObjCreatePo( pNew, pObjNew ); + } + Bar_ProgressStop( pProgress ); + Aig_ManSetRegNum( pNew, 0 ); + assert( Aig_ManHasNoGaps(pNew) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Man_t * Cec_Duplicate( Aig_Man_t * p ) +{ + Bar_Progress_t * pProgress = NULL; + Aig_Man_t * pNew; + Aig_Obj_t * pObj; + int i; + // make sure the AIG does not have choices and dangling nodes + Aig_ManForEachNode( p, pObj, i ) + assert( Aig_ObjRefs(pObj) > 0 ); + // create the new manager + pNew = Aig_ManStart( Aig_ManNodeNum(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->pHaig = NULL; + if ( Aig_ObjRefs(pObj) == 0 ) + pObj->pData = Aig_ObjCreatePi( pNew ); + } + // add logic for the POs + pProgress = Bar_ProgressStart( stdout, Aig_ManPoNum(p) ); + Aig_ManForEachPo( p, pObj, i ) + { + Bar_ProgressUpdate( pProgress, i, "Miter..." ); + Cec_DeriveMiter_rec( pNew, Aig_ObjFanin0(pObj) ); + Aig_ObjCreatePo( pNew, Aig_ObjChild0Copy(pObj) ); + } + Bar_ProgressStop( pProgress ); + Aig_ManSetRegNum( pNew, 0 ); + assert( Aig_ManHasNoGaps(pNew) ); + return pNew; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecClass.c b/src/aig/cec2/cecClass.c new file mode 100644 index 00000000..24e40281 --- /dev/null +++ b/src/aig/cec2/cecClass.c @@ -0,0 +1,571 @@ +/**CFile**************************************************************** + + FileName [cecClass.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [Equivalence class representation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecClass.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p, int nLevels ) +{ + Aig_Man_t * pAig; + Aig_Obj_t ** pCopy; + Aig_Obj_t * pRes0, * pRes1, * pRepr, * pNode; + Aig_Obj_t * pMiter; + int i; + pAig = Aig_ManStart( p->nNodes ); + pCopy = ABC_ALLOC( Aig_Obj_t *, p->nObjs ); + pCopy[0] = Aig_ManConst1(pAig); + for ( i = 1; i < p->nObjs; i++ ) + { + if ( p->pFans0[i] == -1 ) // pi always has zero first fanin + { + pCopy[i] = Aig_ObjCreatePi( pAig ); + continue; + } + if ( p->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin + continue; + pRes0 = Aig_NotCond( pCopy[Cec_Lit2Var(p->pFans0[i])], Cec_LitIsCompl(p->pFans0[i]) ); + pRes1 = Aig_NotCond( pCopy[Cec_Lit2Var(p->pFans1[i])], Cec_LitIsCompl(p->pFans1[i]) ); + pNode = pCopy[i] = Aig_And( pAig, pRes0, pRes1 ); + if ( p->pReprs[i] < 0 ) + continue; + assert( p->pReprs[i] < i ); + pRepr = pCopy[p->pReprs[i]]; + if ( Aig_Regular(pNode) == Aig_Regular(pRepr) ) + continue; + pCopy[i] = Aig_NotCond( pRepr, Aig_ObjPhaseReal(pRepr) ^ Aig_ObjPhaseReal(pNode) ); + if ( nLevels && ((int)Aig_Regular(pRepr)->Level > nLevels || (int)Aig_Regular(pNode)->Level > nLevels) ) + continue; + pMiter = Aig_Exor( pAig, pNode, pRepr ); + Aig_ObjCreatePo( pAig, Aig_NotCond(pMiter, Aig_ObjPhaseReal(pMiter)) ); +// Aig_ObjCreatePo( pAig, Aig_Regular(pRepr) ); +// Aig_ObjCreatePo( pAig, Aig_Regular(pCopy[i]) ); + } + ABC_FREE( pCopy ); + Aig_ManSetRegNum( pAig, 0 ); + Aig_ManCleanup( pAig ); + return pAig; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Caig_ManCountOne( Caig_Man_t * p, int i ) +{ + int Ent, nLits = 0; + assert( p->pReprs[i] < 0 && p->pNexts[i] > 0 ); + for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] ) + { + assert( p->pReprs[Ent] == i ); + nLits++; + } + return 1 + nLits; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Caig_ManCountLiterals( Caig_Man_t * p ) +{ + int i, nLits = 0; + for ( i = 1; i < p->nObjs; i++ ) + if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) + nLits += Caig_ManCountOne(p, i) - 1; + return nLits; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManPrintOne( Caig_Man_t * p, int i, int Counter ) +{ + int Ent; + printf( "Class %4d : Num = %2d {", Counter, Caig_ManCountOne(p, i) ); + for ( Ent = i; Ent; Ent = p->pNexts[Ent] ) + printf(" %d", Ent ); + printf( " }\n" ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose ) +{ + int i, Counter = 0, Counter1 = 0, CounterX = 0, nLits; + for ( i = 1; i < p->nObjs; i++ ) + { + if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) + Counter++; + if ( p->pReprs[i] == 0 ) + Counter1++; + if ( p->pReprs[i] < 0 && p->pNexts[i] == 0 ) + CounterX++; + } + nLits = Caig_ManCountLiterals( p ); + printf( "Class = %6d. Const = %6d. Unsed = %6d. Lits = %7d. All = %7d. Mem = %5.2f Mb\n", + Counter, Counter1, CounterX, nLits, nLits+Counter1, 1.0*p->nMemsMax/(1<<20) ); + if ( fVerbose ) + for ( i = 1; i < p->nObjs; i++ ) + if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) + Caig_ManPrintOne( p, i, ++Counter ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManCollectSimsSimple( Caig_Man_t * p, int i ) +{ + int Ent; + Vec_PtrClear( p->vSims ); + for ( Ent = i; Ent; Ent = p->pNexts[Ent] ) + Vec_PtrPush( p->vSims, p->pSims + Ent ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i ) +{ + unsigned * pSim; + int Ent; + Vec_PtrClear( p->vSims ); + for ( Ent = i; Ent; Ent = p->pNexts[Ent] ) + { + pSim = Caig_ManSimDeref( p, Ent ); + Vec_PtrPush( p->vSims, pSim + 1 ); + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords ) +{ + int w; + if ( (p0[0] & 1) == (p1[0] & 1) ) + { + for ( w = 0; w < nWords; w++ ) + if ( p0[w] != p1[w] ) + return 0; + return 1; + } + else + { + for ( w = 0; w < nWords; w++ ) + if ( p0[w] != ~p1[w] ) + return 0; + return 1; + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Caig_ManCompareConst( unsigned * p, int nWords ) +{ + int w; + if ( p[0] & 1 ) + { + for ( w = 0; w < nWords; w++ ) + if ( p[w] != ~0 ) + return 0; + return 1; + } + else + { + for ( w = 0; w < nWords; w++ ) + if ( p[w] != 0 ) + return 0; + return 1; + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManClassCreate( Caig_Man_t * p, Vec_Int_t * vClass ) +{ + int * pNext, Repr, Ent, i; + assert( Vec_IntSize(vClass) > 0 ); + Vec_IntForEachEntry( vClass, Ent, i ) + { + if ( i == 0 ) + { + Repr = Ent; + p->pReprs[Ent] = -1; + pNext = p->pNexts + Ent; + } + else + { + p->pReprs[Ent] = Repr; + *pNext = Ent; + pNext = p->pNexts + Ent; + } + } + *pNext = 0; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims ) +{ + unsigned * pSim0, * pSim1; + int Ent, c = 0, d = 0; + Vec_IntClear( p->vClassOld ); + Vec_IntClear( p->vClassNew ); + pSim0 = Vec_PtrEntry( vSims, c++ ); + Vec_IntPush( p->vClassOld, i ); + for ( Ent = p->pNexts[i]; Ent; Ent = p->pNexts[Ent] ) + { + pSim1 = Vec_PtrEntry( vSims, c++ ); + if ( Caig_ManCompareEqual( pSim0, pSim1, p->nWords ) ) + Vec_IntPush( p->vClassOld, Ent ); + else + { + Vec_IntPush( p->vClassNew, Ent ); + Vec_PtrWriteEntry( vSims, d++, pSim1 ); + } + } +//if ( Vec_PtrSize(vSims) > 100 ) +//printf( "%d -> %d %d \n", Vec_PtrSize(vSims), Vec_IntSize(p->vClassOld), Vec_IntSize(p->vClassNew) ); + Vec_PtrShrink( vSims, d ); + if ( Vec_IntSize(p->vClassNew) == 0 ) + return 0; + Caig_ManClassCreate( p, p->vClassOld ); + Caig_ManClassCreate( p, p->vClassNew ); + if ( Vec_IntSize(p->vClassNew) > 1 ) + return 1 + Caig_ManClassRefineOne( p, Vec_IntEntry(p->vClassNew,0), vSims ); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Caig_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 [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManClassesCreate( Caig_Man_t * p ) +{ + int * pTable, nTableSize, i, Key; + nTableSize = Aig_PrimeCudd( 100 + p->nObjs / 10 ); + pTable = ABC_CALLOC( int, nTableSize ); + p->pReprs = ABC_ALLOC( int, p->nObjs ); + p->pNexts = ABC_CALLOC( int, p->nObjs ); + for ( i = 1; i < p->nObjs; i++ ) + { + if ( p->pFans0[i] > 0 && p->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin + continue; + if ( Caig_ManCompareConst( p->pSims + i, 1 ) ) + { + p->pReprs[i] = 0; + continue; + } + Key = Caig_ManHashKey( p->pSims + i, 1, nTableSize ); + if ( pTable[Key] == 0 ) + p->pReprs[i] = -1; + else + { + p->pNexts[ pTable[Key] ] = i; + p->pReprs[i] = p->pReprs[ pTable[Key] ]; + if ( p->pReprs[i] == -1 ) + p->pReprs[i] = pTable[Key]; + } + pTable[Key] = i; + } + ABC_FREE( pTable ); +Caig_ManPrintClasses( p, 0 ); + // refine classes + for ( i = 1; i < p->nObjs; i++ ) + if ( p->pReprs[i] < 0 && p->pNexts[i] > 0 ) + { + Caig_ManCollectSimsSimple( p, i ); + Caig_ManClassRefineOne( p, i, p->vSims ); + } + // clean memory + memset( p->pSims, 0, sizeof(unsigned) * p->nObjs ); +Caig_ManPrintClasses( p, 0 ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManSimulateSimple( Caig_Man_t * p ) +{ + unsigned Res0, Res1; + int i; + for ( i = 1; i < p->nObjs; i++ ) + { + if ( p->pFans0[i] == -1 ) // pi + { + p->pSims[i] = Aig_ManRandom( 0 ); + continue; + } + if ( p->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin + continue; + Res0 = p->pSims[Cec_Lit2Var(p->pFans0[i])]; + Res1 = p->pSims[Cec_Lit2Var(p->pFans1[i])]; + p->pSims[i] = (Cec_LitIsCompl(p->pFans0[i]) ? ~Res0: Res0) & + (Cec_LitIsCompl(p->pFans1[i]) ? ~Res1: Res1); + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined ) +{ + Vec_Int_t * vClasses; + int * pTable, nTableSize, i, Key, iNode; + unsigned * pSim; + if ( Vec_IntSize(vRefined) == 0 ) + return; + nTableSize = Aig_PrimeCudd( 100 + Vec_IntSize(vRefined) / 5 ); + pTable = ABC_CALLOC( int, nTableSize ); + vClasses = Vec_IntAlloc( 100 ); + Vec_IntForEachEntry( vRefined, iNode, i ) + { + pSim = Caig_ManSimRead( p, iNode ); + assert( !Caig_ManCompareConst( pSim + 1, p->nWords ) ); + Key = Caig_ManHashKey( pSim + 1, p->nWords, nTableSize ); + if ( pTable[Key] == 0 ) + { + assert( p->pReprs[iNode] == 0 ); + assert( p->pNexts[iNode] == 0 ); + p->pReprs[iNode] = -1; + Vec_IntPush( vClasses, iNode ); + } + else + { + p->pNexts[ pTable[Key] ] = iNode; + p->pReprs[iNode] = p->pReprs[ pTable[Key] ]; + if ( p->pReprs[iNode] == -1 ) + p->pReprs[iNode] = pTable[Key]; + assert( p->pReprs[iNode] > 0 ); + } + pTable[Key] = iNode; + } + ABC_FREE( pTable ); + // refine classes + Vec_IntForEachEntry( vClasses, iNode, i ) + { + if ( p->pNexts[iNode] == 0 ) + { + Caig_ManSimDeref( p, iNode ); + continue; + } + Caig_ManCollectSimsNormal( p, iNode ); + Caig_ManClassRefineOne( p, iNode, p->vSims ); + } + Vec_IntFree( vClasses ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters ) +{ + Vec_Ptr_t * vInfo; + Caig_Man_t * p; + int i; + Aig_ManRandom( 1 ); + p = Caig_ManCreate( pAig ); + p->nWords = 1; + Caig_ManSimulateSimple( p ); + Caig_ManClassesCreate( p ); + p->nWords = nWords; + for ( i = 0; i < nIters; i++ ) + { + p->nWords = i + 1; + Caig_ManSimMemRelink( p ); + p->nMemsMax = 0; + + vInfo = Vec_PtrAllocSimInfo( p->nPis, p->nWords ); + Aig_ManRandomInfo( vInfo, 0, p->nWords ); + Caig_ManSimulateRound( p, vInfo, NULL ); + Vec_PtrFree( vInfo ); +Caig_ManPrintClasses( p, 0 ); + } + + p->nWords = nWords; + Caig_ManSimMemRelink( p ); + p->nMemsMax = 0; + return p; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecCnf.c b/src/aig/cec2/cecCnf.c new file mode 100644 index 00000000..706b15e0 --- /dev/null +++ b/src/aig/cec2/cecCnf.c @@ -0,0 +1,328 @@ +/**CFile**************************************************************** + + FileName [cecCnf.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [CNF computation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecCnf.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Addes clauses to the solver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_AddClausesMux( Cec_ManSat_t * p, Aig_Obj_t * pNode ) +{ + Aig_Obj_t * pNodeI, * pNodeT, * pNodeE; + int pLits[4], RetValue, VarF, VarI, VarT, VarE, fCompT, fCompE; + + assert( !Aig_IsComplement( pNode ) ); + assert( Aig_ObjIsMuxType( pNode ) ); + // get nodes (I = if, T = then, E = else) + pNodeI = Aig_ObjRecognizeMux( pNode, &pNodeT, &pNodeE ); + // get the variable numbers + VarF = Cec_ObjSatNum(p,pNode); + VarI = Cec_ObjSatNum(p,pNodeI); + VarT = Cec_ObjSatNum(p,Aig_Regular(pNodeT)); + VarE = Cec_ObjSatNum(p,Aig_Regular(pNodeE)); + // get the complementation flags + fCompT = Aig_IsComplement(pNodeT); + fCompE = Aig_IsComplement(pNodeE); + + // f = ITE(i, t, e) + + // i' + t' + f + // i' + t + f' + // i + e' + f + // i + e + f' + + // create four clauses + pLits[0] = toLitCond(VarI, 1); + pLits[1] = toLitCond(VarT, 1^fCompT); + pLits[2] = toLitCond(VarF, 0); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Aig_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarI, 1); + pLits[1] = toLitCond(VarT, 0^fCompT); + pLits[2] = toLitCond(VarF, 1); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Aig_Regular(pNodeT)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarI, 0); + pLits[1] = toLitCond(VarE, 1^fCompE); + pLits[2] = toLitCond(VarF, 0); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarI, 0); + pLits[1] = toLitCond(VarE, 0^fCompE); + pLits[2] = toLitCond(VarF, 1); + if ( p->pPars->fPolarFlip ) + { + if ( pNodeI->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + + // two additional clauses + // t' & e' -> f' + // t & e -> f + + // t + e + f' + // t' + e' + f + + if ( VarT == VarE ) + { +// assert( fCompT == !fCompE ); + return; + } + + pLits[0] = toLitCond(VarT, 0^fCompT); + pLits[1] = toLitCond(VarE, 0^fCompE); + pLits[2] = toLitCond(VarF, 1); + if ( p->pPars->fPolarFlip ) + { + if ( Aig_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); + pLits[0] = toLitCond(VarT, 1^fCompT); + pLits[1] = toLitCond(VarE, 1^fCompE); + pLits[2] = toLitCond(VarF, 0); + if ( p->pPars->fPolarFlip ) + { + if ( Aig_Regular(pNodeT)->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( Aig_Regular(pNodeE)->fPhase ) pLits[1] = lit_neg( pLits[1] ); + if ( pNode->fPhase ) pLits[2] = lit_neg( pLits[2] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 ); + assert( RetValue ); +} + +/**Function************************************************************* + + Synopsis [Addes clauses to the solver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_AddClausesSuper( Cec_ManSat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) +{ + Aig_Obj_t * pFanin; + int * pLits, nLits, RetValue, i; + assert( !Aig_IsComplement(pNode) ); + assert( Aig_ObjIsNode( pNode ) ); + // create storage for literals + nLits = Vec_PtrSize(vSuper) + 1; + pLits = ABC_ALLOC( int, nLits ); + // suppose AND-gate is A & B = C + // add !A => !C or A + !C + Vec_PtrForEachEntry( vSuper, pFanin, i ) + { + pLits[0] = toLitCond(Cec_ObjSatNum(p,Aig_Regular(pFanin)), Aig_IsComplement(pFanin)); + pLits[1] = toLitCond(Cec_ObjSatNum(p,pNode), 1); + if ( p->pPars->fPolarFlip ) + { + if ( Aig_Regular(pFanin)->fPhase ) pLits[0] = lit_neg( pLits[0] ); + if ( pNode->fPhase ) pLits[1] = lit_neg( pLits[1] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 ); + assert( RetValue ); + } + // add A & B => C or !A + !B + C + Vec_PtrForEachEntry( vSuper, pFanin, i ) + { + pLits[i] = toLitCond(Cec_ObjSatNum(p,Aig_Regular(pFanin)), !Aig_IsComplement(pFanin)); + if ( p->pPars->fPolarFlip ) + { + if ( Aig_Regular(pFanin)->fPhase ) pLits[i] = lit_neg( pLits[i] ); + } + } + pLits[nLits-1] = toLitCond(Cec_ObjSatNum(p,pNode), 0); + if ( p->pPars->fPolarFlip ) + { + if ( pNode->fPhase ) pLits[nLits-1] = lit_neg( pLits[nLits-1] ); + } + RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits ); + assert( RetValue ); + ABC_FREE( pLits ); +} + +/**Function************************************************************* + + Synopsis [Collects the supergate.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_CollectSuper_rec( Aig_Obj_t * pObj, Vec_Ptr_t * vSuper, int fFirst, int fUseMuxes ) +{ + // if the new node is complemented or a PI, another gate begins + if ( Aig_IsComplement(pObj) || Aig_ObjIsPi(pObj) || + (!fFirst && Aig_ObjRefs(pObj) > 1) || + (fUseMuxes && Aig_ObjIsMuxType(pObj)) ) + { + Vec_PtrPushUnique( vSuper, pObj ); + return; + } + // go through the branches + Cec_CollectSuper_rec( Aig_ObjChild0(pObj), vSuper, 0, fUseMuxes ); + Cec_CollectSuper_rec( Aig_ObjChild1(pObj), vSuper, 0, fUseMuxes ); +} + +/**Function************************************************************* + + Synopsis [Collects the supergate.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_CollectSuper( Aig_Obj_t * pObj, int fUseMuxes, Vec_Ptr_t * vSuper ) +{ + assert( !Aig_IsComplement(pObj) ); + assert( !Aig_ObjIsPi(pObj) ); + Vec_PtrClear( vSuper ); + Cec_CollectSuper_rec( pObj, vSuper, 1, fUseMuxes ); +} + +/**Function************************************************************* + + Synopsis [Updates the solver clause database.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ObjAddToFrontier( Cec_ManSat_t * p, Aig_Obj_t * pObj, Vec_Ptr_t * vFrontier ) +{ + assert( !Aig_IsComplement(pObj) ); + if ( Cec_ObjSatNum(p,pObj) ) + return; + assert( Cec_ObjSatNum(p,pObj) == 0 ); + if ( Aig_ObjIsConst1(pObj) ) + return; + Vec_PtrPush( p->vUsedNodes, pObj ); + Cec_ObjSetSatNum( p, pObj, p->nSatVars++ ); + if ( Aig_ObjIsNode(pObj) ) + Vec_PtrPush( vFrontier, pObj ); +} + +/**Function************************************************************* + + Synopsis [Updates the solver clause database.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Aig_Obj_t * pObj ) +{ + Vec_Ptr_t * vFrontier; + Aig_Obj_t * pNode, * pFanin; + int i, k, fUseMuxes = 1; + // quit if CNF is ready + if ( Cec_ObjSatNum(p,pObj) ) + return; + // start the frontier + vFrontier = Vec_PtrAlloc( 100 ); + Cec_ObjAddToFrontier( p, pObj, vFrontier ); + // explore nodes in the frontier + Vec_PtrForEachEntry( vFrontier, pNode, i ) + { + // create the supergate + assert( Cec_ObjSatNum(p,pNode) ); + if ( fUseMuxes && Aig_ObjIsMuxType(pNode) ) + { + Vec_PtrClear( p->vFanins ); + Vec_PtrPushUnique( p->vFanins, Aig_ObjFanin0( Aig_ObjFanin0(pNode) ) ); + 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 ) + Cec_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier ); + Cec_AddClausesMux( p, pNode ); + } + else + { + Cec_CollectSuper( pNode, fUseMuxes, p->vFanins ); + Vec_PtrForEachEntry( p->vFanins, pFanin, k ) + Cec_ObjAddToFrontier( p, Aig_Regular(pFanin), vFrontier ); + Cec_AddClausesSuper( p, pNode, p->vFanins ); + } + assert( Vec_PtrSize(p->vFanins) > 1 ); + } + Vec_PtrFree( vFrontier ); +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecCore.c b/src/aig/cec2/cecCore.c new file mode 100644 index 00000000..540a3951 --- /dev/null +++ b/src/aig/cec2/cecCore.c @@ -0,0 +1,245 @@ +/**CFile**************************************************************** + + FileName [cecCore.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [Core procedures.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecCore.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [This procedure sets default parameters.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatSetDefaultParams( Cec_ParSat_t * p ) +{ + memset( p, 0, sizeof(Cec_ParSat_t) ); + p->nBTLimit = 10; // conflict limit at a node + p->nSatVarMax = 2000; // the max number of SAT variables + p->nCallsRecycle = 100; // calls to perform before recycling SAT solver + p->fFirstStop = 0; // stop on the first sat output + p->fPolarFlip = 0; // uses polarity adjustment + p->fVerbose = 0; // verbose stats +} + +/**Function************************************************************* + + Synopsis [This procedure sets default parameters.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManCswSetDefaultParams( Cec_ParCsw_t * p ) +{ + memset( p, 0, sizeof(Cec_ParCsw_t) ); + p->nWords = 10; // the number of simulation words + p->nRounds = 10; // the number of simulation rounds + p->nBTLimit = 10; // conflict limit at a node + p->nSatVarMax = 2000; // the max number of SAT variables + p->nCallsRecycle = 100; // calls to perform before recycling SAT solver + p->nLevelMax = 50; // restriction on the level of nodes to be swept + p->fRewriting = 0; // enables AIG rewriting + p->fFirstStop = 0; // stop on the first sat output + p->fVerbose = 1; // verbose stats +} + +/**Function************************************************************* + + Synopsis [This procedure sets default parameters.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManCecSetDefaultParams( Cec_ParCec_t * p ) +{ + memset( p, 0, sizeof(Cec_ParCec_t) ); + p->nIters = 1; // iterations of SAT solving/sweeping + p->nBTLimitBeg = 2; // starting backtrack limit + p->nBTlimitMulti = 8; // multiple of backtrack limiter + p->fUseSmartCnf = 0; // use smart CNF computation + p->fRewriting = 0; // enables AIG rewriting + p->fSatSweeping = 0; // enables SAT sweeping + p->fFirstStop = 0; // stop on the first sat output + p->fVerbose = 1; // verbose stats +} + + +/**Function************************************************************* + + Synopsis [Performs equivalence checking.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_Sweep( Aig_Man_t * pAig, int nBTLimit ) +{ + extern void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int fCompact ); +// Cec_MtrStatus_t Status; + Cec_ParCsw_t ParsCsw, * pParsCsw = &ParsCsw; + Cec_ParSat_t ParsSat, * pParsSat = &ParsSat; + Caig_Man_t * pCaig; + Aig_Man_t * pSRAig; +// int clk; + + Cec_ManCswSetDefaultParams( pParsCsw ); + pParsCsw->nBTLimit = nBTLimit; + pCaig = Caig_ManClassesPrepare( pAig, pParsCsw->nWords, pParsCsw->nRounds ); + + pSRAig = Caig_ManSpecReduce( pCaig, 20 ); + Aig_ManPrintStats( pSRAig ); + Ioa_WriteAiger( pSRAig, "temp_srm.aig", 0, 1 ); + +/* + Cec_ManSatSetDefaultParams( pParsSat ); + pParsSat->fFirstStop = 0; + pParsSat->nBTLimit = pParsCsw->nBTlimit; +clk = clock(); + Status = Cec_SatSolveOutputs( pSRAig, pParsSat ); + Cec_MiterStatusPrint( Status, "SRM ", clock() - clk ); +*/ + + Aig_ManStop( pSRAig ); + + Caig_ManDelete( pCaig ); + + return 1; +} + +/**Function************************************************************* + + Synopsis [Performs equivalence checking.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_Solve( Aig_Man_t * pAig0, Aig_Man_t * pAig1, Cec_ParCec_t * pPars ) +{ + Cec_ParSat_t ParsSat, * pParsSat = &ParsSat; + Cec_ParCsw_t ParsCsw, * pParsCsw = &ParsCsw; + Cec_MtrStatus_t Status; + Caig_Man_t * pCaig; + Aig_Man_t * pMiter; + int i, clk = clock(); + if ( pPars->fVerbose ) + { + Status = Cec_MiterStatusTrivial( pAig0 ); + Status.nNodes += pAig1? Aig_ManNodeNum( pAig1 ) : 0; + Cec_MiterStatusPrint( Status, "Init ", 0 ); + } + // create combinational miter + if ( pAig1 == NULL ) + { + Status = Cec_MiterStatus( pAig0 ); + if ( Status.nSat > 0 && pPars->fFirstStop ) + { + if ( pPars->fVerbose ) + printf( "Output %d is trivially SAT.\n", Status.iOut ); + return 0; + } + if ( Status.nUndec == 0 ) + { + if ( pPars->fVerbose ) + printf( "The miter has no undecided outputs.\n" ); + return 1; + } + pMiter = Cec_Duplicate( pAig0 ); + } + else + { + pMiter = Cec_DeriveMiter( pAig0, pAig1 ); + Status = Cec_MiterStatus( pMiter ); + if ( Status.nSat > 0 && pPars->fFirstStop ) + { + if ( pPars->fVerbose ) + printf( "Output %d is trivially SAT.\n", Status.iOut ); + Aig_ManStop( pMiter ); + return 0; + } + if ( Status.nUndec == 0 ) + { + if ( pPars->fVerbose ) + printf( "The problem is solved by structrual hashing.\n" ); + Aig_ManStop( pMiter ); + return 1; + } + } + if ( pPars->fVerbose ) + Cec_MiterStatusPrint( Status, "Strash", clock() - clk ); + // start parameter structures +// Cec_ManSatSetDefaultParams( pParsSat ); +// pParsSat->fFirstStop = pPars->fFirstStop; +// pParsSat->nBTLimit = pPars->nBTLimitBeg; +/* + // try SAT solving + clk = clock(); + pParsSat->nBTLimit *= pPars->nBTlimitMulti; + Status = Cec_SatSolveOutputs( pMiter, pParsSat ); + if ( pPars->fVerbose ) + Cec_MiterStatusPrint( Status, "SAT ", clock() - clk ); + if ( Status.nSat && pParsSat->fFirstStop ) + break; + if ( Status.nUndec == 0 ) + break; +*/ + + Cec_ManCswSetDefaultParams( pParsCsw ); + pCaig = Caig_ManClassesPrepare( pMiter, pParsCsw->nWords, pParsCsw->nRounds ); + for ( i = 0; i < pPars->nIters; i++ ) + { + Cec_ManSatSweepInt( pCaig, pParsCsw ); + i = i; + } + Caig_ManDelete( pCaig ); + Aig_ManStop( pMiter ); + return 1; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecInt.h b/src/aig/cec2/cecInt.h new file mode 100644 index 00000000..ef43e44c --- /dev/null +++ b/src/aig/cec2/cecInt.h @@ -0,0 +1,208 @@ +/**CFile**************************************************************** + + FileName [cecInt.h] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [External declarations.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#ifndef __CEC_INT_H__ +#define __CEC_INT_H__ + +//////////////////////////////////////////////////////////////////////// +/// INCLUDES /// +//////////////////////////////////////////////////////////////////////// + +#include "aig.h" +#include "satSolver.h" +#include "bar.h" +#include "cec.h" + +//////////////////////////////////////////////////////////////////////// +/// PARAMETERS /// +//////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////////////////////////////////////// +/// BASIC TYPES /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Cec_ManSat_t_ Cec_ManSat_t; +struct Cec_ManSat_t_ +{ + // parameters + Cec_ParSat_t * pPars; + // AIGs used in the package + Aig_Man_t * pAig; // the AIG whose outputs are considered + Vec_Int_t * vStatus; // status for each output + // SAT solving + sat_solver * pSat; // recyclable SAT solver + int nSatVars; // the counter of SAT variables + int * pSatVars; // mapping of each node into its SAT var + Vec_Ptr_t * vUsedNodes; // nodes whose SAT vars are assigned + int nRecycles; // the number of times SAT solver was recycled + int nCallsSince; // the number of calls since the last recycle + Vec_Ptr_t * vFanins; // fanins of the CNF node + // SAT calls statistics + int nSatUnsat; // the number of proofs + int nSatSat; // the number of failure + int nSatUndec; // the number of timeouts + // runtime stats + int timeSatUnsat; // unsat + int timeSatSat; // sat + int timeSatUndec; // undecided + int timeTotal; // total runtime +}; + +typedef struct Cec_ManCec_t_ Cec_ManCec_t; +struct Cec_ManCec_t_ +{ + // parameters + Cec_ParCec_t * pPars; + // AIGs used in the package + Aig_Man_t * pAig; // the miter for equivalence checking + // mapping of PI/PO nodes + + // counter-example + int * pCex; // counter-example + int iOutput; // the output for this counter-example + + // statistics + +}; + +typedef struct Cec_MtrStatus_t_ Cec_MtrStatus_t; +struct Cec_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 +}; + +// combinational simulation manager +typedef struct Caig_Man_t_ Caig_Man_t; +struct Caig_Man_t_ +{ + // parameters + Aig_Man_t * pAig; // the AIG to be used for simulation + int nWords; // the number of simulation words + // AIG representation + int nPis; // the number of primary inputs + int nPos; // the number of primary outputs + int nNodes; // the number of internal nodes + int nObjs; // nPis + nNodes + nPos + 1 + int * pFans0; // fanin0 for all objects + int * pFans1; // fanin1 for all objects + // simulation info + int * pRefs; // reference counter for each node + unsigned * pSims; // simlulation information for each node + // recycable memory + unsigned * pMems; // allocated simulaton memory + 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 + // equivalence class representation + int * pReprs; // representatives of each node + int * pNexts; // nexts for each node + // temporaries + Vec_Ptr_t * vSims; // pointers to sim info + Vec_Int_t * vClassOld; // old class numbers + Vec_Int_t * vClassNew; // new class numbers + Vec_Int_t * vRefinedC; // refined const reprs +}; + +//////////////////////////////////////////////////////////////////////// +/// MACRO DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +static inline int Cec_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; } +static inline int Cec_Lit2Var( int Lit ) { return Lit >> 1; } +static inline int Cec_LitIsCompl( int Lit ) { return Lit & 1; } +static inline int Cec_LitNot( int Lit ) { return Lit ^ 1; } +static inline int Cec_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); } +static inline int Cec_LitRegular( int Lit ) { return Lit & ~01; } + +static inline int Cec_ObjSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj ) { return p->pSatVars[pObj->Id]; } +static inline void Cec_ObjSetSatNum( Cec_ManSat_t * p, Aig_Obj_t * pObj, int Num ) { p->pSatVars[pObj->Id] = Num; } + +static inline Aig_Obj_t * Cec_ObjFraig( Aig_Obj_t * pObj ) { return pObj->pData; } +static inline void Cec_ObjSetFraig( Aig_Obj_t * pObj, Aig_Obj_t * pNode ) { pObj->pData = pNode; } + +static inline int Cec_ObjIsConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj ) +{ + return Aig_ObjRepr(pAig, pObj) == Aig_ManConst1(pAig); +} +static inline void Cec_ObjSetConst1Cand( Aig_Man_t * pAig, Aig_Obj_t * pObj ) +{ + assert( !Cec_ObjIsConst1Cand( pAig, pObj ) ); + Aig_ObjSetRepr( pAig, pObj, Aig_ManConst1(pAig) ); +} + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +/*=== cecAig.c ==========================================================*/ +extern Aig_Man_t * Cec_Duplicate( Aig_Man_t * p ); +extern Aig_Man_t * Cec_DeriveMiter( Aig_Man_t * p0, Aig_Man_t * p1 ); +/*=== cecClass.c ==========================================================*/ +extern Aig_Man_t * Caig_ManSpecReduce( Caig_Man_t * p, int nLevels ); +extern int Caig_ManCompareEqual( unsigned * p0, unsigned * p1, int nWords ); +extern int Caig_ManCompareConst( unsigned * p, int nWords ); +extern void Caig_ManCollectSimsNormal( Caig_Man_t * p, int i ); +extern int Caig_ManClassRefineOne( Caig_Man_t * p, int i, Vec_Ptr_t * vSims ); +extern void Caig_ManProcessRefined( Caig_Man_t * p, Vec_Int_t * vRefined ); +extern void Caig_ManPrintClasses( Caig_Man_t * p, int fVerbose ); +extern Caig_Man_t * Caig_ManClassesPrepare( Aig_Man_t * pAig, int nWords, int nIters ); +/*=== cecCnf.c ==========================================================*/ +extern void Cec_CnfNodeAddToSolver( Cec_ManSat_t * p, Aig_Obj_t * pObj ); +/*=== cecSat.c ==========================================================*/ +extern Cec_MtrStatus_t Cec_SatSolveOutputs( Aig_Man_t * pAig, Cec_ParSat_t * pPars ); +/*=== cecSim.c ==========================================================*/ +extern Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig ); +extern void Caig_ManDelete( Caig_Man_t * p ); +extern void Caig_ManSimMemRelink( Caig_Man_t * p ); +extern unsigned * Caig_ManSimRead( Caig_Man_t * p, int i ); +extern unsigned * Caig_ManSimRef( Caig_Man_t * p, int i ); +extern unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i ); +extern void Caig_ManSimulateRound( Caig_Man_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * vInfoCos ); +extern int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose ); +/*=== cecStatus.c ==========================================================*/ +extern int Cec_OutputStatus( Aig_Man_t * p, Aig_Obj_t * pObj ); +extern Cec_MtrStatus_t Cec_MiterStatus( Aig_Man_t * p ); +extern Cec_MtrStatus_t Cec_MiterStatusTrivial( Aig_Man_t * p ); +extern void Cec_MiterStatusPrint( Cec_MtrStatus_t S, char * pString, int Time ); +/*=== cecSweep.c ==========================================================*/ +extern void Cec_ManSatSweepInt( Caig_Man_t * pMan, Cec_ParCsw_t * pPars ); +extern Aig_Man_t * Cec_ManSatSweep( Aig_Man_t * pAig, Cec_ParCsw_t * pPars ); + +#ifdef __cplusplus +} +#endif + +#endif + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + diff --git a/src/aig/cec2/cecMan.c b/src/aig/cec2/cecMan.c new file mode 100644 index 00000000..86415c53 --- /dev/null +++ b/src/aig/cec2/cecMan.c @@ -0,0 +1,59 @@ +/**CFile**************************************************************** + + FileName [cecMan.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [Manager pcocures.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecSat.c b/src/aig/cec2/cecSat.c new file mode 100644 index 00000000..a999dd97 --- /dev/null +++ b/src/aig/cec2/cecSat.c @@ -0,0 +1,250 @@ +/**CFile**************************************************************** + + FileName [cecSat.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [SAT solver calls.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Creates the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cec_ManSat_t * Cec_ManCreate( Aig_Man_t * pAig, Cec_ParSat_t * pPars ) +{ + Cec_ManSat_t * p; + // create interpolation manager + p = ABC_ALLOC( Cec_ManSat_t, 1 ); + memset( p, 0, sizeof(Cec_ManSat_t) ); + p->pPars = pPars; + p->pAig = pAig; + // SAT solving + p->nSatVars = 1; + p->pSatVars = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) ); + p->vUsedNodes = Vec_PtrAlloc( 1000 ); + p->vFanins = Vec_PtrAlloc( 100 ); + return p; +} + +/**Function************************************************************* + + Synopsis [Frees the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManStop( Cec_ManSat_t * p ) +{ + if ( p->pSat ) + sat_solver_delete( p->pSat ); + Vec_PtrFree( p->vUsedNodes ); + Vec_PtrFree( p->vFanins ); + ABC_FREE( p->pSatVars ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [Recycles the SAT solver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatSolverRecycle( Cec_ManSat_t * p ) +{ + int Lit; + if ( p->pSat ) + { + Aig_Obj_t * pObj; + int i; + Vec_PtrForEachEntry( p->vUsedNodes, pObj, i ) + Cec_ObjSetSatNum( p, pObj, 0 ); + Vec_PtrClear( p->vUsedNodes ); +// memset( p->pSatVars, 0, sizeof(int) * Aig_ManObjNumMax(p->pAigTotal) ); + sat_solver_delete( p->pSat ); + } + p->pSat = sat_solver_new(); + sat_solver_setnvars( p->pSat, 1000 ); + // var 0 is not used + // var 1 is reserved for const1 node - add the clause + p->nSatVars = 1; +// p->nSatVars = 0; + Lit = toLit( p->nSatVars ); + if ( p->pPars->fPolarFlip ) + Lit = lit_neg( Lit ); + sat_solver_addclause( p->pSat, &Lit, &Lit + 1 ); + Cec_ObjSetSatNum( p, Aig_ManConst1(p->pAig), p->nSatVars++ ); + + p->nRecycles++; + p->nCallsSince = 0; +} + +/**Function************************************************************* + + Synopsis [Runs equivalence test for the two nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManSatCheckNode( Cec_ManSat_t * p, Aig_Obj_t * pNode ) +{ + int nBTLimit = p->pPars->nBTLimit; + int Lit, RetValue, status, clk; + + // sanity checks + assert( !Aig_IsComplement(pNode) ); + + p->nCallsSince++; // experiment with this!!! + + // check if SAT solver needs recycling + if ( p->pSat == NULL || + (p->pPars->nSatVarMax && + p->nSatVars > p->pPars->nSatVarMax && + p->nCallsSince > p->pPars->nCallsRecycle) ) + Cec_ManSatSolverRecycle( p ); + + // if the nodes do not have SAT variables, allocate them + Cec_CnfNodeAddToSolver( p, pNode ); + + // propage unit clauses + if ( p->pSat->qtail != p->pSat->qhead ) + { + status = sat_solver_simplify(p->pSat); + assert( status != 0 ); + assert( p->pSat->qtail == p->pSat->qhead ); + } + + // solve under assumptions + // A = 1; B = 0 OR A = 1; B = 1 + Lit = toLitCond( Cec_ObjSatNum(p,pNode), pNode->fPhase ); + if ( p->pPars->fPolarFlip ) + { + if ( pNode->fPhase ) Lit = lit_neg( Lit ); + } +//Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); +clk = clock(); + RetValue = sat_solver_solve( p->pSat, &Lit, &Lit + 1, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); + if ( RetValue == l_False ) + { +p->timeSatUnsat += clock() - clk; + Lit = lit_neg( Lit ); + RetValue = sat_solver_addclause( p->pSat, &Lit, &Lit + 1 ); + assert( RetValue ); + p->timeSatUnsat++; + return 1; + } + else if ( RetValue == l_True ) + { +p->timeSatSat += clock() - clk; + p->timeSatSat++; + return 0; + } + else // if ( RetValue == l_Undef ) + { +p->timeSatUndec += clock() - clk; + p->timeSatUndec++; + return -1; + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cec_MtrStatus_t Cec_SatSolveOutputs( Aig_Man_t * pAig, Cec_ParSat_t * pPars ) +{ + Bar_Progress_t * pProgress = NULL; + Cec_MtrStatus_t Status; + Cec_ManSat_t * p; + Aig_Obj_t * pObj; + int i, status; + Status = Cec_MiterStatus( pAig ); + p = Cec_ManCreate( pAig, pPars ); + pProgress = Bar_ProgressStart( stdout, Aig_ManPoNum(pAig) ); + Aig_ManForEachPo( pAig, pObj, i ) + { + Bar_ProgressUpdate( pProgress, i, "SAT..." ); + if ( Cec_OutputStatus(pAig, pObj) ) + continue; + status = Cec_ManSatCheckNode( p, Aig_ObjFanin0(pObj) ); + if ( status == 1 ) + { + Status.nUndec--, Status.nUnsat++; + Aig_ObjPatchFanin0( pAig, pObj, Aig_ManConst0(pAig) ); + } + if ( status == 0 ) + { + Status.nUndec--, Status.nSat++; + Aig_ObjPatchFanin0( pAig, pObj, Aig_ManConst1(pAig) ); + } + if ( status == -1 ) + continue; + // save the pattern (if it is first) + if ( Status.iOut == -1 ) + { + } + // quit if at least one of them is solved + if ( status == 0 && pPars->fFirstStop ) + break; + } + Aig_ManCleanup( pAig ); + Bar_ProgressStop( pProgress ); + printf( " Confs = %8d. Recycles = %6d.\n", p->pPars->nBTLimit, p->nRecycles ); + Cec_ManStop( p ); + return Status; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecSat2.c b/src/aig/cec2/cecSat2.c new file mode 100644 index 00000000..4f009b25 --- /dev/null +++ b/src/aig/cec2/cecSat2.c @@ -0,0 +1,284 @@ +/**CFile**************************************************************** + + FileName [cecSat.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinational equivalence checking.] + + Synopsis [Backend calling the SAT solver.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 30, 2007.] + + Revision [$Id: cecSat.c,v 1.00 2007/06/30 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "aig.h" +#include "cnf.h" +#include "../../sat/lsat/solver.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Writes CNF into a file.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +solver * Cnf_WriteIntoSolverNew( Cnf_Dat_t * p ) +{ + solver * pSat; + int i, status; + pSat = solver_new(); + for ( i = 0; i < p->nVars; i++ ) + solver_newVar( pSat ); + for ( i = 0; i < p->nClauses; i++ ) + { + if ( !solver_addClause( pSat, p->pClauses[i+1]-p->pClauses[i], p->pClauses[i] ) ) + { + solver_delete( pSat ); + return NULL; + } + } + status = solver_simplify(pSat); + if ( status == 0 ) + { + solver_delete( pSat ); + return NULL; + } + return pSat; +} + +/**Function************************************************************* + + Synopsis [Adds the OR-clause.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cnf_DataWriteAndClausesNew( void * p, Cnf_Dat_t * pCnf ) +{ +/* + sat_solver * pSat = p; + Aig_Obj_t * pObj; + int i, Lit; + Aig_ManForEachPo( pCnf->pMan, pObj, i ) + { + Lit = toLitCond( pCnf->pVarNums[pObj->Id], 0 ); + if ( !sat_solver_addclause( pSat, &Lit, &Lit+1 ) ) + return 0; + } +*/ + return 1; +} + +/**Function************************************************************* + + Synopsis [Adds the OR-clause.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cnf_DataWriteOrClauseNew( solver * pSat, Cnf_Dat_t * pCnf ) +{ + Aig_Obj_t * pObj; + int i, * pLits; + pLits = ALLOC( int, Aig_ManPoNum(pCnf->pMan) ); + Aig_ManForEachPo( pCnf->pMan, pObj, i ) + pLits[i] = solver_mkLit_args( pCnf->pVarNums[pObj->Id], 0 ); + if ( !solver_addClause( pSat, Aig_ManPoNum(pCnf->pMan), pLits ) ) + { + free( pLits ); + return 0; + } + free( pLits ); + return 1; +} + +/**Function************************************************************* + + Synopsis [Writes the given clause in a file in DIMACS format.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Sat_SolverPrintStatsNew( FILE * pFile, solver * pSat ) +{ +// printf( "starts : %8d\n", solver_num_assigns(pSat) ); + printf( "vars : %8d\n", solver_num_vars(pSat) ); + printf( "clauses : %8d\n", solver_num_clauses(pSat) ); + printf( "conflicts : %8d\n", solver_num_learnts(pSat) ); +} + +/**Function************************************************************* + + Synopsis [Returns a counter-example.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int * Sat_SolverGetModelNew( solver * pSat, int * pVars, int nVars ) +{ + int * pModel; + int i; + pModel = ALLOC( int, nVars+1 ); + for ( i = 0; i < nVars; i++ ) + { + assert( pVars[i] >= 0 && pVars[i] < solver_num_vars(pSat) ); + pModel[i] = (int)(solver_modelValue_Var( pSat, pVars[i] ) == solver_l_True); + } + return pModel; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_RunSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFlipBits, int fAndOuts, int fVerbose ) +{ + solver * pSat; + Cnf_Dat_t * pCnf; + int status, RetValue, clk = clock(); + Vec_Int_t * vCiIds; + + assert( Aig_ManRegNum(pMan) == 0 ); + pMan->pData = NULL; + + // derive CNF + pCnf = Cnf_Derive( pMan, Aig_ManPoNum(pMan) ); +// pCnf = Cnf_DeriveSimple( pMan, Aig_ManPoNum(pMan) ); + + // convert into SAT solver + pSat = Cnf_WriteIntoSolverNew( pCnf ); + if ( pSat == NULL ) + { + Cnf_DataFree( pCnf ); + return 1; + } + + + if ( fAndOuts ) + { + assert( 0 ); + // assert each output independently + if ( !Cnf_DataWriteAndClausesNew( pSat, pCnf ) ) + { + solver_delete( pSat ); + Cnf_DataFree( pCnf ); + return 1; + } + } + else + { + // add the OR clause for the outputs + if ( !Cnf_DataWriteOrClauseNew( pSat, pCnf ) ) + { + solver_delete( pSat ); + Cnf_DataFree( pCnf ); + return 1; + } + } + vCiIds = Cnf_DataCollectPiSatNums( pCnf, pMan ); + Cnf_DataFree( pCnf ); + + +// 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 = 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 ) + { + Vec_IntFree( vCiIds ); + solver_delete( pSat ); +// printf( "The problem is UNSATISFIABLE after simplification.\n" ); + return 1; + } + + // solve the miter + clk = clock(); + if ( fVerbose ) + solver_set_verbosity( pSat, 1 ); + status = solver_solve( pSat, 0, NULL ); + if ( status == solver_l_Undef ) + { +// printf( "The problem timed out.\n" ); + RetValue = -1; + } + else if ( status == solver_l_True ) + { +// printf( "The problem is SATISFIABLE.\n" ); + RetValue = 0; + } + else if ( status == solver_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 == solver_l_True ) + { + pMan->pData = Sat_SolverGetModelNew( pSat, vCiIds->pArray, vCiIds->nSize ); + } + // free the sat_solver + if ( fVerbose ) + Sat_SolverPrintStatsNew( stdout, pSat ); +//sat_solver_store_write( pSat, "trace.cnf" ); +//sat_solver_store_free( pSat ); + solver_delete( pSat ); + Vec_IntFree( vCiIds ); + return RetValue; +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + diff --git a/src/aig/cec2/cecSim.c b/src/aig/cec2/cecSim.c new file mode 100644 index 00000000..4fedbddc --- /dev/null +++ b/src/aig/cec2/cecSim.c @@ -0,0 +1,447 @@ +/**CFile**************************************************************** + + FileName [cecSim.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [AIG simulation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecSim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Creates fast simulation manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Caig_Man_t * Caig_ManCreate( Aig_Man_t * pAig ) +{ + Caig_Man_t * p; + Aig_Obj_t * pObj; + int i; + assert( Aig_ManHasNoGaps(pAig) ); + Aig_ManCleanData( pAig ); + p = (Caig_Man_t *)ABC_ALLOC( Caig_Man_t, 1 ); + memset( p, 0, sizeof(Caig_Man_t) ); + p->pAig = pAig; + p->nPis = Aig_ManPiNum(pAig); + p->nPos = Aig_ManPoNum(pAig); + p->nNodes = Aig_ManNodeNum(pAig); + p->nObjs = p->nPis + p->nPos + p->nNodes + 1; + p->pFans0 = ABC_ALLOC( int, p->nObjs ); + p->pFans1 = ABC_ALLOC( int, p->nObjs ); + p->pRefs = ABC_ALLOC( int, p->nObjs ); + p->pSims = ABC_CALLOC( unsigned, p->nObjs ); + // add objects + Aig_ManForEachObj( pAig, pObj, i ) + { + p->pRefs[i] = Aig_ObjRefs(pObj); + if ( Aig_ObjIsNode(pObj) ) + { + p->pFans0[i] = (Aig_ObjFaninId0(pObj) << 1) | Aig_ObjFaninC0(pObj); + p->pFans1[i] = (Aig_ObjFaninId1(pObj) << 1) | Aig_ObjFaninC1(pObj); + } + else if ( Aig_ObjIsPo(pObj) ) + { + p->pFans0[i] = (Aig_ObjFaninId0(pObj) << 1) | Aig_ObjFaninC0(pObj); + p->pFans1[i] = -1; + } + else + { + assert( Aig_ObjIsPi(pObj) || Aig_ObjIsConst1(pObj) ); + p->pFans0[i] = -1; + p->pFans1[i] = -1; + } + } + // temporaries + p->vClassOld = Vec_IntAlloc( 1000 ); + p->vClassNew = Vec_IntAlloc( 1000 ); + p->vRefinedC = Vec_IntAlloc( 10000 ); + p->vSims = Vec_PtrAlloc( 1000 ); + return p; +} + +/**Function************************************************************* + + Synopsis [Creates fast simulation manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManDelete( Caig_Man_t * p ) +{ + Vec_IntFree( p->vClassOld ); + Vec_IntFree( p->vClassNew ); + Vec_IntFree( p->vRefinedC ); + Vec_PtrFree( p->vSims ); + ABC_FREE( p->pFans0 ); + ABC_FREE( p->pFans1 ); + ABC_FREE( p->pRefs ); + ABC_FREE( p->pSims ); + ABC_FREE( p->pMems ); + ABC_FREE( p->pReprs ); + ABC_FREE( p->pNexts ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [References simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManSimMemRelink( Caig_Man_t * p ) +{ + int * pPlace, Ent; + pPlace = &p->MemFree; + for ( Ent = p->nMems * (p->nWords + 1); + Ent + p->nWords + 1 < p->nWordsAlloc; + Ent += p->nWords + 1 ) + { + *pPlace = Ent; + pPlace = p->pMems + Ent; + } + *pPlace = 0; +} + +/**Function************************************************************* + + Synopsis [References simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned * Caig_ManSimRead( Caig_Man_t * p, int i ) +{ + assert( i && p->pSims[i] > 0 ); + return p->pMems + p->pSims[i]; +} + +/**Function************************************************************* + + Synopsis [References simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned * Caig_ManSimRef( Caig_Man_t * p, int i ) +{ + unsigned * pSim; + assert( p->pSims[i] == 0 ); + if ( p->MemFree == 0 ) + { + if ( p->nWordsAlloc == 0 ) + { + assert( p->pMems == NULL ); + p->nWordsAlloc = (1<<17); // -> 1Mb + p->nMems = 1; + } + p->nWordsAlloc *= 2; + p->pMems = ABC_REALLOC( unsigned, p->pMems, p->nWordsAlloc ); + Caig_ManSimMemRelink( p ); + } + p->pSims[i] = p->MemFree; + pSim = p->pMems + p->MemFree; + p->MemFree = pSim[0]; + pSim[0] = p->pRefs[i]; + p->nMems++; + if ( p->nMemsMax < p->nMems ) + p->nMemsMax = p->nMems; + return pSim; +} + +/**Function************************************************************* + + Synopsis [Dereference simulaton info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned * Caig_ManSimDeref( Caig_Man_t * p, int i ) +{ + unsigned * pSim; + assert( p->pSims[i] > 0 ); + pSim = p->pMems + p->pSims[i]; + if ( --pSim[0] == 0 ) + { + pSim[0] = p->MemFree; + p->MemFree = p->pSims[i]; + p->pSims[i] = 0; + p->nMems--; + } + return pSim; +} + +/**Function************************************************************* + + Synopsis [Simulates one round.] + + Description [Returns the number of PO entry if failed; 0 otherwise.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Caig_ManSimulateRound( Caig_Man_t * p, Vec_Ptr_t * vInfoCis, Vec_Ptr_t * vInfoCos ) +{ + unsigned * pRes0, * pRes1, * pRes; + int i, w, iCiId = 0, iCoId = 0; + int nWords = Vec_PtrReadWordsSimInfo( vInfoCis ); + assert( vInfoCos == NULL || nWords == Vec_PtrReadWordsSimInfo(vInfoCos) ); + Vec_IntClear( p->vRefinedC ); + if ( p->pRefs[0] ) + { + pRes = Caig_ManSimRef( p, 0 ); + for ( w = 1; w <= nWords; w++ ) + pRes[w] = ~0; + } + for ( i = 1; i < p->nObjs; i++ ) + { + if ( p->pFans0[i] == -1 ) // ci always has zero first fanin + { + if ( p->pRefs[i] == 0 ) + { + iCiId++; + continue; + } + pRes = Caig_ManSimRef( p, i ); + pRes0 = Vec_PtrEntry( vInfoCis, iCiId++ ); + for ( w = 1; w <= nWords; w++ ) + pRes[w] = pRes0[w-1]; + goto references; + } + if ( p->pFans1[i] == -1 ) // co always has non-zero 1st fanin and zero 2nd fanin + { + pRes0 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans0[i]) ); + if ( vInfoCos ) + { + pRes = Vec_PtrEntry( vInfoCos, iCoId++ ); + if ( Cec_LitIsCompl(p->pFans0[i]) ) + for ( w = 1; w <= nWords; w++ ) + pRes[w-1] = ~pRes0[w]; + else + for ( w = 1; w <= nWords; w++ ) + pRes[w-1] = pRes0[w]; + } + continue; + } + assert( p->pRefs[i] ); + pRes = Caig_ManSimRef( p, i ); + pRes0 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans0[i]) ); + pRes1 = Caig_ManSimDeref( p, Cec_Lit2Var(p->pFans1[i]) ); + if ( Cec_LitIsCompl(p->pFans0[i]) ) + { + if ( Cec_LitIsCompl(p->pFans1[i]) ) + for ( w = 1; w <= nWords; w++ ) + pRes[w] = ~(pRes0[w] | pRes1[w]); + else + for ( w = 1; w <= nWords; w++ ) + pRes[w] = ~pRes0[w] & pRes1[w]; + } + else + { + if ( Cec_LitIsCompl(p->pFans1[i]) ) + for ( w = 1; w <= nWords; w++ ) + pRes[w] = pRes0[w] & ~pRes1[w]; + else + for ( w = 1; w <= nWords; w++ ) + pRes[w] = pRes0[w] & pRes1[w]; + } +references: + if ( p->pReprs == NULL ) + continue; + // if this node is candidate constant, collect it + if ( p->pReprs[i] == 0 && !Caig_ManCompareConst(pRes + 1, nWords) ) + { + pRes[0]++; + Vec_IntPush( p->vRefinedC, i ); + } + // if the node belongs to a class, save it + if ( p->pReprs[i] > 0 || p->pNexts[i] > 0 ) + pRes[0]++; + // if this is the last node of the class, process it + if ( p->pReprs[i] > 0 && p->pNexts[i] == 0 ) + { + Caig_ManCollectSimsNormal( p, p->pReprs[i] ); + Caig_ManClassRefineOne( p, p->pReprs[i], p->vSims ); + } + } + if ( Vec_IntSize(p->vRefinedC) > 0 ) + Caig_ManProcessRefined( p, p->vRefinedC ); + assert( iCiId == p->nPis ); + assert( vInfoCos == NULL || iCoId == p->nPos ); + assert( p->nMems == 1 ); +/* + if ( p->nMems > 1 ) + { + for ( i = 1; i < p->nObjs; i++ ) + if ( p->pSims[i] ) + { + int x = 0; + } + } +*/ +} + +/**Function************************************************************* + + Synopsis [Returns the number of PO that failed.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManFindPo( Vec_Ptr_t * vInfo, int nWords ) +{ + unsigned * pInfo; + int i, w; + Vec_PtrForEachEntry( vInfo, pInfo, i ) + for ( w = 0; w < nWords; w++ ) + if ( pInfo[w] != 0 ) + return i; + return -1; +} + +/**Function************************************************************* + + Synopsis [Returns 1 if the bug is detected, 0 otherwise.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, int fMiter, int fVerbose ) +{ + Caig_Man_t * p; + Cec_MtrStatus_t Status; + Vec_Ptr_t * vInfoCis, * vInfoCos = NULL; + int i, RetValue = 0, clk, clkTotal = clock(); +/* + p = Caig_ManClassesPrepare( pAig, nWords, nIters ); +// if ( fVerbose ) + printf( "Maxcut = %6d. AIG mem = %8.3f Mb. Sim mem = %8.3f Mb.\n", + p->nMemsMax, + 1.0*(p->nObjs * 14)/(1<<20), + 1.0*(p->nMemsMax * (nWords+1))/(1<<20) ); + Caig_ManDelete( p ); + return 0; +*/ + if ( fMiter ) + { + Status = Cec_MiterStatus( pAig ); + if ( Status.nSat > 0 ) + { + printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut ); + return 1; + } + if ( Status.nUndec == 0 ) + { + printf( "Miter is trivially unsatisfiable.\n" ); + return 0; + } + } + Aig_ManRandom( 1 ); + p = Caig_ManCreate( pAig ); + p->nWords = nWords; + if ( fMiter ) + vInfoCos = Vec_PtrAllocSimInfo( Aig_ManPiNum(pAig), nWords ); + for ( i = 0; i < nIters; i++ ) + { + clk = clock(); + vInfoCis = Vec_PtrAllocSimInfo( Aig_ManPiNum(pAig), nWords ); + Aig_ManRandomInfo( vInfoCis, 0, nWords ); + Caig_ManSimulateRound( p, vInfoCis, vInfoCos ); + Vec_PtrFree( vInfoCis ); + if ( fVerbose ) + { + printf( "Iter %3d out of %3d and timeout %3d sec. ", i+1, nIters, TimeLimit ); + printf("Time = %7.2f sec\r", (1.0*clock()-clkTotal)/CLOCKS_PER_SEC); + } + if ( fMiter ) + { + int iOut = Cec_ManFindPo( vInfoCos, nWords ); + if ( iOut >= 0 ) + { + if ( fVerbose ) + printf( "Miter is satisfiable after simulation (output %d).\n", iOut ); + RetValue = 1; + break; + } + } + if ( (clock() - clk)/CLOCKS_PER_SEC >= TimeLimit ) + { + printf( "No bug detected after %d rounds with time limit %d seconds.\n", i+1, TimeLimit ); + break; + } + } + if ( fVerbose ) + printf( "Maxcut = %6d. AIG mem = %8.3f Mb. Sim mem = %8.3f Mb.\n", + p->nMemsMax, + 1.0*(p->nObjs * 14)/(1<<20), + 1.0*(p->nMemsMax * 4 * (nWords+1))/(1<<20) ); + Caig_ManDelete( p ); + if ( vInfoCos ) + Vec_PtrFree( vInfoCos ); + return RetValue > 0; +} + + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecStatus.c b/src/aig/cec2/cecStatus.c new file mode 100644 index 00000000..79d6ec66 --- /dev/null +++ b/src/aig/cec2/cecStatus.c @@ -0,0 +1,187 @@ +/**CFile**************************************************************** + + FileName [cecStatus.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [Miter status.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecStatus.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Returns 1 if the output is known.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_OutputStatus( Aig_Man_t * p, Aig_Obj_t * pObj ) +{ + Aig_Obj_t * pChild; + assert( Aig_ObjIsPo(pObj) ); + pChild = Aig_ObjChild0(pObj); + // check if the output is constant 0 + if ( pChild == Aig_ManConst0(p) ) + return 1; + // check if the output is constant 1 + if ( pChild == Aig_ManConst1(p) ) + return 1; + // check if the output is a primary input + if ( Aig_ObjIsPi(Aig_Regular(pChild)) ) + return 1; + // check if the output is 1 for the 0000 pattern + if ( Aig_Regular(pChild)->fPhase != (unsigned)Aig_IsComplement(pChild) ) + return 1; + return 0; +} + +/**Function************************************************************* + + Synopsis [Returns number of used inputs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_CountInputs( Aig_Man_t * p ) +{ + Aig_Obj_t * pObj; + int i, Counter = 0; + Aig_ManForEachPi( p, pObj, i ) + Counter += (int)(pObj->nRefs > 0); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Checks the status of the miter.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cec_MtrStatus_t Cec_MiterStatus( Aig_Man_t * p ) +{ + Cec_MtrStatus_t Status; + Aig_Obj_t * pObj, * pChild; + int i; + assert( p->nRegs == 0 ); + memset( &Status, 0, sizeof(Cec_MtrStatus_t) ); + Status.iOut = -1; + Status.nInputs = Cec_CountInputs( p ); + Status.nNodes = Aig_ManNodeNum( p ); + Status.nOutputs = Aig_ManPoNum(p); + Aig_ManForEachPo( p, pObj, i ) + { + pChild = Aig_ObjChild0(pObj); + // check if the output is constant 0 + if ( pChild == Aig_ManConst0(p) ) + Status.nUnsat++; + // check if the output is constant 1 + else if ( pChild == Aig_ManConst1(p) ) + { + Status.nSat++; + if ( Status.iOut == -1 ) + Status.iOut = i; + } + // check if the output is a primary input + else if ( Aig_ObjIsPi(Aig_Regular(pChild)) ) + { + Status.nSat++; + if ( Status.iOut == -1 ) + Status.iOut = i; + } + // check if the output is 1 for the 0000 pattern + else if ( Aig_Regular(pChild)->fPhase != (unsigned)Aig_IsComplement(pChild) ) + { + Status.nSat++; + if ( Status.iOut == -1 ) + Status.iOut = i; + } + else + Status.nUndec++; + } + return Status; +} + +/**Function************************************************************* + + Synopsis [Checks the status of the miter.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cec_MtrStatus_t Cec_MiterStatusTrivial( Aig_Man_t * p ) +{ + Cec_MtrStatus_t Status; + memset( &Status, 0, sizeof(Cec_MtrStatus_t) ); + Status.iOut = -1; + Status.nInputs = Aig_ManPiNum(p); + Status.nNodes = Aig_ManNodeNum( p ); + Status.nOutputs = Aig_ManPoNum(p); + Status.nUndec = Aig_ManPoNum(p); + return Status; +} + +/**Function************************************************************* + + Synopsis [Prints the status of the miter.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_MiterStatusPrint( Cec_MtrStatus_t S, char * pString, int Time ) +{ + printf( "%s:", pString ); + printf( " I =%6d", S.nInputs ); + printf( " N =%7d", S.nNodes ); + printf( " " ); + printf( " ? =%6d", S.nUndec ); + printf( " U =%6d", S.nUnsat ); + printf( " S =%6d", S.nSat ); + printf(" %7.2f sec\n", (float)(Time)/(float)(CLOCKS_PER_SEC)); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/cecSweep.c b/src/aig/cec2/cecSweep.c new file mode 100644 index 00000000..d7d85b02 --- /dev/null +++ b/src/aig/cec2/cecSweep.c @@ -0,0 +1,582 @@ +/**CFile**************************************************************** + + FileName [cecSweep.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Combinatinoal equivalence checking.] + + Synopsis [Pattern accumulation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: cecSweep.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "cecInt.h" +#include "satSolver.h" +#include "cnf.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Cec_ManCsw_t_ Cec_ManCsw_t; +struct Cec_ManCsw_t_ +{ + // parameters + Cec_ParCsw_t * pPars; // parameters + Caig_Man_t * p; // AIG and simulation manager + // mapping into copy + Aig_Obj_t ** pCopy; // the copy of nodes + Vec_Int_t * vCopies; // the nodes copied in the last round + char * pProved; // tells if the given node is proved + char * pProvedNow; // tells if the given node is proved + int * pLevel; // level of the nodes + // collected patterns + Vec_Ptr_t * vInfo; // simulation info accumulated + Vec_Ptr_t * vPres; // simulation presence accumulated + Vec_Ptr_t * vInfoAll; // vector of vectors of simulation info + // temporaries + Vec_Int_t * vPiNums; // primary input numbers + Vec_Int_t * vPoNums; // primary output numbers + Vec_Int_t * vPat; // one counter-example + Vec_Ptr_t * vSupp; // support of one node +}; + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Adds pattern to storage.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSavePattern( Cec_ManCsw_t * p, Vec_Int_t * vPat ) +{ + unsigned * pInfo, * pPres; + int nPatsAlloc, iLit, i, c; + assert( p->p->nWords == Vec_PtrReadWordsSimInfo(p->vInfo) ); + // find next empty place + nPatsAlloc = 32 * p->p->nWords; + for ( c = 0; c < nPatsAlloc; c++ ) + { + Vec_IntForEachEntry( vPat, iLit, i ) + { + pPres = Vec_PtrEntry( p->vPres, Cec_Lit2Var(iLit) ); + if ( Aig_InfoHasBit( pPres, c ) ) + break; + } + if ( i == Vec_IntSize(vPat) ) + break; + } + // increase the size if needed + if ( c == nPatsAlloc ) + { + p->vInfo = Vec_PtrAllocSimInfo( p->p->nPis, p->p->nWords ); + Vec_PtrCleanSimInfo( p->vInfo, 0, p->p->nWords ); + Vec_PtrCleanSimInfo( p->vPres, 0, p->p->nWords ); + Vec_PtrPush( p->vInfoAll, p->vInfo ); + c = 0; + } + // save the pattern + Vec_IntForEachEntry( vPat, iLit, i ) + { + pPres = Vec_PtrEntry( p->vPres, Cec_Lit2Var(iLit) ); + pInfo = Vec_PtrEntry( p->vInfo, Cec_Lit2Var(iLit) ); + Aig_InfoSetBit( pPres, c ); + if ( !Cec_LitIsCompl(iLit) ) + Aig_InfoSetBit( pInfo, c ); + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Obj_t * Cec_ManCswCreatePartition_rec( Aig_Man_t * pAig, Cec_ManCsw_t * p, int i ) +{ + Aig_Obj_t * pRes0, * pRes1; + if ( p->pCopy[i] ) + return p->pCopy[i]; + Vec_IntPush( p->vCopies, i ); + if ( p->p->pFans0[i] == -1 ) // pi + { + Vec_IntPush( p->vPiNums, Aig_ObjPioNum( Aig_ManObj(p->p->pAig, i) ) ); + return p->pCopy[i] = Aig_ObjCreatePi( pAig ); + } + assert( p->p->pFans0[i] && p->p->pFans1[i] ); + pRes0 = Cec_ManCswCreatePartition_rec( pAig, p, Cec_Lit2Var(p->p->pFans0[i]) ); + pRes0 = Aig_NotCond( pRes0, Cec_LitIsCompl(p->p->pFans0[i]) ); + pRes1 = Cec_ManCswCreatePartition_rec( pAig, p, Cec_Lit2Var(p->p->pFans1[i]) ); + pRes1 = Aig_NotCond( pRes1, Cec_LitIsCompl(p->p->pFans1[i]) ); + return p->pCopy[i] = Aig_And( pAig, pRes0, pRes1 ); +} + +/**Function************************************************************* + + Synopsis [Creates dynamic partition.] + + Description [PIs point to node IDs. POs point to node IDs.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Man_t * Cec_ManCswCreatePartition( Cec_ManCsw_t * p, int * piStart, int nMitersMin, int nNodesMin, int nLevelMax ) +{ + Caig_Man_t * pMan = p->p; + Aig_Man_t * pAig; + Aig_Obj_t * pRepr, * pNode, * pMiter, * pTerm; + int i, iNode, Counter = 0; + assert( p->pCopy && p->vCopies ); + // clear previous marks + Vec_IntForEachEntry( p->vCopies, iNode, i ) + p->pCopy[iNode] = NULL; + Vec_IntClear( p->vCopies ); + // iterate through nodes starting from the given one + pAig = Aig_ManStart( nNodesMin ); + p->pCopy[0] = Aig_ManConst1(pAig); + Vec_IntPush( p->vCopies, 0 ); + for ( i = *piStart; i < pMan->nObjs; i++ ) + { + if ( pMan->pFans0[i] == -1 ) // pi always has zero first fanin + continue; + if ( pMan->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin + continue; + if ( pMan->pReprs[i] < 0 ) + continue; + if ( p->pPars->nLevelMax && (p->pLevel[i] > p->pPars->nLevelMax || p->pLevel[pMan->pReprs[i]] > p->pPars->nLevelMax) ) + continue; + // create cones + pRepr = Cec_ManCswCreatePartition_rec( pAig, p, pMan->pReprs[i] ); + pNode = Cec_ManCswCreatePartition_rec( pAig, p, i ); + // skip if they are the same + if ( Aig_Regular(pRepr) == Aig_Regular(pNode) ) + { + p->pProvedNow[i] = 1; + continue; + } + // perform speculative reduction + assert( p->pCopy[i] == pNode ); + p->pCopy[i] = Aig_NotCond( pRepr, Aig_ObjPhaseReal(pRepr) ^ Aig_ObjPhaseReal(pNode) ); + if ( p->pProved[i] ) + { + p->pProvedNow[i] = 1; + continue; + } + pMiter = Aig_Exor( pAig, pRepr, pNode ); + pTerm = Aig_ObjCreatePo( pAig, Aig_NotCond(pMiter, Aig_ObjPhaseReal(pMiter)) ); + Vec_IntPush( p->vPoNums, i ); + if ( ++Counter > nMitersMin && Aig_ManObjNum(pAig) > nNodesMin ) + break; + } + *piStart = i + 1; + Aig_ManSetRegNum( pAig, 0 ); + Aig_ManCleanup( pAig ); + return pAig; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatDerivePattern( Cec_ManCsw_t * p, Aig_Man_t * pAig, Aig_Obj_t * pRoot, Cnf_Dat_t * pCnf, sat_solver * pSat ) +{ + Aig_Obj_t * pObj; + int i, Value, iVar; + assert( Aig_ObjIsPo(pRoot) ); + Aig_SupportNodes( pAig, &pRoot, 1, p->vSupp ); + Vec_IntClear( p->vPat ); + Vec_PtrForEachEntry( p->vSupp, pObj, i ) + { + assert( Aig_ObjIsPi(pObj) ); + Value = sat_solver_var_value( pSat, pCnf->pVarNums[pObj->Id] ); + iVar = Vec_IntEntry( p->vPiNums, Aig_ObjPioNum(pObj) ); + assert( iVar >= 0 && iVar < p->p->nPis ); + Vec_IntPush( p->vPat, Cec_Var2Lit( iVar, !Value ) ); + } +} + +/**Function************************************************************* + + Synopsis [Creates level.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManCreateLevel( Cec_ManCsw_t * p ) +{ + Aig_Obj_t * pObj; + int i; + assert( p->pLevel == NULL ); + p->pLevel = ABC_ALLOC( int, p->p->nObjs ); + Aig_ManForEachObj( p->p->pAig, pObj, i ) + p->pLevel[i] = Aig_ObjLevel(pObj); +} + +/**Function************************************************************* + + Synopsis [Creates the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cec_ManCsw_t * Cec_ManCswCreate( Caig_Man_t * pMan, Cec_ParCsw_t * pPars ) +{ + Cec_ManCsw_t * p; + // create interpolation manager + p = ABC_ALLOC( Cec_ManCsw_t, 1 ); + memset( p, 0, sizeof(Cec_ManCsw_t) ); + p->pPars = pPars; + p->p = pMan; + // internal storage + p->vCopies = Vec_IntAlloc( 10000 ); + p->pCopy = ABC_CALLOC( Aig_Obj_t *, pMan->nObjs ); + p->pProved = ABC_CALLOC( char, pMan->nObjs ); + p->pProvedNow = ABC_CALLOC( char, pMan->nObjs ); + // temporaries + p->vPat = Vec_IntAlloc( 1000 ); + p->vSupp = Vec_PtrAlloc( 1000 ); + p->vPiNums = Vec_IntAlloc( 1000 ); + p->vPoNums = Vec_IntAlloc( 1000 ); + if ( pPars->nLevelMax ) + Cec_ManCreateLevel( p ); + return p; +} + +/**Function************************************************************* + + Synopsis [Frees the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManCswStop( Cec_ManCsw_t * p ) +{ + Vec_IntFree( p->vPiNums ); + Vec_IntFree( p->vPoNums ); + Vec_PtrFree( p->vSupp ); + Vec_IntFree( p->vPat ); + Vec_IntFree( p->vCopies ); + Vec_PtrFree( p->vPres ); + Vec_VecFree( (Vec_Vec_t *)p->vInfoAll ); + ABC_FREE( p->pLevel ); + ABC_FREE( p->pCopy ); + ABC_FREE( p->pProved ); + ABC_FREE( p->pProvedNow ); + ABC_FREE( p ); +} + + +/**Function************************************************************* + + Synopsis [Cleans the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManCleanSimInfo( Cec_ManCsw_t * p ) +{ + if ( p->vInfoAll ) + Vec_VecFree( (Vec_Vec_t *)p->vInfoAll ); + if ( p->vPres ) + Vec_PtrFree( p->vPres ); + p->vInfoAll = Vec_PtrAlloc( 100 ); + p->vInfo = Vec_PtrAllocSimInfo( p->p->nPis, p->pPars->nWords ); + p->vPres = Vec_PtrAllocSimInfo( p->p->nPis, p->pPars->nWords ); + Vec_PtrCleanSimInfo( p->vInfo, 0, p->p->nWords ); + Vec_PtrCleanSimInfo( p->vPres, 0, p->p->nWords ); + Vec_PtrPush( p->vInfoAll, p->vInfo ); +} + +/**Function************************************************************* + + Synopsis [Update information about proved nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManCountProved( char * pArray, int nSize ) +{ + int i, Counter = 0; + for ( i = 0; i < nSize; i++ ) + Counter += (pArray[i] == 1); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Update information about proved nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManCountDisproved( char * pArray, int nSize ) +{ + int i, Counter = 0; + for ( i = 0; i < nSize; i++ ) + Counter += (pArray[i] == -1); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Update information about proved nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cec_ManCountTimedout( char * pArray, int nSize ) +{ + int i, Counter = 0; + for ( i = 0; i < nSize; i++ ) + Counter += (pArray[i] == -2); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Update information about proved nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManUpdateProved( Cec_ManCsw_t * p ) +{ + Caig_Man_t * pMan = p->p; + int i; + for ( i = 1; i < pMan->nObjs; i++ ) + { + if ( pMan->pFans0[i] == -1 ) // pi always has zero first fanin + continue; + if ( pMan->pFans1[i] == -1 ) // po always has non-zero 1st fanin and zero 2nd fanin + continue; + if ( p->pProvedNow[Cec_Lit2Var(pMan->pFans0[i])] < 0 || + p->pProvedNow[Cec_Lit2Var(pMan->pFans1[i])] < 0 ) + p->pProvedNow[i] = -1; + if ( pMan->pReprs[i] < 0 ) + { + assert( p->pProvedNow[i] <= 0 ); + continue; + } + if ( p->pProved[i] ) + { + assert( p->pProvedNow[i] == 1 ); + continue; + } + if ( p->pProvedNow[i] == 1 ) + p->pProved[i] = 1; + } +} + +/**Function************************************************************* + + Synopsis [Creates dynamic partition.] + + Description [PIs point to node IDs. POs point to node IDs.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatSweepRound( Cec_ManCsw_t * p ) +{ + Bar_Progress_t * pProgress = NULL; + Vec_Ptr_t * vInfo; + Aig_Man_t * pAig, * pTemp; + Aig_Obj_t * pObj; + Cnf_Dat_t * pCnf; + sat_solver * pSat; + int i, Lit, iNode, iStart, status; + int nProved, nDisproved, nTimedout, nBefore, nAfter, nRecycles = 0; + int clk = clock(); + Cec_ManCleanSimInfo( p ); + memset( p->pProvedNow, 0, sizeof(char) * p->p->nObjs ); + pProgress = Bar_ProgressStart( stdout, p->p->nObjs ); + for ( iStart = 1; iStart < p->p->nObjs; ) + { + Bar_ProgressUpdate( pProgress, iStart, "Sweep..." ); + Vec_IntClear( p->vPiNums ); + Vec_IntClear( p->vPoNums ); + // generate AIG, synthesize, convert to CNF, and solve + pAig = Cec_ManCswCreatePartition( p, &iStart, p->pPars->nCallsRecycle, p->pPars->nSatVarMax, p->pPars->nLevelMax ); + Aig_ManPrintStats( pAig ); + + if ( p->pPars->fRewriting ) + { + pAig = Dar_ManRwsat( pTemp = pAig, 1, 0 ); + Aig_ManStop( pTemp ); + } + pCnf = Cnf_Derive( pAig, Aig_ManPoNum(pAig) ); + pSat = Cnf_DataWriteIntoSolver( pCnf, 1, 0 ); + Aig_ManForEachPo( pAig, pObj, i ) + { + iNode = Vec_IntEntry( p->vPoNums, i ); + Lit = toLitCond( pCnf->pVarNums[pObj->Id], 0 ); + status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); + if ( status == l_False ) + p->pProvedNow[iNode] = 1; + else if ( status == l_Undef ) + p->pProvedNow[iNode] = -2; + else if ( status == l_True ) + { + p->pProvedNow[iNode] = -1; + Cec_ManSatDerivePattern( p, pAig, pObj, pCnf, pSat ); + Cec_ManSavePattern( p, p->vPat ); + } + } + // clean up + Aig_ManStop( pAig ); + Cnf_DataFree( pCnf ); + sat_solver_delete( pSat ); + nRecycles++; + } + Bar_ProgressStop( pProgress ); + // collect statistics + nProved = Cec_ManCountProved( p->pProvedNow, p->p->nObjs ); + nDisproved = Cec_ManCountDisproved( p->pProvedNow, p->p->nObjs ); + nTimedout = Cec_ManCountTimedout( p->pProvedNow, p->p->nObjs ); + nBefore = Cec_ManCountProved( p->pProved, p->p->nObjs ); + Cec_ManUpdateProved( p ); + nAfter = Cec_ManCountProved( p->pProved, p->p->nObjs ); + printf( "Pr =%6d. Cex =%6d. Fail =%6d. Bef =%6d. Aft =%6d. Rcl =%4d.", + nProved, nDisproved, nTimedout, nBefore, nAfter, nRecycles ); + ABC_PRT( "Time", clock() - clk ); + // resimulate with the collected information + Vec_PtrForEachEntry( p->vInfoAll, vInfo, i ) + Caig_ManSimulateRound( p->p, vInfo, NULL ); +Caig_ManPrintClasses( p->p, 0 ); +} + +/**Function************************************************************* + + Synopsis [Performs one round of sweeping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cec_ManSatSweepInt( Caig_Man_t * pMan, Cec_ParCsw_t * pPars ) +{ + Cec_ManCsw_t * p; + p = Cec_ManCswCreate( pMan, pPars ); + Cec_ManSatSweepRound( p ); + Cec_ManCswStop( p ); +} + + +/**Function************************************************************* + + Synopsis [Performs equivalence checking.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Man_t * Cec_ManTrasferReprs( Aig_Man_t * pAig, Caig_Man_t * pCaig ) +{ + return NULL; +} + +/**Function************************************************************* + + Synopsis [Performs equivalence checking.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Man_t * Cec_ManSatSweep( Aig_Man_t * pAig, Cec_ParCsw_t * pPars ) +{ +/* + Aig_Man_t * pAigNew, * pAigDfs; + Caig_Man_t * pCaig; + Cec_ManCsw_t * p; + pAigDfs = Cec_Duplicate( pAig ); + pCaig = Caig_ManClassesPrepare( pAigDfs, pPars->nWords, pPars->nRounds ); + p = Cec_ManCswCreate( pCaig, pPars ); + Cec_ManSatSweep( p, pPars ); + Cec_ManCswStop( p ); +// pAigNew = + Caig_ManDelete( pCaig ); + Aig_ManStop( pAigDfs ); + return pAigNew; +*/ + return NULL; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/cec2/module.make b/src/aig/cec2/module.make new file mode 100644 index 00000000..537397e3 --- /dev/null +++ b/src/aig/cec2/module.make @@ -0,0 +1,9 @@ +SRC += src/aig/cec/cecAig.c \ + src/aig/cec/cecClass.c \ + src/aig/cec/cecCnf.c \ + src/aig/cec/cecCore.c \ + src/aig/cec/cecMan.c \ + src/aig/cec/cecSat.c \ + src/aig/cec/cecSim.c \ + src/aig/cec/cecStatus.c \ + src/aig/cec/cecSweep.c diff --git a/src/aig/cgt/cgt.h b/src/aig/cgt/cgt.h index f8c1cc2e..8d18ea80 100644 --- a/src/aig/cgt/cgt.h +++ b/src/aig/cgt/cgt.h @@ -21,10 +21,6 @@ #ifndef __CGT_H__ #define __CGT_H__ -#ifdef __cplusplus -extern "C" { -#endif - /* The algorithm implemented in this package is based on the paper: A. Hurst. "Automatic synthesis of clock gating logic with controlled @@ -39,6 +35,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/cgt/cgtCore.c b/src/aig/cgt/cgtCore.c index f49cd46f..b213297e 100644 --- a/src/aig/cgt/cgtCore.c +++ b/src/aig/cgt/cgtCore.c @@ -220,7 +220,7 @@ p->timePrepare += clock() - clk; p->nCallsSat -nCallsSat, p->nCallsUndec-nCallsUndec, p->nCallsFiltered-nCallsFiltered ); - PRT( "Time", clock() - clkTotal ); + ABC_PRT( "Time", clock() - clkTotal ); } Cgt_ManClean( p ); p->nRecycles++; diff --git a/src/aig/cgt/cgtDecide.c b/src/aig/cgt/cgtDecide.c index 0fb2a681..3e79ff73 100644 --- a/src/aig/cgt/cgtDecide.c +++ b/src/aig/cgt/cgtDecide.c @@ -227,7 +227,7 @@ Vec_Vec_t * Cgt_ManDecideSimple( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int nO // printf( "Gated transitions = %5.2f %%. (%5.2f %%.) ", // 100.0*nTransSaved/nTransTotal, Cgt_ManComputeCoverage(pAig, vGates) ); printf( "Gated transitions = %5.2f %%. ", Cgt_ManComputeCoverage(pAig, vGates) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } /* { @@ -283,7 +283,7 @@ Vec_Vec_t * Cgt_ManDecideArea( Aig_Man_t * pAig, Vec_Vec_t * vGatesAll, int nOdc Vec_VecSizeSize(vGatesAll), Counter, Saig_ManRegNum(pAig) ); printf( "Complete gates = %6d. Gated transitions = %5.2f %%. ", Vec_PtrSize(vCompletes), Cgt_ManComputeCoverage(pAig, vGates) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } Vec_PtrFree( vCompletes ); return vGates; diff --git a/src/aig/cgt/cgtInt.h b/src/aig/cgt/cgtInt.h index 23d851f3..3d9823c3 100644 --- a/src/aig/cgt/cgtInt.h +++ b/src/aig/cgt/cgtInt.h @@ -21,10 +21,6 @@ #ifndef __CGT_INT_H__ #define __CGT_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -38,6 +34,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/cgt/cgtMan.c b/src/aig/cgt/cgtMan.c index a3385228..ddc1c5e0 100644 --- a/src/aig/cgt/cgtMan.c +++ b/src/aig/cgt/cgtMan.c @@ -47,7 +47,7 @@ Cgt_Man_t * Cgt_ManCreate( Aig_Man_t * pAig, Aig_Man_t * pCare, Cgt_Par_t * pPar Aig_ManFanoutStart( pAig ); Aig_ManSetPioNumbers( pAig ); // create interpolation manager - p = ALLOC( Cgt_Man_t, 1 ); + p = ABC_ALLOC( Cgt_Man_t, 1 ); memset( p, 0, sizeof(Cgt_Man_t) ); p->pPars = pPars; p->pAig = pAig; @@ -123,17 +123,17 @@ void Cgt_ManPrintStats( Cgt_Man_t * p ) p->pPars->nConfMax, p->pPars->nVarsMin, p->pPars->nFlopsMin ); printf( "SAT : Calls = %d. Unsat = %d. Sat = %d. Fails = %d. Recycles = %d. ", p->nCalls, p->nCallsUnsat, p->nCallsSat, p->nCallsUndec, p->nRecycles ); - PRT( "Time", p->timeTotal ); + ABC_PRT( "Time", p->timeTotal ); /* p->timeOther = p->timeTotal-p->timeAig-p->timePrepare-p->timeSat-p->timeDecision; - PRTP( "AIG ", p->timeAig, p->timeTotal ); - PRTP( "Prepare ", p->timePrepare, p->timeTotal ); - PRTP( "SAT solving", p->timeSat, p->timeTotal ); - PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); - PRTP( " sat ", p->timeSatSat, p->timeTotal ); - PRTP( " undecided", p->timeSatUndec, p->timeTotal ); - PRTP( "Other ", p->timeOther, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + ABC_PRTP( "AIG ", p->timeAig, p->timeTotal ); + ABC_PRTP( "Prepare ", p->timePrepare, p->timeTotal ); + ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal ); + ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); + ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal ); + ABC_PRTP( " undecided", p->timeSatUndec, p->timeTotal ); + ABC_PRTP( "Other ", p->timeOther, p->timeTotal ); + ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); */ } @@ -163,7 +163,7 @@ void Cgt_ManStop( Cgt_Man_t * p ) Vec_VecFree( p->vGatesAll ); if ( p->vSuppsInv ) Vec_VecFree( p->vSuppsInv ); - free( p ); + ABC_FREE( p ); } diff --git a/src/aig/cgt/cgtSat.c b/src/aig/cgt/cgtSat.c index 094fb47d..94168978 100644 --- a/src/aig/cgt/cgtSat.c +++ b/src/aig/cgt/cgtSat.c @@ -57,7 +57,7 @@ int Cgt_CheckImplication( Cgt_Man_t * p, Aig_Obj_t * pGate, Aig_Obj_t * pMiter ) pLits[1] = toLitCond( p->pCnf->pVarNums[pMiter->Id], 0 ); clk = clock(); - RetValue = sat_solver_solve( p->pSat, pLits, pLits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSat, pLits, pLits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); p->timeSat += clock() - clk; if ( RetValue == l_False ) { diff --git a/src/aig/cnf/cnf.h b/src/aig/cnf/cnf.h index c9c5bce3..4343bf9a 100644 --- a/src/aig/cnf/cnf.h +++ b/src/aig/cnf/cnf.h @@ -21,10 +21,6 @@ #ifndef __CNF_H__ #define __CNF_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -43,6 +39,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/cnf/cnfCore.c b/src/aig/cnf/cnfCore.c index e1d62de0..11a7af43 100644 --- a/src/aig/cnf/cnfCore.c +++ b/src/aig/cnf/cnfCore.c @@ -77,9 +77,9 @@ p->timeSave = clock() - clk; // reset reference counters Aig_ManResetRefs( pAig ); -//PRT( "Cuts ", p->timeCuts ); -//PRT( "Map ", p->timeMap ); -//PRT( "Saving ", p->timeSave ); +//ABC_PRT( "Cuts ", p->timeCuts ); +//ABC_PRT( "Map ", p->timeMap ); +//ABC_PRT( "Saving ", p->timeSave ); return pCnf; } @@ -141,7 +141,7 @@ Cnf_Dat_t * Cnf_Derive_old( Aig_Man_t * pAig ) clk = clock(); Cnf_ManScanMapping( p, 0 ); Cnf_ManMapForCnf( p ); -PRT( "iter ", clock() - clk ); +ABC_PRT( "iter ", clock() - clk ); } */ // write the file @@ -159,7 +159,7 @@ clk = clock(); Cnf_ManPostprocess( p ); Cnf_ManScanMapping( p, 0 ); */ -PRT( "Ext ", clock() - clk ); +ABC_PRT( "Ext ", clock() - clk ); /* vMapped = Cnf_ManScanMapping( p, 1 ); diff --git a/src/aig/cnf/cnfData.c b/src/aig/cnf/cnfData.c index 01f6ff8a..8df93fdb 100644 --- a/src/aig/cnf/cnfData.c +++ b/src/aig/cnf/cnfData.c @@ -4554,7 +4554,7 @@ void Cnf_ReadMsops( char ** ppSopSizes, char *** ppSops ) assert( Size < 100000 ); // allocate memory - pMemory = ALLOC( char, Size * 75 ); + pMemory = ABC_ALLOC( char, Size * 75 ); // copy the array into memory for ( i = 0; i < Size; i++ ) for ( k = 0; k < 75; k++ ) @@ -4564,8 +4564,8 @@ void Cnf_ReadMsops( char ** ppSopSizes, char *** ppSops ) pMemory[i*75+k] = Map[(int)s_Data4[i][k]]; // set pointers and compute SOP sizes - pSopSizes = ALLOC( char, 65536 ); - pSops = ALLOC( char *, 65536 ); + pSopSizes = ABC_ALLOC( char, 65536 ); + pSops = ABC_ALLOC( char *, 65536 ); pSopSizes[0] = 0; pSops[0] = NULL; pPrev = pMemory; diff --git a/src/aig/cnf/cnfMan.c b/src/aig/cnf/cnfMan.c index 7c24606c..f8e88b8f 100644 --- a/src/aig/cnf/cnfMan.c +++ b/src/aig/cnf/cnfMan.c @@ -49,7 +49,7 @@ Cnf_Man_t * Cnf_ManStart() Cnf_Man_t * p; int i; // allocate the manager - p = ALLOC( Cnf_Man_t, 1 ); + p = ABC_ALLOC( Cnf_Man_t, 1 ); memset( p, 0, sizeof(Cnf_Man_t) ); // derive internal data structures Cnf_ReadMsops( &p->pSopSizes, &p->pSops ); @@ -57,7 +57,7 @@ Cnf_Man_t * Cnf_ManStart() p->pMemCuts = Aig_MmFlexStart(); p->nMergeLimit = 10; // allocate temporary truth tables - p->pTruths[0] = ALLOC( unsigned, 4 * Aig_TruthWordNum(p->nMergeLimit) ); + p->pTruths[0] = ABC_ALLOC( unsigned, 4 * Aig_TruthWordNum(p->nMergeLimit) ); for ( i = 1; i < 4; i++ ) p->pTruths[i] = p->pTruths[i-1] + Aig_TruthWordNum(p->nMergeLimit); p->vMemory = Vec_IntAlloc( 1 << 18 ); @@ -78,12 +78,12 @@ Cnf_Man_t * Cnf_ManStart() void Cnf_ManStop( Cnf_Man_t * p ) { Vec_IntFree( p->vMemory ); - free( p->pTruths[0] ); + ABC_FREE( p->pTruths[0] ); Aig_MmFlexStop( p->pMemCuts, 0 ); - free( p->pSopSizes ); - free( p->pSops[1] ); - free( p->pSops ); - free( p ); + ABC_FREE( p->pSopSizes ); + ABC_FREE( p->pSops[1] ); + ABC_FREE( p->pSops ); + ABC_FREE( p ); } /**Function************************************************************* @@ -123,16 +123,16 @@ Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, int nLiter { Cnf_Dat_t * pCnf; int i; - pCnf = ALLOC( Cnf_Dat_t, 1 ); + pCnf = ABC_ALLOC( Cnf_Dat_t, 1 ); memset( pCnf, 0, sizeof(Cnf_Dat_t) ); pCnf->pMan = pAig; pCnf->nVars = nVars; pCnf->nClauses = nClauses; pCnf->nLiterals = nLiterals; - pCnf->pClauses = ALLOC( int *, nClauses + 1 ); - pCnf->pClauses[0] = ALLOC( int, nLiterals ); + pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 ); + pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals ); pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals; - pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(pAig) ); + pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(pAig) ); // memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(pAig) ); for ( i = 0; i < Aig_ManObjNumMax(pAig); i++ ) pCnf->pVarNums[i] = -1; @@ -177,10 +177,10 @@ void Cnf_DataFree( Cnf_Dat_t * p ) { if ( p == NULL ) return; - free( p->pClauses[0] ); - free( p->pClauses ); - free( p->pVarNums ); - free( p ); + ABC_FREE( p->pClauses[0] ); + ABC_FREE( p->pClauses ); + ABC_FREE( p->pVarNums ); + ABC_FREE( p ); } /**Function************************************************************* @@ -425,15 +425,15 @@ int Cnf_DataWriteOrClause( void * p, Cnf_Dat_t * pCnf ) sat_solver * pSat = p; Aig_Obj_t * pObj; int i, * pLits; - pLits = ALLOC( int, Aig_ManPoNum(pCnf->pMan) ); + pLits = ABC_ALLOC( int, Aig_ManPoNum(pCnf->pMan) ); Aig_ManForEachPo( pCnf->pMan, pObj, i ) pLits[i] = toLitCond( pCnf->pVarNums[pObj->Id], 0 ); if ( !sat_solver_addclause( pSat, pLits, pLits + Aig_ManPoNum(pCnf->pMan) ) ) { - free( pLits ); + ABC_FREE( pLits ); return 0; } - free( pLits ); + ABC_FREE( pLits ); return 1; } @@ -479,7 +479,7 @@ void Cnf_DataTranformPolarity( Cnf_Dat_t * pCnf, int fTransformPos ) int * pVarToPol; int i, iVar; // create map from the variable number to its polarity - pVarToPol = CALLOC( int, pCnf->nVars ); + pVarToPol = ABC_CALLOC( int, pCnf->nVars ); Aig_ManForEachObj( pCnf->pMan, pObj, i ) { if ( !fTransformPos && Aig_ObjIsPo(pObj) ) @@ -495,7 +495,7 @@ void Cnf_DataTranformPolarity( Cnf_Dat_t * pCnf, int fTransformPos ) if ( pVarToPol[iVar] ) pCnf->pClauses[0][i] = lit_neg( pCnf->pClauses[0][i] ); } - free( pVarToPol ); + ABC_FREE( pVarToPol ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/cnf/cnfMap.c b/src/aig/cnf/cnfMap.c index 8453e3cc..63625e6f 100644 --- a/src/aig/cnf/cnfMap.c +++ b/src/aig/cnf/cnfMap.c @@ -101,7 +101,7 @@ void Cnf_DeriveMapping( Cnf_Man_t * p ) Dar_Cut_t * pCut, * pCutBest; int i, k, AreaFlow, * pAreaFlows; // allocate area flows - pAreaFlows = ALLOC( int, Aig_ManObjNumMax(p->pManAig) ); + pAreaFlows = ABC_ALLOC( int, Aig_ManObjNumMax(p->pManAig) ); memset( pAreaFlows, 0, sizeof(int) * Aig_ManObjNumMax(p->pManAig) ); // visit the nodes in the topological order and update their best cuts vSuper = Vec_PtrAlloc( 100 ); @@ -136,7 +136,7 @@ void Cnf_DeriveMapping( Cnf_Man_t * p ) } } Vec_PtrFree( vSuper ); - free( pAreaFlows ); + ABC_FREE( pAreaFlows ); /* // compute the area of mapping diff --git a/src/aig/cnf/cnfWrite.c b/src/aig/cnf/cnfWrite.c index 8a6a9160..638e67da 100644 --- a/src/aig/cnf/cnfWrite.c +++ b/src/aig/cnf/cnfWrite.c @@ -205,17 +205,17 @@ Cnf_Dat_t * Cnf_ManWriteCnf( Cnf_Man_t * p, Vec_Ptr_t * vMapped, int nOutputs ) //printf( "\n" ); // allocate CNF - pCnf = ALLOC( Cnf_Dat_t, 1 ); + pCnf = ABC_ALLOC( Cnf_Dat_t, 1 ); memset( pCnf, 0, sizeof(Cnf_Dat_t) ); pCnf->pMan = p->pManAig; pCnf->nLiterals = nLiterals; pCnf->nClauses = nClauses; - pCnf->pClauses = ALLOC( int *, nClauses + 1 ); - pCnf->pClauses[0] = ALLOC( int, nLiterals ); + pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 ); + pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals ); pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals; // create room for variable numbers - pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(p->pManAig) ); + pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p->pManAig) ); // memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p->pManAig) ); for ( i = 0; i < Aig_ManObjNumMax(p->pManAig); i++ ) pCnf->pVarNums[i] = -1; @@ -356,17 +356,17 @@ Cnf_Dat_t * Cnf_DeriveSimple( Aig_Man_t * p, int nOutputs ) nClauses = 1 + 3 * Aig_ManNodeNum(p) + Aig_ManPoNum( p ) + nOutputs; // allocate CNF - pCnf = ALLOC( Cnf_Dat_t, 1 ); + pCnf = ABC_ALLOC( Cnf_Dat_t, 1 ); memset( pCnf, 0, sizeof(Cnf_Dat_t) ); pCnf->pMan = p; pCnf->nLiterals = nLiterals; pCnf->nClauses = nClauses; - pCnf->pClauses = ALLOC( int *, nClauses + 1 ); - pCnf->pClauses[0] = ALLOC( int, nLiterals ); + pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 ); + pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals ); pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals; // create room for variable numbers - pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(p) ); + pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p) ); // memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p) ); for ( i = 0; i < Aig_ManObjNumMax(p); i++ ) pCnf->pVarNums[i] = -1; @@ -478,17 +478,17 @@ Cnf_Dat_t * Cnf_DeriveSimpleForRetiming( Aig_Man_t * p ) nClauses = 1 + 3 * Aig_ManNodeNum(p) + 3 * Aig_ManPoNum(p); // allocate CNF - pCnf = ALLOC( Cnf_Dat_t, 1 ); + pCnf = ABC_ALLOC( Cnf_Dat_t, 1 ); memset( pCnf, 0, sizeof(Cnf_Dat_t) ); pCnf->pMan = p; pCnf->nLiterals = nLiterals; pCnf->nClauses = nClauses; - pCnf->pClauses = ALLOC( int *, nClauses + 1 ); - pCnf->pClauses[0] = ALLOC( int, nLiterals ); + pCnf->pClauses = ABC_ALLOC( int *, nClauses + 1 ); + pCnf->pClauses[0] = ABC_ALLOC( int, nLiterals ); pCnf->pClauses[nClauses] = pCnf->pClauses[0] + nLiterals; // create room for variable numbers - pCnf->pVarNums = ALLOC( int, Aig_ManObjNumMax(p) ); + pCnf->pVarNums = ABC_ALLOC( int, Aig_ManObjNumMax(p) ); // memset( pCnf->pVarNums, 0xff, sizeof(int) * Aig_ManObjNumMax(p) ); for ( i = 0; i < Aig_ManObjNumMax(p); i++ ) pCnf->pVarNums[i] = -1; diff --git a/src/aig/csw/csw.h b/src/aig/csw/csw.h index 1443f4d9..3d704d5f 100644 --- a/src/aig/csw/csw.h +++ b/src/aig/csw/csw.h @@ -21,10 +21,6 @@ #ifndef __CSW_H__ #define __CSW_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/csw/cswCut.c b/src/aig/csw/cswCut.c index a3d9b04e..14cc3e4c 100644 --- a/src/aig/csw/cswCut.c +++ b/src/aig/csw/cswCut.c @@ -78,7 +78,7 @@ static inline float Csw_CutFindCost2( Csw_Man_t * p, Csw_Cut_t * pCut ) /**Function************************************************************* - Synopsis [Returns the next free cut to use.] + Synopsis [Returns the next ABC_FREE cut to use.] Description [] diff --git a/src/aig/csw/cswInt.h b/src/aig/csw/cswInt.h index 37efe9b4..76c673a3 100644 --- a/src/aig/csw/cswInt.h +++ b/src/aig/csw/cswInt.h @@ -21,10 +21,6 @@ #ifndef __CSW_INT_H__ #define __CSW_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -44,6 +40,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/csw/cswMan.c b/src/aig/csw/cswMan.c index c3061dee..4225402c 100644 --- a/src/aig/csw/cswMan.c +++ b/src/aig/csw/cswMan.c @@ -47,7 +47,7 @@ Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer assert( nCutsMax >= 2 ); assert( nLeafMax <= 16 ); // allocate the fraiging manager - p = ALLOC( Csw_Man_t, 1 ); + p = ABC_ALLOC( Csw_Man_t, 1 ); memset( p, 0, sizeof(Csw_Man_t) ); p->nCutsMax = nCutsMax; p->nLeafMax = nLeafMax; @@ -57,9 +57,9 @@ Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer p->pManRes = Aig_ManStartFrom( pMan ); assert( Aig_ManPiNum(p->pManAig) == Aig_ManPiNum(p->pManRes) ); // allocate room for cuts and equivalent nodes - p->pnRefs = ALLOC( int, Aig_ManObjNumMax(pMan) ); - p->pEquiv = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMan) ); - p->pCuts = ALLOC( Csw_Cut_t *, Aig_ManObjNumMax(pMan) ); + p->pnRefs = ABC_ALLOC( int, Aig_ManObjNumMax(pMan) ); + p->pEquiv = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMan) ); + p->pCuts = ABC_ALLOC( Csw_Cut_t *, Aig_ManObjNumMax(pMan) ); memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pMan) ); memset( p->pnRefs, 0, sizeof(int) * Aig_ManObjNumMax(pMan) ); // allocate memory manager @@ -68,14 +68,14 @@ Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVer p->pMemCuts = Aig_MmFixedStart( p->nCutSize * p->nCutsMax, 512 ); // allocate hash table for cuts p->nTableSize = Aig_PrimeCudd( Aig_ManNodeNum(pMan) * p->nCutsMax / 2 ); - p->pTable = ALLOC( Csw_Cut_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Csw_Cut_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize ); // set the pointers to the available fraig nodes Csw_ObjSetEquiv( p, Aig_ManConst1(p->pManAig), Aig_ManConst1(p->pManRes) ); Aig_ManForEachPi( p->pManAig, pObj, i ) Csw_ObjSetEquiv( p, pObj, Aig_ManPi(p->pManRes, i) ); // room for temporary truth tables - p->puTemp[0] = ALLOC( unsigned, 4 * p->nTruthWords ); + p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords ); p->puTemp[1] = p->puTemp[0] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords; @@ -104,18 +104,18 @@ void Csw_ManStop( Csw_Man_t * p ) p->nNodesTried, Csw_TableCountCuts( p ) ); printf( "Triv0 = %6d. Triv1 = %6d. Triv2 = %6d. Cut-replace = %6d.\n", p->nNodesTriv0, p->nNodesTriv1, p->nNodesTriv2, p->nNodesCuts ); - PRTP( "Cuts ", p->timeCuts, p->timeTotal ); - PRTP( "Hashing ", p->timeHash, p->timeTotal ); - PRTP( "Other ", p->timeOther, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + ABC_PRTP( "Cuts ", p->timeCuts, p->timeTotal ); + ABC_PRTP( "Hashing ", p->timeHash, p->timeTotal ); + ABC_PRTP( "Other ", p->timeOther, p->timeTotal ); + ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); } - free( p->puTemp[0] ); + ABC_FREE( p->puTemp[0] ); Aig_MmFixedStop( p->pMemCuts, 0 ); - free( p->pnRefs ); - free( p->pEquiv ); - free( p->pCuts ); - free( p->pTable ); - free( p ); + ABC_FREE( p->pnRefs ); + ABC_FREE( p->pEquiv ); + ABC_FREE( p->pCuts ); + ABC_FREE( p->pTable ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/dar/dar.h b/src/aig/dar/dar.h index c2d53c89..86f43a9e 100644 --- a/src/aig/dar/dar.h +++ b/src/aig/dar/dar.h @@ -21,10 +21,6 @@ #ifndef __DAR_H__ #define __DAR_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -48,6 +48,7 @@ struct Dar_RwrPar_t_ int fUpdateLevel; // update level int fUseZeros; // performs zero-cost replacement int fPower; // enables power-aware rewriting + int fRecycle; // enables cut recycling int fVerbose; // enables verbose output int fVeryVerbose; // enables very verbose output }; diff --git a/src/aig/dar/darCore.c b/src/aig/dar/darCore.c index 957b4cc9..3c8423cf 100644 --- a/src/aig/dar/darCore.c +++ b/src/aig/dar/darCore.c @@ -48,6 +48,7 @@ void Dar_ManDefaultRwrParams( Dar_RwrPar_t * pPars ) pPars->fUpdateLevel = 0; pPars->fUseZeros = 0; pPars->fPower = 0; + pPars->fRecycle = 1; pPars->fVerbose = 0; pPars->fVeryVerbose = 0; } @@ -71,7 +72,7 @@ int Dar_ManRewrite( Aig_Man_t * pAig, Dar_RwrPar_t * pPars ) Dar_Cut_t * pCut; Aig_Obj_t * pObj, * pObjNew; int i, k, nNodesOld, nNodeBefore, nNodeAfter, Required; - int clk = 0, clkStart; + int clk = 0, clkStart, Counter = 0; // prepare the library Dar_LibPrepare( pPars->nSubgMax ); // create rewriting manager @@ -86,7 +87,7 @@ int Dar_ManRewrite( Aig_Man_t * pAig, Dar_RwrPar_t * pPars ) if ( p->pPars->fUpdateLevel ) Aig_ManStartReverseLevels( pAig, 0 ); // set elementary cuts for the PIs - Dar_ManCutsStart( p ); +// Dar_ManCutsStart( p ); // resynthesize each node once clkStart = clock(); p->nNodesInit = Aig_ManNodeNum(pAig); @@ -105,6 +106,13 @@ int Dar_ManRewrite( Aig_Man_t * pAig, Dar_RwrPar_t * pPars ) if ( i > nNodesOld ) // if ( p->pPars->fUseZeros && i > nNodesOld ) break; + if ( pPars->fRecycle && ++Counter % 50000 == 0 && Aig_DagSize(pObj) < Vec_PtrSize(p->vCutNodes)/100 ) + { +// printf( "Counter = %7d. Node = %7d. Dag = %5d. Vec = %5d.\n", +// Counter, i, Aig_DagSize(pObj), Vec_PtrSize(p->vCutNodes) ); +// fflush( stdout ); + Dar_ManCutsRestart( p, pObj ); + } // consider freeing the cuts // if ( (i & 0xFFF) == 0 && Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) > 100 ) @@ -173,7 +181,6 @@ p->timeTotal = clock() - clkStart; p->timeOther = p->timeTotal - p->timeCuts - p->timeEval; // Bar_ProgressStop( pProgress ); - p->nCutMemUsed = Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20); Dar_ManCutsFree( p ); // put the nodes into the DFS order and reassign their IDs // Aig_NtkReassignIds( p ); @@ -260,7 +267,11 @@ Aig_MmFixed_t * Dar_ManComputeCuts( Aig_Man_t * pAig, int nCutsMax, int fVerbose // create rewriting manager p = Dar_ManStart( pAig, pPars ); // set elementary cuts for the PIs - Dar_ManCutsStart( p ); +// Dar_ManCutsStart( p ); + Aig_MmFixedRestart( p->pMemCuts ); + Dar_ObjPrepareCuts( p, Aig_ManConst1(p->pAig) ); + Aig_ManForEachPi( pAig, pObj, i ) + Dar_ObjPrepareCuts( p, pObj ); // compute cuts for each nodes in the topological order Aig_ManForEachNode( pAig, pObj, i ) Dar_ObjComputeCuts( p, pObj ); @@ -274,14 +285,14 @@ Aig_MmFixed_t * Dar_ManComputeCuts( Aig_Man_t * pAig, int nCutsMax, int fVerbose Aig_ManObjNum(pAig), nCuts, nCutsK ); printf( "Cut size = %2d. Truth size = %2d. Total mem = %5.2f Mb ", (int)sizeof(Dar_Cut_t), (int)4, 1.0*Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) ); - PRT( "Runtime", clock() - clk ); + ABC_PRT( "Runtime", clock() - clk ); /* Aig_ManForEachNode( pAig, pObj, i ) if ( i % 300 == 0 ) Dar_ObjCutPrint( pAig, pObj ); */ } - // free the cuts + // ABC_FREE the cuts pMemCuts = p->pMemCuts; p->pMemCuts = NULL; // Dar_ManCutsFree( p ); diff --git a/src/aig/dar/darCut.c b/src/aig/dar/darCut.c index 6ebfec9d..1e1e4edb 100644 --- a/src/aig/dar/darCut.c +++ b/src/aig/dar/darCut.c @@ -127,7 +127,7 @@ static inline int Dar_CutFindValue( Dar_Man_t * p, Dar_Cut_t * pCut ) /**Function************************************************************* - Synopsis [Returns the next free cut to use.] + Synopsis [Returns the next ABC_FREE cut to use.] Description [Uses the cut with the smallest value.] @@ -585,9 +585,11 @@ Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj ) pObj->nCuts = p->pPars->nCutsMax; // create the cutset of the node pCutSet = (Dar_Cut_t *)Aig_MmFixedEntryFetch( p->pMemCuts ); + memset( pCutSet, 0, p->pPars->nCutsMax * sizeof(Dar_Cut_t) ); Dar_ObjSetCuts( pObj, pCutSet ); Dar_ObjForEachCutAll( pObj, pCut, i ) pCut->fUsed = 0; + Vec_PtrPush( p->vCutNodes, pObj ); // add unit cut if needed pCut = pCutSet; pCut->fUsed = 1; @@ -605,6 +607,8 @@ Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj ) pCut->uTruth = 0xAAAA; } pCut->Value = Dar_CutFindValue( p, pCut ); + if ( p->nCutMemUsed < Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) ) + p->nCutMemUsed = Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20); return pCutSet; } @@ -619,15 +623,16 @@ Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj ) SeeAlso [] ***********************************************************************/ -void Dar_ManCutsStart( Dar_Man_t * p ) +void Dar_ManCutsRestart( Dar_Man_t * p, Aig_Obj_t * pRoot ) { Aig_Obj_t * pObj; int i; - Aig_ManCleanData( p->pAig ); + Vec_PtrForEachEntry( p->vCutNodes, pObj, i ) + if ( !Aig_ObjIsNone(pObj) ) + Dar_ObjSetCuts( pObj, NULL ); + Vec_PtrClear( p->vCutNodes ); Aig_MmFixedRestart( p->pMemCuts ); Dar_ObjPrepareCuts( p, Aig_ManConst1(p->pAig) ); - Aig_ManForEachPi( p->pAig, pObj, i ) - Dar_ObjPrepareCuts( p, pObj ); } /**Function************************************************************* @@ -725,6 +730,8 @@ Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Aig_Obj_t * pObj ) { if ( Dar_ObjCuts(pObj) ) return Dar_ObjCuts(pObj); + if ( Aig_ObjIsPi(pObj) ) + return Dar_ObjPrepareCuts( p, pObj ); if ( Aig_ObjIsBuf(pObj) ) return Dar_ObjComputeCuts_rec( p, Aig_ObjFanin0(pObj) ); Dar_ObjComputeCuts_rec( p, Aig_ObjFanin0(pObj) ); diff --git a/src/aig/dar/darData.c b/src/aig/dar/darData.c index cb403b8a..e644c92b 100644 --- a/src/aig/dar/darData.c +++ b/src/aig/dar/darData.c @@ -11174,7 +11174,7 @@ void Aig_NtkGenerateArrays( Abc_Ntk_t * pNtk ) pObj->pCopy = (void *)Count++; Pos = 0; - pBuffer = ALLOC( char, 200000 ); + pBuffer = ABC_ALLOC( char, 200000 ); Abc_AigForEachAnd( pNtk, pObj, i ) { pObj->pCopy = (void *)Count++; @@ -11250,7 +11250,7 @@ void Aig_NtkGenerateArrays( Abc_Ntk_t * pNtk ) Vec_IntSort( vOuts, 0 ); Pos = 0; - pBuffer = ALLOC( char, 50000 ); + pBuffer = ABC_ALLOC( char, 50000 ); Prev = 0; Vec_IntForEachEntry( vOuts, Out, i ) { diff --git a/src/aig/dar/darInt.h b/src/aig/dar/darInt.h index afa3bd07..0f2e8894 100644 --- a/src/aig/dar/darInt.h +++ b/src/aig/dar/darInt.h @@ -21,10 +21,6 @@ #ifndef __DAR_INT_H__ #define __DAR_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -44,6 +40,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -72,6 +72,7 @@ struct Dar_Man_t_ // various data members Aig_MmFixed_t * pMemCuts; // memory manager for cuts void * pManCnf; // CNF managers + Vec_Ptr_t * vCutNodes; // the nodes with cuts allocated // current rewriting step Vec_Ptr_t * vLeavesBest; // the best set of leaves int OutBest; // the best output (in the library) @@ -130,8 +131,9 @@ static inline void Dar_ObjSetCuts( Aig_Obj_t * pObj, Dar_Cut_t * pCuts ) /*=== darBalance.c ========================================================*/ /*=== darCore.c ===========================================================*/ /*=== darCut.c ============================================================*/ -extern void Dar_ManCutsStart( Dar_Man_t * p ); +extern void Dar_ManCutsRestart( Dar_Man_t * p, Aig_Obj_t * pRoot ); extern void Dar_ManCutsFree( Dar_Man_t * p ); +extern Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj ); extern Dar_Cut_t * Dar_ObjComputeCuts_rec( Dar_Man_t * p, Aig_Obj_t * pObj ); extern Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Aig_Obj_t * pObj ); extern void Dar_ObjCutPrint( Aig_Man_t * p, Aig_Obj_t * pObj ); diff --git a/src/aig/dar/darLib.c b/src/aig/dar/darLib.c index 24693df2..c5fd4696 100644 --- a/src/aig/dar/darLib.c +++ b/src/aig/dar/darLib.c @@ -123,11 +123,11 @@ Dar_Lib_t * Dar_LibAlloc( int nObjs ) unsigned uTruths[4] = { 0xAAAA, 0xCCCC, 0xF0F0, 0xFF00 }; Dar_Lib_t * p; int i;//, clk = clock(); - p = ALLOC( Dar_Lib_t, 1 ); + p = ABC_ALLOC( Dar_Lib_t, 1 ); memset( p, 0, sizeof(Dar_Lib_t) ); // allocate objects p->nObjs = nObjs; - p->pObjs = ALLOC( Dar_LibObj_t, nObjs ); + p->pObjs = ABC_ALLOC( Dar_LibObj_t, nObjs ); memset( p->pObjs, 0, sizeof(Dar_LibObj_t) * nObjs ); // allocate canonical data p->pPerms4 = Dar_Permutations( 4 ); @@ -139,7 +139,7 @@ Dar_Lib_t * Dar_LibAlloc( int nObjs ) p->pObjs[i].fTerm = 1; p->pObjs[i].Num = uTruths[i]; } -// PRT( "Library start", clock() - clk ); +// ABC_PRT( "Library start", clock() - clk ); return p; } @@ -156,21 +156,21 @@ Dar_Lib_t * Dar_LibAlloc( int nObjs ) ***********************************************************************/ void Dar_LibFree( Dar_Lib_t * p ) { - free( p->pObjs ); - free( p->pDatas ); - free( p->pNodesMem ); - free( p->pNodes0Mem ); - free( p->pSubgrMem ); - free( p->pSubgr0Mem ); - free( p->pPriosMem ); - FREE( p->pPlaceMem ); - FREE( p->pScoreMem ); - free( p->pPerms4 ); - free( p->puCanons ); - free( p->pPhases ); - free( p->pPerms ); - free( p->pMap ); - free( p ); + ABC_FREE( p->pObjs ); + ABC_FREE( p->pDatas ); + ABC_FREE( p->pNodesMem ); + ABC_FREE( p->pNodes0Mem ); + ABC_FREE( p->pSubgrMem ); + ABC_FREE( p->pSubgr0Mem ); + ABC_FREE( p->pPriosMem ); + ABC_FREE( p->pPlaceMem ); + ABC_FREE( p->pScoreMem ); + ABC_FREE( p->pPerms4 ); + ABC_FREE( p->puCanons ); + ABC_FREE( p->pPhases ); + ABC_FREE( p->pPerms ); + ABC_FREE( p->pMap ); + ABC_FREE( p ); } /**Function************************************************************* @@ -275,8 +275,8 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios ) p->nSubgr[Class]++; } // allocate memory for the roots of each class - p->pSubgrMem = ALLOC( int, Vec_IntSize(vOuts) ); - p->pSubgr0Mem = ALLOC( int, Vec_IntSize(vOuts) ); + p->pSubgrMem = ABC_ALLOC( int, Vec_IntSize(vOuts) ); + p->pSubgr0Mem = ABC_ALLOC( int, Vec_IntSize(vOuts) ); p->nSubgrTotal = 0; for ( i = 0; i < 222; i++ ) { @@ -298,7 +298,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios ) if ( fTraining ) { // allocate memory for the priority of roots of each class - p->pPriosMem = ALLOC( int, Vec_IntSize(vOuts) ); + p->pPriosMem = ABC_ALLOC( int, Vec_IntSize(vOuts) ); p->nSubgrTotal = 0; for ( i = 0; i < 222; i++ ) { @@ -311,7 +311,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios ) assert( p->nSubgrTotal == Vec_IntSize(vOuts) ); // allocate memory for the priority of roots of each class - p->pPlaceMem = ALLOC( int, Vec_IntSize(vOuts) ); + p->pPlaceMem = ABC_ALLOC( int, Vec_IntSize(vOuts) ); p->nSubgrTotal = 0; for ( i = 0; i < 222; i++ ) { @@ -324,7 +324,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios ) assert( p->nSubgrTotal == Vec_IntSize(vOuts) ); // allocate memory for the priority of roots of each class - p->pScoreMem = ALLOC( int, Vec_IntSize(vOuts) ); + p->pScoreMem = ABC_ALLOC( int, Vec_IntSize(vOuts) ); p->nSubgrTotal = 0; for ( i = 0; i < 222; i++ ) { @@ -340,7 +340,7 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios ) { int Counter = 0; // allocate memory for the priority of roots of each class - p->pPriosMem = ALLOC( int, Vec_IntSize(vOuts) ); + p->pPriosMem = ABC_ALLOC( int, Vec_IntSize(vOuts) ); p->nSubgrTotal = 0; for ( i = 0; i < 222; i++ ) { @@ -366,8 +366,8 @@ void Dar_LibSetup( Dar_Lib_t * p, Vec_Int_t * vOuts, Vec_Int_t * vPrios ) for ( i = 0; i < 222; i++ ) p->nNodesTotal += p->nNodes[i]; // allocate memory for the nodes of each class - p->pNodesMem = ALLOC( int, p->nNodesTotal ); - p->pNodes0Mem = ALLOC( int, p->nNodesTotal ); + p->pNodesMem = ABC_ALLOC( int, p->nNodesTotal ); + p->pNodes0Mem = ABC_ALLOC( int, p->nNodesTotal ); p->nNodesTotal = 0; for ( i = 0; i < 222; i++ ) { @@ -409,10 +409,10 @@ void Dar_LibCreateData( Dar_Lib_t * p, int nDatas ) { if ( p->nDatas == nDatas ) return; - FREE( p->pDatas ); + ABC_FREE( p->pDatas ); // allocate datas p->nDatas = nDatas; - p->pDatas = ALLOC( Dar_LibDat_t, nDatas ); + p->pDatas = ABC_ALLOC( Dar_LibDat_t, nDatas ); memset( p->pDatas, 0, sizeof(Dar_LibDat_t) * nDatas ); } @@ -572,7 +572,7 @@ void Dar_LibStart() assert( s_DarLib == NULL ); s_DarLib = Dar_LibRead(); // printf( "The 4-input library started with %d nodes and %d subgraphs. ", s_DarLib->nObjs - 4, s_DarLib->nSubgrTotal ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); } /**Function************************************************************* diff --git a/src/aig/dar/darMan.c b/src/aig/dar/darMan.c index 9ab504c0..b11d3175 100644 --- a/src/aig/dar/darMan.c +++ b/src/aig/dar/darMan.c @@ -42,14 +42,13 @@ Dar_Man_t * Dar_ManStart( Aig_Man_t * pAig, Dar_RwrPar_t * pPars ) { Dar_Man_t * p; - // start the manager - p = ALLOC( Dar_Man_t, 1 ); + Aig_ManCleanData( pAig ); + p = ABC_ALLOC( Dar_Man_t, 1 ); memset( p, 0, sizeof(Dar_Man_t) ); p->pPars = pPars; p->pAig = pAig; - // prepare the internal memory manager + p->vCutNodes = Vec_PtrAlloc( 1000 ); p->pMemCuts = Aig_MmFixedStart( p->pPars->nCutsMax * sizeof(Dar_Cut_t), 1024 ); - // other data p->vLeavesBest = Vec_PtrAlloc( 4 ); return p; } @@ -69,11 +68,13 @@ void Dar_ManStop( Dar_Man_t * p ) { if ( p->pPars->fVerbose ) Dar_ManPrintStats( p ); + if ( p->vCutNodes ) + Vec_PtrFree( p->vCutNodes ); if ( p->pMemCuts ) Aig_MmFixedStop( p->pMemCuts, 0 ); if ( p->vLeavesBest ) Vec_PtrFree( p->vLeavesBest ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -102,10 +103,10 @@ void Dar_ManPrintStats( Dar_Man_t * p ) printf( "Bufs = %5d. BufMax = %5d. BufReplace = %6d. BufFix = %6d. Levels = %4d.\n", Aig_ManBufNum(p->pAig), p->pAig->nBufMax, p->pAig->nBufReplaces, p->pAig->nBufFixes, Aig_ManLevels(p->pAig) ); - PRT( "Cuts ", p->timeCuts ); - PRT( "Eval ", p->timeEval ); - PRT( "Other ", p->timeOther ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Cuts ", p->timeCuts ); + ABC_PRT( "Eval ", p->timeEval ); + ABC_PRT( "Other ", p->timeOther ); + ABC_PRT( "TOTAL ", p->timeTotal ); if ( !p->pPars->fVeryVerbose ) return; @@ -119,7 +120,7 @@ void Dar_ManPrintStats( Dar_Man_t * p ) printf( "S = %8d (%5.2f %%) ", p->ClassSubgs[i], p->nTotalSubgs? 100.0*p->ClassSubgs[i]/p->nTotalSubgs : 0.0 ); printf( "R = %7d ", p->ClassGains[i]? p->ClassSubgs[i]/p->ClassGains[i] : 9999999 ); // Kit_DsdPrintFromTruth( pCanons + i, 4 ); -// PRTP( "T", p->ClassTimes[i], p->timeEval ); +// ABC_PRTP( "T", p->ClassTimes[i], p->timeEval ); printf( "\n" ); } fflush( stdout ); diff --git a/src/aig/dar/darPrec.c b/src/aig/dar/darPrec.c index 8c3a4ce3..85a31dfc 100644 --- a/src/aig/dar/darPrec.c +++ b/src/aig/dar/darPrec.c @@ -45,7 +45,7 @@ char ** Dar_ArrayAlloc( int nCols, int nRows, int Size ) char * pBuffer; int i; assert( nCols > 0 && nRows > 0 && Size > 0 ); - pBuffer = ALLOC( char, nCols * (sizeof(void *) + nRows * Size) ); + pBuffer = ABC_ALLOC( char, nCols * (sizeof(void *) + nRows * Size) ); pRes = (char **)pBuffer; pRes[0] = pBuffer + nCols * sizeof(void *); for ( i = 1; i < nCols; i++ ) @@ -130,8 +130,8 @@ 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 free the resulting array, - call free() on the pointer returned by this procedure.] + two-dimentional array of the size: n! x n. To ABC_FREE the resulting array, + call ABC_FREE() on the pointer returned by this procedure.] SideEffects [] @@ -210,8 +210,8 @@ unsigned Dar_TruthPermute( unsigned Truth, char * pPerms, int nVars, int fRevers assert( nVars < 6 ); nMints = (1 << nVars); - pMints = ALLOC( int, nMints ); - pMintsP = ALLOC( int, nMints ); + pMints = ABC_ALLOC( int, nMints ); + pMintsP = ABC_ALLOC( int, nMints ); for ( i = 0; i < nMints; i++ ) pMints[i] = i; @@ -231,8 +231,8 @@ unsigned Dar_TruthPermute( unsigned Truth, char * pPerms, int nVars, int fRevers Result |= (1 << pMintsP[m]); } - free( pMints ); - free( pMintsP ); + ABC_FREE( pMints ); + ABC_FREE( pMintsP ); return Result; } @@ -297,10 +297,10 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP int i, k; nFuncs = (1 << 16); - uCanons = ALLOC( unsigned short, nFuncs ); - uPhases = ALLOC( char, nFuncs ); - uPerms = ALLOC( char, nFuncs ); - uMap = ALLOC( unsigned char, nFuncs ); + 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 ); @@ -361,23 +361,23 @@ void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puP } uPhases[(1<<16)-1] = 16; assert( nClasses == 222 ); - free( pPerms4 ); + ABC_FREE( pPerms4 ); if ( puCanons ) *puCanons = uCanons; else - free( uCanons ); + ABC_FREE( uCanons ); if ( puPhases ) *puPhases = uPhases; else - free( uPhases ); + ABC_FREE( uPhases ); if ( puPerms ) *puPerms = uPerms; else - free( uPerms ); + ABC_FREE( uPerms ); if ( puMap ) *puMap = uMap; else - free( uMap ); + ABC_FREE( uMap ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/dar/darRefact.c b/src/aig/dar/darRefact.c index ecf032be..f0173a3c 100644 --- a/src/aig/dar/darRefact.c +++ b/src/aig/dar/darRefact.c @@ -106,7 +106,7 @@ Ref_Man_t * Dar_ManRefStart( Aig_Man_t * pAig, Dar_RefPar_t * pPars ) { Ref_Man_t * p; // start the manager - p = ALLOC( Ref_Man_t, 1 ); + p = ABC_ALLOC( Ref_Man_t, 1 ); memset( p, 0, sizeof(Ref_Man_t) ); p->pAig = pAig; p->pPars = pPars; @@ -143,10 +143,10 @@ void Dar_ManRefPrintStats( Ref_Man_t * p ) p->nNodesInit, Aig_ManNodeNum(p->pAig), Gain, 100.0*Gain/p->nNodesInit ); printf( "Tried = %6d. Below = %5d. Extended = %5d. Used = %5d. Levels = %4d.\n", p->nNodesTried, p->nNodesBelow, p->nNodesExten, p->nCutsUsed, Aig_ManLevels(p->pAig) ); - PRT( "Cuts ", p->timeCuts ); - PRT( "Eval ", p->timeEval ); - PRT( "Other ", p->timeOther ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Cuts ", p->timeCuts ); + ABC_PRT( "Eval ", p->timeEval ); + ABC_PRT( "Other ", p->timeOther ); + ABC_PRT( "TOTAL ", p->timeTotal ); } /**Function************************************************************* @@ -172,7 +172,7 @@ void Dar_ManRefStop( Ref_Man_t * p ) Vec_PtrFree( p->vLeavesBest ); Vec_IntFree( p->vMemory ); Vec_PtrFree( p->vCutNodes ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/dar/darScript.c b/src/aig/dar/darScript.c index 6df776e6..383b5b6b 100644 --- a/src/aig/dar/darScript.c +++ b/src/aig/dar/darScript.c @@ -401,7 +401,7 @@ clk = clock(); if ( fVerbose ) { -PRT( "Synthesis time", clock() - clk ); +ABC_PRT( "Synthesis time", clock() - clk ); } clk = clock(); if ( fConstruct ) @@ -413,7 +413,7 @@ clk = clock(); Vec_PtrFree( vAigs ); if ( fVerbose ) { -PRT( "Choicing time ", clock() - clk ); +ABC_PRT( "Choicing time ", clock() - clk ); } return pMan; // return NULL; @@ -458,7 +458,7 @@ clk = clock(); if ( fVerbose ) { -PRT( "Synthesis time", clock() - clk ); +ABC_PRT( "Synthesis time", clock() - clk ); } // pPars->timeSynth = clock() - clk; @@ -493,7 +493,7 @@ clk = clock(); if ( fVerbose ) { -//PRT( "Choicing time ", clock() - clk ); +//ABC_PRT( "Choicing time ", clock() - clk ); } return pMan; // return NULL; diff --git a/src/aig/dch/dch.h b/src/aig/dch/dch.h index d0092a5f..a5a56da6 100644 --- a/src/aig/dch/dch.h +++ b/src/aig/dch/dch.h @@ -21,10 +21,6 @@ #ifndef __DCH_H__ #define __DCH_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/dch/dchChoice.c b/src/aig/dch/dchChoice.c index 19689051..019f4ec4 100644 --- a/src/aig/dch/dchChoice.c +++ b/src/aig/dch/dchChoice.c @@ -247,8 +247,8 @@ Aig_Man_t * Dch_DeriveChoiceAig( Aig_Man_t * pAig ) int i; // start recording equivalences pChoices = Aig_ManStart( Aig_ManObjNumMax(pAig) ); - pChoices->pEquivs = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) ); - pChoices->pReprs = CALLOC( Aig_Obj_t *, 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); @@ -262,7 +262,7 @@ Aig_Man_t * Dch_DeriveChoiceAig( Aig_Man_t * pAig ) Aig_ObjCreatePo( pChoices, Aig_ObjChild0CopyRepr(pChoices, pObj) ); Dch_DeriveChoiceCountEquivs( pChoices ); // there is no need for cleanup - FREE( pChoices->pReprs ); + ABC_FREE( pChoices->pReprs ); pChoices = Aig_ManDupDfs( pTemp = pChoices ); Aig_ManStop( pTemp ); return pChoices; diff --git a/src/aig/dch/dchClass.c b/src/aig/dch/dchClass.c index 5d042847..d8fbe8ed 100644 --- a/src/aig/dch/dchClass.c +++ b/src/aig/dch/dchClass.c @@ -134,11 +134,11 @@ static inline Aig_Obj_t ** Dch_ObjRemoveClass( Dch_Cla_t * p, Aig_Obj_t * pRepr Dch_Cla_t * Dch_ClassesStart( Aig_Man_t * pAig ) { Dch_Cla_t * p; - p = ALLOC( Dch_Cla_t, 1 ); + p = ABC_ALLOC( Dch_Cla_t, 1 ); memset( p, 0, sizeof(Dch_Cla_t) ); p->pAig = pAig; - p->pId2Class = CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) ); - p->pClassSizes = CALLOC( int, Aig_ManObjNumMax(pAig) ); + p->pId2Class = ABC_CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) ); + p->pClassSizes = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) ); p->vClassOld = Vec_PtrAlloc( 100 ); p->vClassNew = Vec_PtrAlloc( 100 ); assert( pAig->pReprs == NULL ); @@ -183,10 +183,10 @@ void Dch_ClassesStop( Dch_Cla_t * p ) { if ( p->vClassNew ) Vec_PtrFree( p->vClassNew ); if ( p->vClassOld ) Vec_PtrFree( p->vClassOld ); - FREE( p->pId2Class ); - FREE( p->pClassSizes ); - FREE( p->pMemClasses ); - free( p ); + ABC_FREE( p->pId2Class ); + ABC_FREE( p->pClassSizes ); + ABC_FREE( p->pMemClasses ); + ABC_FREE( p ); } /**Function************************************************************* @@ -338,8 +338,8 @@ void Dch_ClassesPrepare( Dch_Cla_t * p, int fLatchCorr, int nMaxLevs ) // allocate the hash table hashing simulation info into nodes nTableSize = Aig_PrimeCudd( Aig_ManObjNumMax(p->pAig)/4 ); - ppTable = CALLOC( Aig_Obj_t *, nTableSize ); - ppNexts = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) ); + ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize ); + ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) ); // add all the nodes to the hash table nEntries = 0; @@ -390,7 +390,7 @@ void Dch_ClassesPrepare( Dch_Cla_t * p, int fLatchCorr, int nMaxLevs ) } // allocate room for classes - p->pMemClasses = ALLOC( Aig_Obj_t *, nEntries + p->nCands1 ); + p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, nEntries + p->nCands1 ); p->pMemClassesFree = p->pMemClasses + nEntries; // copy the entries into storage in the topological order @@ -419,8 +419,8 @@ void Dch_ClassesPrepare( Dch_Cla_t * p, int fLatchCorr, int nMaxLevs ) nEntries2 += nNodes; } assert( nEntries == nEntries2 ); - free( ppTable ); - free( ppNexts ); + ABC_FREE( ppTable ); + ABC_FREE( ppNexts ); // now it is time to refine the classes Dch_ClassesRefine( p ); Dch_ClassesCheck( p ); diff --git a/src/aig/dch/dchCnf.c b/src/aig/dch/dchCnf.c index dc822d77..81fc2f2c 100644 --- a/src/aig/dch/dchCnf.c +++ b/src/aig/dch/dchCnf.c @@ -166,7 +166,7 @@ void Dch_AddClausesSuper( Dch_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) assert( Aig_ObjIsNode( pNode ) ); // create storage for literals nLits = Vec_PtrSize(vSuper) + 1; - pLits = ALLOC( int, nLits ); + pLits = ABC_ALLOC( int, nLits ); // suppose AND-gate is A & B = C // add !A => !C or A + !C Vec_PtrForEachEntry( vSuper, pFanin, i ) @@ -197,7 +197,7 @@ void Dch_AddClausesSuper( Dch_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) } RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits ); assert( RetValue ); - free( pLits ); + ABC_FREE( pLits ); } /**Function************************************************************* diff --git a/src/aig/dch/dchCore.c b/src/aig/dch/dchCore.c index 27c039cf..8e854355 100644 --- a/src/aig/dch/dchCore.c +++ b/src/aig/dch/dchCore.c @@ -93,7 +93,7 @@ p->timeChoice = clock() - clk; // pResult = Aig_ManDupSimpleDfs( p->pAigTotal ); // count the number of equivalences and choices p->nEquivs = Dch_DeriveChoiceCountEquivs( pResult ); - p->nChoices = Aig_ManCountChoices( pResult ); + p->nChoices = Aig_ManChoiceNum( pResult ); p->timeTotal = clock() - clkTotal; Dch_ManStop( p ); return pResult; diff --git a/src/aig/dch/dchInt.h b/src/aig/dch/dchInt.h index e9a6f2e4..4e6315a4 100644 --- a/src/aig/dch/dchInt.h +++ b/src/aig/dch/dchInt.h @@ -21,10 +21,6 @@ #ifndef __DCH_INT_H__ #define __DCH_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/dch/dchMan.c b/src/aig/dch/dchMan.c index a5faa2a6..caed0ed5 100644 --- a/src/aig/dch/dchMan.c +++ b/src/aig/dch/dchMan.c @@ -43,7 +43,7 @@ Dch_Man_t * Dch_ManCreate( Vec_Ptr_t * vAigs, Dch_Pars_t * pPars ) { Dch_Man_t * p; // create interpolation manager - p = ALLOC( Dch_Man_t, 1 ); + p = ABC_ALLOC( Dch_Man_t, 1 ); memset( p, 0, sizeof(Dch_Man_t) ); p->pPars = pPars; p->vAigs = vAigs; @@ -51,13 +51,13 @@ Dch_Man_t * Dch_ManCreate( Vec_Ptr_t * vAigs, Dch_Pars_t * pPars ) Aig_ManFanoutStart( p->pAigTotal ); // SAT solving p->nSatVars = 1; - p->pSatVars = CALLOC( int, Aig_ManObjNumMax(p->pAigTotal) ); + p->pSatVars = ABC_CALLOC( int, Aig_ManObjNumMax(p->pAigTotal) ); p->vUsedNodes = Vec_PtrAlloc( 1000 ); p->vFanins = Vec_PtrAlloc( 100 ); p->vSimRoots = Vec_PtrAlloc( 1000 ); p->vSimClasses = Vec_PtrAlloc( 1000 ); // equivalences proved - p->pReprsProved = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAigTotal) ); + p->pReprsProved = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAigTotal) ); return p; } @@ -95,18 +95,18 @@ void Dch_ManPrintStats( Dch_Man_t * p ) p->nLits, p->nReprs, p->nEquivs, p->nChoices ); printf( "Choicing runtime statistics:\n" ); p->timeOther = p->timeTotal-p->timeSimInit-p->timeSimSat-p->timeSat-p->timeChoice; - PRTP( "Sim init ", p->timeSimInit, p->timeTotal ); - PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal ); - PRTP( "SAT solving", p->timeSat, p->timeTotal ); - PRTP( " sat ", p->timeSatSat, p->timeTotal ); - PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); - PRTP( " undecided", p->timeSatUndec, p->timeTotal ); - PRTP( "Choice ", p->timeChoice, p->timeTotal ); - PRTP( "Other ", p->timeOther, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + 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 ); if ( p->pPars->timeSynth ) { - PRT( "Synthesis ", p->pPars->timeSynth ); + ABC_PRT( "Synthesis ", p->pPars->timeSynth ); } } @@ -137,9 +137,9 @@ void Dch_ManStop( Dch_Man_t * p ) Vec_PtrFree( p->vFanins ); Vec_PtrFree( p->vSimRoots ); Vec_PtrFree( p->vSimClasses ); - FREE( p->pReprsProved ); - FREE( p->pSatVars ); - free( p ); + ABC_FREE( p->pReprsProved ); + ABC_FREE( p->pSatVars ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/dch/dchSat.c b/src/aig/dch/dchSat.c index 07196259..6966e635 100644 --- a/src/aig/dch/dchSat.c +++ b/src/aig/dch/dchSat.c @@ -83,7 +83,7 @@ int Dch_NodesAreEquiv( Dch_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew ) //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); clk = clock(); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) { @@ -125,7 +125,7 @@ p->timeSatUndec += clock() - clk; } clk = clock(); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) { diff --git a/src/aig/dch/dchSweep.c b/src/aig/dch/dchSweep.c index 36c5fc33..afaf7426 100644 --- a/src/aig/dch/dchSweep.c +++ b/src/aig/dch/dchSweep.c @@ -127,7 +127,7 @@ void Dch_ManSweep( Dch_Man_t * p ) } Bar_ProgressStop( pProgress ); // update the representatives of the nodes (makes classes invalid) - FREE( p->pAigTotal->pReprs ); + ABC_FREE( p->pAigTotal->pReprs ); p->pAigTotal->pReprs = p->pReprsProved; p->pReprsProved = NULL; // clean the mark diff --git a/src/aig/deco/deco.h b/src/aig/deco/deco.h index 67126902..07afd15c 100644 --- a/src/aig/deco/deco.h +++ b/src/aig/deco/deco.h @@ -21,10 +21,6 @@ #ifndef __DEC_H__ #define __DEC_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -201,12 +201,12 @@ static inline Dec_Edge_t Dec_IntToEdge_( unsigned Edge ) static inline Dec_Graph_t * Dec_GraphCreate( int nLeaves ) { Dec_Graph_t * pGraph; - pGraph = ALLOC( Dec_Graph_t, 1 ); + pGraph = ABC_ALLOC( Dec_Graph_t, 1 ); memset( pGraph, 0, sizeof(Dec_Graph_t) ); pGraph->nLeaves = nLeaves; pGraph->nSize = nLeaves; pGraph->nCap = 2 * nLeaves + 50; - pGraph->pNodes = ALLOC( Dec_Node_t, pGraph->nCap ); + pGraph->pNodes = ABC_ALLOC( Dec_Node_t, pGraph->nCap ); memset( pGraph->pNodes, 0, sizeof(Dec_Node_t) * pGraph->nSize ); return pGraph; } @@ -225,7 +225,7 @@ static inline Dec_Graph_t * Dec_GraphCreate( int nLeaves ) static inline Dec_Graph_t * Dec_GraphCreateConst0() { Dec_Graph_t * pGraph; - pGraph = ALLOC( Dec_Graph_t, 1 ); + pGraph = ABC_ALLOC( Dec_Graph_t, 1 ); memset( pGraph, 0, sizeof(Dec_Graph_t) ); pGraph->fConst = 1; pGraph->eRoot.fCompl = 1; @@ -246,7 +246,7 @@ static inline Dec_Graph_t * Dec_GraphCreateConst0() static inline Dec_Graph_t * Dec_GraphCreateConst1() { Dec_Graph_t * pGraph; - pGraph = ALLOC( Dec_Graph_t, 1 ); + pGraph = ABC_ALLOC( Dec_Graph_t, 1 ); memset( pGraph, 0, sizeof(Dec_Graph_t) ); pGraph->fConst = 1; return pGraph; @@ -286,8 +286,8 @@ static inline Dec_Graph_t * Dec_GraphCreateLeaf( int iLeaf, int nLeaves, int fCo ***********************************************************************/ static inline void Dec_GraphFree( Dec_Graph_t * pGraph ) { - FREE( pGraph->pNodes ); - free( pGraph ); + ABC_FREE( pGraph->pNodes ); + ABC_FREE( pGraph ); } /**Function************************************************************* @@ -549,7 +549,7 @@ static inline Dec_Node_t * Dec_GraphAppendNode( Dec_Graph_t * pGraph ) Dec_Node_t * pNode; if ( pGraph->nSize == pGraph->nCap ) { - pGraph->pNodes = REALLOC( Dec_Node_t, pGraph->pNodes, 2 * pGraph->nCap ); + pGraph->pNodes = ABC_REALLOC( Dec_Node_t, pGraph->pNodes, 2 * pGraph->nCap ); pGraph->nCap = 2 * pGraph->nCap; } pNode = pGraph->pNodes + pGraph->nSize++; diff --git a/src/aig/fra/fra.h b/src/aig/fra/fra.h index e7cd0550..a2c10367 100644 --- a/src/aig/fra/fra.h +++ b/src/aig/fra/fra.h @@ -21,10 +21,6 @@ #ifndef __FRA_H__ #define __FRA_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -45,6 +41,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -215,8 +215,8 @@ struct Fra_Man_t_ sat_solver * pSat; // SAT solver int nSatVars; // the number of variables currently used Vec_Ptr_t * vPiVars; // the PIs of the cone used - sint64 nBTLimitGlobal; // resource limit - sint64 nInsLimitGlobal; // resource limit + ABC_INT64_T nBTLimitGlobal; // resource limit + ABC_INT64_T nInsLimitGlobal; // resource limit Vec_Ptr_t ** pMemFanins; // the arrays of fanins for some FRAIG nodes int * pMemSatNums; // the array of SAT numbers for some FRAIG nodes int nMemAlloc; // allocated size of the arrays for FRAIG varnums and fanins @@ -290,7 +290,7 @@ static inline int Fra_ImpCreate( int Left, int Right ) //////////////////////////////////////////////////////////////////////// /*=== fraCec.c ========================================================*/ -extern int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFlipBits, int fAndOuts, int fVerbose ); +extern int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fFlipBits, int fAndOuts, int fVerbose ); extern int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose ); extern int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimit, int nPartSize, int fSmart, int fVerbose ); /*=== fraClass.c ========================================================*/ @@ -376,7 +376,7 @@ extern void Fra_SmlSimulate( Fra_Man_t * p, int fInit ); extern void Fra_SmlResimulate( Fra_Man_t * p ); extern Fra_Sml_t * Fra_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFrame ); extern void Fra_SmlStop( Fra_Sml_t * p ); -extern Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords ); +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 ); diff --git a/src/aig/fra/fraBmc.c b/src/aig/fra/fraBmc.c index 411ca2c1..689d7d67 100644 --- a/src/aig/fra/fraBmc.c +++ b/src/aig/fra/fraBmc.c @@ -188,13 +188,13 @@ void Fra_BmcFilterImplications( Fra_Man_t * p, Fra_Bmc_t * pBmc ) Fra_Bmc_t * Fra_BmcStart( Aig_Man_t * pAig, int nPref, int nDepth ) { Fra_Bmc_t * p; - p = ALLOC( Fra_Bmc_t, 1 ); + p = ABC_ALLOC( Fra_Bmc_t, 1 ); memset( p, 0, sizeof(Fra_Bmc_t) ); p->pAig = pAig; p->nPref = nPref; p->nDepth = nDepth; p->nFramesAll = nPref + nDepth; - p->pObjToFrames = ALLOC( Aig_Obj_t *, p->nFramesAll * Aig_ManObjNumMax(pAig) ); + p->pObjToFrames = ABC_ALLOC( Aig_Obj_t *, p->nFramesAll * Aig_ManObjNumMax(pAig) ); memset( p->pObjToFrames, 0, sizeof(Aig_Obj_t *) * p->nFramesAll * Aig_ManObjNumMax(pAig) ); return p; } @@ -215,9 +215,9 @@ void Fra_BmcStop( Fra_Bmc_t * p ) Aig_ManStop( p->pAigFrames ); if ( p->pAigFraig ) Aig_ManStop( p->pAigFraig ); - free( p->pObjToFrames ); - free( p->pObjToFraig ); - free( p ); + ABC_FREE( p->pObjToFrames ); + ABC_FREE( p->pObjToFraig ); + ABC_FREE( p ); } /**Function************************************************************* @@ -253,7 +253,7 @@ Aig_Man_t * Fra_BmcFrames( Fra_Bmc_t * p, int fKeepPos ) Bmc_ObjSetFrames( pObj, 0, Aig_ManConst0(pAigFrames) ); // add timeframes - pLatches = ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) ); + pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) ); for ( f = 0; f < p->nFramesAll; f++ ) { // add internal nodes of this frame @@ -275,7 +275,7 @@ Aig_Man_t * Fra_BmcFrames( Fra_Bmc_t * p, int fKeepPos ) Bmc_ObjSetFrames( pObj, f+1, pLatches[k++] ); assert( k == Aig_ManRegNum(p->pAig) ); } - free( pLatches ); + ABC_FREE( pLatches ); if ( fKeepPos ) { for ( f = 0; f < p->nFramesAll; f++ ) @@ -333,7 +333,7 @@ void Fra_BmcPerform( Fra_Man_t * p, int nPref, int nDepth ) printf( "Original AIG = %d. Init %d frames = %d. Fraig = %d. ", Aig_ManNodeNum(p->pBmc->pAig), p->pBmc->nFramesAll, Aig_ManNodeNum(p->pBmc->pAigFrames), Aig_ManNodeNum(p->pBmc->pAigFraig) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); printf( "Before BMC: " ); // Fra_ClassesPrint( p->pCla, 0 ); printf( "Const = %5d. Class = %5d. Lit = %5d. ", @@ -360,7 +360,7 @@ void Fra_BmcPerform( Fra_Man_t * p, int nPref, int nDepth ) printf( "Imp = %5d. ", Vec_IntSize(p->pCla->vImps) ); printf( "\n" ); } - // free the BMC manager + // ABC_FREE the BMC manager Fra_BmcStop( p->pBmc ); p->pBmc = NULL; } @@ -397,7 +397,7 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew printf( "Time-frames (%d): PI/PO = %d/%d. Node = %6d. Lev = %5d. ", nFrames, Aig_ManPiNum(pBmc->pAigFrames), Aig_ManPoNum(pBmc->pAigFrames), Aig_ManNodeNum(pBmc->pAigFrames), Aig_ManLevelNum(pBmc->pAigFrames) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } if ( fRewrite ) { @@ -408,7 +408,7 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew { printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ", Aig_ManNodeNum(pBmc->pAigFrames), Aig_ManLevelNum(pBmc->pAigFrames) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } } clk = clock(); @@ -422,7 +422,7 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew if ( pBmc->pAigFraig->pData ) { pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pBmc->pAigFrames, pBmc->pAigFraig->pData ); - FREE( pBmc->pAigFraig->pData ); + ABC_FREE( pBmc->pAigFraig->pData ); } else if ( iOutput >= 0 ) pAig->pSeqModel = Fra_SmlTrivCounterExample( pAig, iOutput ); @@ -432,10 +432,10 @@ void Fra_BmcPerformSimple( Aig_Man_t * pAig, int nFrames, int nBTLimit, int fRew printf( "Fraiged init frames: Node = %6d. Lev = %5d. ", pBmc->pAigFraig? Aig_ManNodeNum(pBmc->pAigFraig) : -1, pBmc->pAigFraig? Aig_ManLevelNum(pBmc->pAigFraig) : -1 ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } Fra_BmcStop( pBmc ); - free( pTemp ); + ABC_FREE( pTemp ); } diff --git a/src/aig/fra/fraCec.c b/src/aig/fra/fraCec.c index 2cdf203d..0cc6748c 100644 --- a/src/aig/fra/fraCec.c +++ b/src/aig/fra/fraCec.c @@ -40,7 +40,7 @@ SeeAlso [] ***********************************************************************/ -int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFlipBits, int fAndOuts, int fVerbose ) +int Fra_FraigSat( Aig_Man_t * pMan, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fFlipBits, int fAndOuts, int fVerbose ) { sat_solver * pSat; Cnf_Dat_t * pCnf; @@ -91,13 +91,13 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl // printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) ); -// PRT( "Time", clock() - clk ); +// ABC_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 ); +// ABC_PRT( "Time", clock() - clk ); if ( status == 0 ) { Vec_IntFree( vCiIds ); @@ -110,7 +110,7 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl clk = clock(); if ( fVerbose ) pSat->verbosity = 1; - status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)nInsLimit, (sint64)0, (sint64)0 ); + 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" ); @@ -128,7 +128,7 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl } else assert( 0 ); -// PRT( "SAT sat_solver time", clock() - clk ); +// ABC_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 @@ -136,7 +136,7 @@ int Fra_FraigSat( Aig_Man_t * pMan, sint64 nConfLimit, sint64 nInsLimit, int fFl { pMan->pData = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize ); } - // free the sat_solver + // ABC_FREE the sat_solver if ( fVerbose ) Sat_SolverPrintStats( stdout, pSat ); //sat_solver_store_write( pSat, "trace.cnf" ); @@ -176,18 +176,18 @@ int Fra_FraigCec( Aig_Man_t ** ppAig, int nConfLimit, int fVerbose ) // assert( RetValue == -1 ); if ( RetValue == 0 ) { - pAig->pData = ALLOC( int, Aig_ManPiNum(pAig) ); + pAig->pData = ABC_ALLOC( int, Aig_ManPiNum(pAig) ); memset( pAig->pData, 0, sizeof(int) * Aig_ManPiNum(pAig) ); return RetValue; } // if SAT only, solve without iteration clk = clock(); - RetValue = Fra_FraigSat( pAig, (sint64)2*nBTLimitStart, (sint64)0, 1, 0, 0 ); + RetValue = Fra_FraigSat( pAig, (ABC_INT64_T)2*nBTLimitStart, (ABC_INT64_T)0, 1, 0, 0 ); if ( fVerbose ) { printf( "Initial SAT: Nodes = %6d. ", Aig_ManNodeNum(pAig) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } if ( RetValue >= 0 ) return RetValue; @@ -199,7 +199,7 @@ clk = clock(); if ( fVerbose ) { printf( "Rewriting: Nodes = %6d. ", Aig_ManNodeNum(pAig) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } // perform the loop @@ -218,7 +218,7 @@ clk = clock(); if ( fVerbose ) { printf( "Fraiging (i=%d): Nodes = %6d. ", i+1, Aig_ManNodeNum(pAig) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } // check the miter status @@ -233,7 +233,7 @@ clk = clock(); if ( fVerbose ) { printf( "Rewriting: Nodes = %6d. ", Aig_ManNodeNum(pAig) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } // check the miter status @@ -251,11 +251,11 @@ PRT( "Time", clock() - clk ); if ( RetValue == -1 ) { clk = clock(); - RetValue = Fra_FraigSat( pAig, (sint64)nBTLimitLast, (sint64)0, 1, 0, 0 ); + RetValue = Fra_FraigSat( pAig, (ABC_INT64_T)nBTLimitLast, (ABC_INT64_T)0, 1, 0, 0 ); if ( fVerbose ) { printf( "Final SAT: Nodes = %6d. ", Aig_ManNodeNum(pAig) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } @@ -318,7 +318,7 @@ int Fra_FraigCecPartitioned( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimi printf( "Timed out after verifying %d partitions (out of %d).\n", nOutputs, Vec_PtrSize(vParts) ); fflush( stdout ); } - // free intermediate results + // ABC_FREE intermediate results Vec_PtrForEachEntry( vParts, pAig, i ) Aig_ManStop( pAig ); Vec_PtrFree( vParts ); @@ -373,17 +373,17 @@ int Fra_FraigCecTop( Aig_Man_t * pMan1, Aig_Man_t * pMan2, int nConfLimit, int n if ( RetValue == 1 ) { printf( "Networks are equivalent. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else if ( RetValue == 0 ) { printf( "Networks are NOT EQUIVALENT. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else { printf( "Networks are UNDECIDED. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } fflush( stdout ); return RetValue; diff --git a/src/aig/fra/fraClass.c b/src/aig/fra/fraClass.c index 064d2b9c..8554b312 100644 --- a/src/aig/fra/fraClass.c +++ b/src/aig/fra/fraClass.c @@ -57,10 +57,10 @@ static inline void Fra_ObjSetNext( Aig_Obj_t ** ppNexts, Aig_Obj_t * pOb Fra_Cla_t * Fra_ClassesStart( Aig_Man_t * pAig ) { Fra_Cla_t * p; - p = ALLOC( Fra_Cla_t, 1 ); + p = ABC_ALLOC( Fra_Cla_t, 1 ); memset( p, 0, sizeof(Fra_Cla_t) ); p->pAig = pAig; - p->pMemRepr = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) ); + p->pMemRepr = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) ); memset( p->pMemRepr, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) ); p->vClasses = Vec_PtrAlloc( 100 ); p->vClasses1 = Vec_PtrAlloc( 100 ); @@ -86,15 +86,15 @@ Fra_Cla_t * Fra_ClassesStart( Aig_Man_t * pAig ) ***********************************************************************/ void Fra_ClassesStop( Fra_Cla_t * p ) { - FREE( p->pMemClasses ); - FREE( p->pMemRepr ); + ABC_FREE( p->pMemClasses ); + ABC_FREE( p->pMemRepr ); if ( p->vClassesTemp ) Vec_PtrFree( p->vClassesTemp ); if ( p->vClassNew ) Vec_PtrFree( p->vClassNew ); if ( p->vClassOld ) Vec_PtrFree( p->vClassOld ); if ( p->vClasses1 ) Vec_PtrFree( p->vClasses1 ); if ( p->vClasses ) Vec_PtrFree( p->vClasses ); if ( p->vImps ) Vec_IntFree( p->vImps ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -278,8 +278,8 @@ void Fra_ClassesPrepare( Fra_Cla_t * p, int fLatchCorr, int nMaxLevs ) // allocate the hash table hashing simulation info into nodes nTableSize = Aig_PrimeCudd( Aig_ManObjNumMax(p->pAig) ); - ppTable = ALLOC( Aig_Obj_t *, nTableSize ); - ppNexts = ALLOC( Aig_Obj_t *, nTableSize ); + ppTable = ABC_ALLOC( Aig_Obj_t *, nTableSize ); + ppNexts = ABC_ALLOC( Aig_Obj_t *, nTableSize ); memset( ppTable, 0, sizeof(Aig_Obj_t *) * nTableSize ); // add all the nodes to the hash table @@ -338,7 +338,7 @@ void Fra_ClassesPrepare( Fra_Cla_t * p, int fLatchCorr, int nMaxLevs ) } // allocate room for classes - p->pMemClasses = ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) ); + p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->vClasses1)) ); p->pMemClassesFree = p->pMemClasses + 2*nEntries; // copy the entries into storage in the topological order @@ -374,8 +374,8 @@ void Fra_ClassesPrepare( Fra_Cla_t * p, int fLatchCorr, int nMaxLevs ) // increment the number of entries nEntries += k; } - free( ppTable ); - free( ppNexts ); + ABC_FREE( ppTable ); + ABC_FREE( ppNexts ); // now it is time to refine the classes Fra_ClassesRefine( p ); // Fra_ClassesPrint( p, 0 ); @@ -587,7 +587,7 @@ int Fra_ClassesRefine1( Fra_Cla_t * p, int fRefineNewClass, int * pSkipped ) void Fra_ClassesTest( Fra_Cla_t * p, int Id1, int Id2 ) { Aig_Obj_t ** pClass; - p->pMemClasses = ALLOC( Aig_Obj_t *, 4 ); + p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 4 ); pClass = p->pMemClasses; assert( Id1 < Id2 ); pClass[0] = Aig_ManObj( p->pAig, Id1 ); @@ -620,7 +620,7 @@ void Fra_ClassesLatchCorr( Fra_Man_t * p ) Fra_ClassObjSetRepr( pObj, Aig_ManConst1(p->pManAig) ); } // allocate room for classes - p->pCla->pMemClasses = ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->pCla->vClasses1)) ); + p->pCla->pMemClasses = ABC_ALLOC( Aig_Obj_t *, 2*(nEntries + Vec_PtrSize(p->pCla->vClasses1)) ); p->pCla->pMemClassesFree = p->pCla->pMemClasses + 2*nEntries; } @@ -644,7 +644,7 @@ void Fra_ClassesPostprocess( Fra_Cla_t * p ) // perform combinational simulation pComb = Fra_SmlSimulateComb( p->pAig, 32 ); // compute the weight of each node in the classes - pWeights = ALLOC( int, Aig_ManObjNumMax(p->pAig) ); + pWeights = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) ); memset( pWeights, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) ); Aig_ManForEachObj( p->pAig, pObj, i ) { @@ -686,7 +686,7 @@ void Fra_ClassesPostprocess( Fra_Cla_t * p ) Vec_PtrWriteEntry( p->vClasses, k++, ppClass ); Vec_PtrShrink( p->vClasses, k ); printf( "After: Const = %6d. Class = %6d. \n", Vec_PtrSize(p->vClasses1), Vec_PtrSize(p->vClasses) ); - free( pWeights ); + ABC_FREE( pWeights ); } /**Function************************************************************* @@ -804,13 +804,13 @@ Aig_Man_t * Fra_ClassesDeriveAig( Fra_Cla_t * p, int nFramesK ) pManFraig->pName = Aig_UtilStrsav( p->pAig->pName ); pManFraig->pSpec = Aig_UtilStrsav( p->pAig->pSpec ); // allocate place for the node mapping - ppEquivs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) ); + ppEquivs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) ); Fra_ObjSetEqu( ppEquivs, Aig_ManConst1(p->pAig), Aig_ManConst1(pManFraig) ); // create latches for the first frame Aig_ManForEachLoSeq( p->pAig, pObj, i ) Fra_ObjSetEqu( ppEquivs, pObj, Aig_ObjCreatePi(pManFraig) ); // add timeframes - pLatches = ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) ); + pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p->pAig) ); for ( f = 0; f < nFramesAll; f++ ) { // create PIs for this frame @@ -839,8 +839,8 @@ Aig_Man_t * Fra_ClassesDeriveAig( Fra_Cla_t * p, int nFramesK ) Aig_ManForEachLoSeq( p->pAig, pObj, i ) Fra_ObjSetEqu( ppEquivs, pObj, pLatches[k++] ); } - free( pLatches ); - free( ppEquivs ); + ABC_FREE( pLatches ); + ABC_FREE( ppEquivs ); // mark the asserts assert( Aig_ManPoNum(pManFraig) % nFramesAll == 0 ); printf( "Assert miters = %6d. Output miters = %6d.\n", diff --git a/src/aig/fra/fraClau.c b/src/aig/fra/fraClau.c index 919d0000..96d06380 100644 --- a/src/aig/fra/fraClau.c +++ b/src/aig/fra/fraClau.c @@ -152,7 +152,7 @@ int * Fra_ClauCreateMapping( Vec_Int_t * vSatVarsFrom, Vec_Int_t * vSatVarsTo, i { int * pMapping, Var, i; assert( Vec_IntSize(vSatVarsFrom) == Vec_IntSize(vSatVarsTo) ); - pMapping = ALLOC( int, nVarsMax ); + pMapping = ABC_ALLOC( int, nVarsMax ); for ( i = 0; i < nVarsMax; i++ ) pMapping[i] = -1; Vec_IntForEachEntry( vSatVarsFrom, Var, i ) @@ -174,10 +174,10 @@ int * Fra_ClauCreateMapping( Vec_Int_t * vSatVarsFrom, Vec_Int_t * vSatVarsTo, i ***********************************************************************/ void Fra_ClauStop( Cla_Man_t * p ) { - free( p->pMapCsMainToCsTest ); - free( p->pMapCsTestToCsMain ); - free( p->pMapCsTestToNsTest ); - free( p->pMapCsTestToNsBmc ); + ABC_FREE( p->pMapCsMainToCsTest ); + ABC_FREE( p->pMapCsTestToCsMain ); + ABC_FREE( p->pMapCsTestToNsTest ); + ABC_FREE( p->pMapCsTestToNsBmc ); Vec_IntFree( p->vSatVarsMainCs ); Vec_IntFree( p->vSatVarsTestCs ); Vec_IntFree( p->vSatVarsTestNs ); @@ -191,7 +191,7 @@ void Fra_ClauStop( Cla_Man_t * p ) if ( p->pSatMain ) sat_solver_delete( p->pSatMain ); if ( p->pSatTest ) sat_solver_delete( p->pSatTest ); if ( p->pSatBmc ) sat_solver_delete( p->pSatBmc ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -217,7 +217,7 @@ Cla_Man_t * Fra_ClauStart( Aig_Man_t * pMan ) assert( Aig_ManPoNum(pMan) - Aig_ManRegNum(pMan) == 1 ); // start the manager - p = ALLOC( Cla_Man_t, 1 ); + p = ABC_ALLOC( Cla_Man_t, 1 ); memset( p, 0, sizeof(Cla_Man_t) ); p->vCexMain0 = Vec_IntAlloc( Aig_ManRegNum(pMan) ); p->vCexMain = Vec_IntAlloc( Aig_ManRegNum(pMan) ); @@ -362,7 +362,7 @@ int Fra_ClauCheckProperty( Cla_Man_t * p, Vec_Int_t * vCex ) int nBTLimit = 0; int RetValue, iVar, i; sat_solver_act_var_clear( p->pSatMain ); - RetValue = sat_solver_solve( p->pSatMain, NULL, NULL, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSatMain, NULL, NULL, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); Vec_IntClear( vCex ); if ( RetValue == l_False ) return 1; @@ -396,7 +396,7 @@ int Fra_ClauCheckBmc( Cla_Man_t * p, Vec_Int_t * vClause ) int nBTLimit = 0; int RetValue; RetValue = sat_solver_solve( p->pSatBmc, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause), - (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( RetValue == l_False ) return 1; assert( RetValue == l_True ); @@ -458,7 +458,7 @@ int Fra_ClauCheckClause( Cla_Man_t * p, Vec_Int_t * vClause, Vec_Int_t * vCex ) Vec_IntPush( p->vCexAssm, toLitCond(i,0) ); // positive helper // try to solve RetValue = sat_solver_solve( p->pSatTest, Vec_IntArray(p->vCexAssm), Vec_IntArray(p->vCexAssm) + Vec_IntSize(p->vCexAssm), - (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( vCex ) Vec_IntClear( vCex ); if ( RetValue == l_False ) diff --git a/src/aig/fra/fraClaus.c b/src/aig/fra/fraClaus.c index 91b70702..e5fe3f40 100644 --- a/src/aig/fra/fraClaus.c +++ b/src/aig/fra/fraClaus.c @@ -98,7 +98,7 @@ int Fra_ClausRunBmc( Clu_Man_t * p ) for ( i = 0; i < p->nPref + p->nFrames; i++ ) { Lits[0] = i * nLitsTot + toLitCond( p->pCnf->pVarNums[pObj->Id], 0 ); - RetValue = sat_solver_solve( p->pSatBmc, Lits, Lits + 1, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSatBmc, Lits, Lits + 1, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( RetValue != l_False ) return 0; } @@ -121,14 +121,14 @@ int Fra_ClausRunSat( Clu_Man_t * p ) Aig_Obj_t * pObj; int * pLits; int i, RetValue; - pLits = ALLOC( int, p->nFrames + 1 ); + pLits = ABC_ALLOC( int, p->nFrames + 1 ); // set the output literals pObj = Aig_ManPo(p->pAig, 0); for ( i = 0; i <= p->nFrames; i++ ) pLits[i] = i * 2 * p->pCnf->nVars + toLitCond( p->pCnf->pVarNums[pObj->Id], i != p->nFrames ); // try to solve the problem - RetValue = sat_solver_solve( p->pSatMain, pLits, pLits + p->nFrames + 1, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); - free( pLits ); + RetValue = sat_solver_solve( p->pSatMain, pLits, pLits + p->nFrames + 1, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); + ABC_FREE( pLits ); if ( RetValue == l_False ) return 1; // get the counter-example @@ -153,7 +153,7 @@ int Fra_ClausRunSat0( Clu_Man_t * p ) int Lits[2], RetValue; pObj = Aig_ManPo(p->pAig, 0); Lits[0] = toLitCond( p->pCnf->pVarNums[pObj->Id], 0 ); - RetValue = sat_solver_solve( p->pSatMain, Lits, Lits + 1, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSatMain, Lits, Lits + 1, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( RetValue == l_False ) return 1; return 0; @@ -350,7 +350,7 @@ int Fra_ClausSelectClauses( Clu_Man_t * p ) assert( Vec_IntSize(p->vClauses) > p->nClausesMax ); // count how many implications have each cost CostMax = p->nSimWords * 32 + 1; - pCostCount = ALLOC( int, CostMax ); + pCostCount = ABC_ALLOC( int, CostMax ); memset( pCostCount, 0, sizeof(int) * CostMax ); Vec_IntForEachEntry( p->vCosts, Cost, i ) { @@ -380,7 +380,7 @@ int Fra_ClausSelectClauses( Clu_Man_t * p ) } Vec_IntWriteEntry( p->vCosts, i, -1 ); } - free( pCostCount ); + ABC_FREE( pCostCount ); p->nClauses = nClauCount; if ( p->fVerbose ) printf( "Selected %d clauses. Cost range: [%d < %d < %d]\n", nClauCount, 1, c, CostMax ); @@ -608,7 +608,7 @@ int Fra_ClausProcessClauses( Clu_Man_t * p, int fRefs ) clk = clock(); // srand( 0xAABBAABB ); Aig_ManRandom(1); - pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames ); + pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames, 1 ); if ( p->fTarget && pSeq->fNonConstOut ) { printf( "Property failed after sequential simulation!\n" ); @@ -617,7 +617,7 @@ clk = clock(); } if ( p->fVerbose ) { -PRT( "Sim-seq", clock() - clk ); +ABC_PRT( "Sim-seq", clock() - clk ); } @@ -627,7 +627,7 @@ clk = clock(); Fra_ClausCollectLatchClauses( p, pSeq ); if ( p->fVerbose ) { -PRT( "Lat-cla", clock() - clk ); +ABC_PRT( "Lat-cla", clock() - clk ); } } @@ -638,7 +638,7 @@ clk = clock(); // pManCut = Aig_ComputeCuts( p->pAig, 10, 4, 0, 1 ); if ( p->fVerbose ) { -PRT( "Cuts ", clock() - clk ); +ABC_PRT( "Cuts ", clock() - clk ); } // collect sequential info for each cut @@ -656,7 +656,7 @@ clk = clock(); } if ( p->fVerbose ) { -PRT( "Infoseq", clock() - clk ); +ABC_PRT( "Infoseq", clock() - clk ); } Fra_SmlStop( pSeq ); @@ -667,7 +667,7 @@ clk = clock(); pComb = Fra_SmlSimulateComb( p->pAig, p->nSimWords + p->nSimWordsPref ); if ( p->fVerbose ) { -PRT( "Sim-cmb", clock() - clk ); +ABC_PRT( "Sim-cmb", clock() - clk ); } // collect combinational info for each cut @@ -692,7 +692,7 @@ clk = clock(); // Aig_ManCutStop( pManCut ); if ( p->fVerbose ) { -PRT( "Infocmb", clock() - clk ); +ABC_PRT( "Infocmb", clock() - clk ); } if ( p->fVerbose ) @@ -732,7 +732,7 @@ int Fra_ClausProcessClauses2( Clu_Man_t * p, int fRefs ) clk = clock(); // srand( 0xAABBAABB ); Aig_ManRandom(1); - pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames ); + pSeq = Fra_SmlSimulateSeq( p->pAig, 0, p->nPref + p->nSimFrames, p->nSimWords/p->nSimFrames, 1 ); if ( p->fTarget && pSeq->fNonConstOut ) { printf( "Property failed after sequential simulation!\n" ); @@ -741,7 +741,7 @@ clk = clock(); } if ( p->fVerbose ) { -//PRT( "Sim-seq", clock() - clk ); +//ABC_PRT( "Sim-seq", clock() - clk ); } // perform combinational simulation @@ -751,7 +751,7 @@ clk = clock(); pComb = Fra_SmlSimulateComb( p->pAig, p->nSimWords + p->nSimWordsPref ); if ( p->fVerbose ) { -//PRT( "Sim-cmb", clock() - clk ); +//ABC_PRT( "Sim-cmb", clock() - clk ); } @@ -761,7 +761,7 @@ clk = clock(); Fra_ClausCollectLatchClauses( p, pSeq ); if ( p->fVerbose ) { -//PRT( "Lat-cla", clock() - clk ); +//ABC_PRT( "Lat-cla", clock() - clk ); } } @@ -772,7 +772,7 @@ clk = clock(); pManCut = Aig_ComputeCuts( p->pAig, p->nCutsMax, p->nLutSize, 0, p->fVerbose ); if ( p->fVerbose ) { -//PRT( "Cuts ", clock() - clk ); +//ABC_PRT( "Cuts ", clock() - clk ); } // collect combinational info for each cut @@ -805,7 +805,7 @@ clk = clock(); { printf( "Node = %5d. Cuts = %7d. Clauses = %6d. Clause/cut = %6.2f.\n", Aig_ManNodeNum(p->pAig), nCuts, Vec_IntSize(p->vClauses), 1.0*Vec_IntSize(p->vClauses)/nCuts ); - PRT( "Processing sim-info to find candidate clauses (unoptimized)", clock() - clk ); + ABC_PRT( "Processing sim-info to find candidate clauses (unoptimized)", clock() - clk ); } // filter out clauses that are contained in the already proven clauses @@ -852,7 +852,7 @@ clk = clock(); // check the clause for ( k = Beg; k < End; k++ ) pStart[k] = lit_neg( pStart[k] ); - RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); for ( k = Beg; k < End; k++ ) pStart[k] = lit_neg( pStart[k] ); // the clause holds @@ -924,7 +924,7 @@ int Fra_ClausBmcClauses( Clu_Man_t * p ) for ( k = Beg; k < End; k++ ) pStart[k] = lit_neg( pStart[k] ); - RetValue = sat_solver_solve( p->pSatBmc, pStart + Beg, pStart + End, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSatBmc, pStart + Beg, pStart + End, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); for ( k = Beg; k < End; k++ ) pStart[k] = lit_neg( pStart[k] ); @@ -1292,7 +1292,7 @@ int Fra_ClausInductiveClauses( Clu_Man_t * p ) for ( k = Beg; k < End; k++ ) pStart[k] = lit_neg( pStart[k] ); - RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (sint64)p->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSatMain, pStart + Beg, pStart + End, (ABC_INT64_T)p->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); for ( k = Beg; k < End; k++ ) pStart[k] = lit_neg( pStart[k] ); @@ -1359,7 +1359,7 @@ int Fra_ClausInductiveClauses( Clu_Man_t * p ) Clu_Man_t * Fra_ClausAlloc( Aig_Man_t * pAig, int nFrames, int nPref, int nClausesMax, int nLutSize, int nLevels, int nCutsMax, int nBatches, int fStepUp, int fTarget, int fVerbose, int fVeryVerbose ) { Clu_Man_t * p; - p = ALLOC( Clu_Man_t, 1 ); + p = ABC_ALLOC( Clu_Man_t, 1 ); memset( p, 0, sizeof(Clu_Man_t) ); p->pAig = pAig; p->nFrames = nFrames; @@ -1412,7 +1412,7 @@ void Fra_ClausFree( Clu_Man_t * p ) if ( p->pCnf ) Cnf_DataFree( p->pCnf ); if ( p->pSatMain ) sat_solver_delete( p->pSatMain ); if ( p->pSatBmc ) sat_solver_delete( p->pSatBmc ); - free( p ); + ABC_FREE( p ); } @@ -1540,7 +1540,7 @@ void Fra_ClausWriteIndClauses( Clu_Man_t * p ) int * pStart, * pVar2Id; int Beg, End, i, k; // create mapping from SAT vars to node IDs - pVar2Id = ALLOC( int, p->pCnf->nVars ); + pVar2Id = ABC_ALLOC( int, p->pCnf->nVars ); memset( pVar2Id, 0xFF, sizeof(int) * p->pCnf->nVars ); for ( i = 0; i < Aig_ManObjNumMax(p->pAig); i++ ) if ( p->pCnf->pVarNums[i] >= 0 ) @@ -1564,7 +1564,7 @@ void Fra_ClausWriteIndClauses( Clu_Man_t * p ) Aig_ObjCreatePo( pNew, pClause ); Beg = End; } - free( pVar2Id ); + ABC_FREE( pVar2Id ); Aig_ManCleanup( pNew ); pName = Ioa_FileNameGenericAppend( p->pAig->pName, "_care.aig" ); printf( "Care one-hotness clauses will be written into file \"%s\".\n", pName ); @@ -1624,7 +1624,7 @@ void Fra_ClausEstimateCoverage( Clu_Man_t * p ) Aig_ManRandom(1); pComb = Fra_SmlSimulateComb( p->pAig, nCombSimWords ); // create mapping from SAT vars to node IDs - pVar2Id = ALLOC( int, p->pCnf->nVars ); + pVar2Id = ABC_ALLOC( int, p->pCnf->nVars ); memset( pVar2Id, 0, sizeof(int) * p->pCnf->nVars ); for ( i = 0; i < Aig_ManObjNumMax(p->pAig); i++ ) if ( p->pCnf->pVarNums[i] >= 0 ) @@ -1654,11 +1654,11 @@ void Fra_ClausEstimateCoverage( Clu_Man_t * p ) for ( w = 0; w < nCombSimWords; w++ ) nCovered += Aig_WordCountOnes( pResultTot[w] ); Fra_SmlStop( pComb ); - free( pVar2Id ); + ABC_FREE( pVar2Id ); // print the result printf( "Care states ratio = %f. ", 1.0 * (nCombSimWords * 32 - nCovered) / (nCombSimWords * 32) ); printf( "(%d out of %d patterns) ", nCombSimWords * 32 - nCovered, nCombSimWords * 32 ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } @@ -1686,7 +1686,7 @@ if ( p->fVerbose ) { printf( "PARAMETERS: Frames = %d. Pref = %d. Clauses max = %d. Cut size = %d.\n", nFrames, nPref, nClausesMax, nLutSize ); printf( "Level max = %d. Cuts max = %d. Batches = %d. Increment cut size = %s.\n", nLevels, nCutsMax, nBatches, fStepUp? "yes":"no" ); -//PRT( "Sim-seq", clock() - clk ); +//ABC_PRT( "Sim-seq", clock() - clk ); } assert( !p->fTarget || Aig_ManPoNum(pAig) - Aig_ManRegNum(pAig) == 1 ); @@ -1700,7 +1700,7 @@ clk = clock(); // p->pAig->nRegs--; if ( fVerbose ) { -//PRT( "CNF ", clock() - clk ); +//ABC_PRT( "CNF ", clock() - clk ); } // check BMC @@ -1720,7 +1720,7 @@ clk = clock(); } if ( fVerbose ) { -//PRT( "SAT-bmc", clock() - clk ); +//ABC_PRT( "SAT-bmc", clock() - clk ); } // start the SAT solver @@ -1751,7 +1751,7 @@ clk = clock(); } if ( fVerbose ) { -// PRT( "SAT-ind", clock() - clk ); +// ABC_PRT( "SAT-ind", clock() - clk ); } // collect the candidate inductive clauses using 4-cuts @@ -1763,7 +1763,7 @@ clk = clock(); p->nSimWordsPref = p->nPref*p->nSimWords/p->nSimFrames; nClausesBeg = p->nClauses; - //PRT( "Clauses", clock() - clk ); + //ABC_PRT( "Clauses", clock() - clk ); // check clauses using BMC @@ -1775,7 +1775,7 @@ clk = clock(); if ( fVerbose ) { printf( "BMC disproved %d clauses. ", Counter ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } } @@ -1794,7 +1794,7 @@ clk = clock(); { printf( "End = %5d. Exs = %5d. ", p->nClauses, p->nCexes ); // printf( "\n" ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } clk = clock(); } @@ -1809,14 +1809,14 @@ clk = clock(); printf( "Property FAILS during refinement. " ); else printf( "Property HOLDS inductively after strengthening. " ); - PRT( "Time ", clock() - clkTotal ); + ABC_PRT( "Time ", clock() - clkTotal ); if ( !p->fFail ) break; } else { printf( "Finished proving inductive clauses. " ); - PRT( "Time ", clock() - clkTotal ); + ABC_PRT( "Time ", clock() - clkTotal ); } } diff --git a/src/aig/fra/fraCnf.c b/src/aig/fra/fraCnf.c index d96fe8a1..27da3fc5 100644 --- a/src/aig/fra/fraCnf.c +++ b/src/aig/fra/fraCnf.c @@ -131,7 +131,7 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) assert( Aig_ObjIsNode( pNode ) ); // create storage for literals nLits = Vec_PtrSize(vSuper) + 1; - pLits = ALLOC( int, nLits ); + pLits = ABC_ALLOC( int, nLits ); // suppose AND-gate is A & B = C // add !A => !C or A + !C Vec_PtrForEachEntry( vSuper, pFanin, i ) @@ -147,7 +147,7 @@ void Fra_AddClausesSuper( Fra_Man_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) pLits[nLits-1] = toLitCond(Fra_ObjSatNum(pNode), 0); RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits ); assert( RetValue ); - free( pLits ); + ABC_FREE( pLits ); } /**Function************************************************************* diff --git a/src/aig/fra/fraHot.c b/src/aig/fra/fraHot.c index b2156193..c4472121 100644 --- a/src/aig/fra/fraHot.c +++ b/src/aig/fra/fraHot.c @@ -378,7 +378,7 @@ void Fra_OneHotEstimateCoverage( Fra_Man_t * p, Vec_Int_t * vOneHots ) // print the result printf( "Care states ratio = %f. ", 1.0 * (nSimWords * 32 - nCovered) / (nSimWords * 32) ); printf( "(%d out of %d patterns) ", nSimWords * 32 - nCovered, nSimWords * 32 ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } /**Function************************************************************* diff --git a/src/aig/fra/fraImp.c b/src/aig/fra/fraImp.c index e2bee834..d579146e 100644 --- a/src/aig/fra/fraImp.c +++ b/src/aig/fra/fraImp.c @@ -64,7 +64,7 @@ static inline int * Fra_SmlCountOnes( Fra_Sml_t * p ) { Aig_Obj_t * pObj; int i, * pnBits; - pnBits = ALLOC( int, Aig_ManObjNumMax(p->pAig) ); + pnBits = ABC_ALLOC( int, Aig_ManObjNumMax(p->pAig) ); memset( pnBits, 0, sizeof(int) * Aig_ManObjNumMax(p->pAig) ); Aig_ManForEachObj( p->pAig, pObj, i ) pnBits[i] = Fra_SmlCountOnesOne( p, i ); @@ -159,7 +159,7 @@ Vec_Ptr_t * Fra_SmlSortUsingOnes( Fra_Sml_t * p, int fLatchCorr ) // count number of nodes having that many 1s nNodes = 0; nBits = p->nWordsTotal * 32; - pnNodes = ALLOC( int, nBits + 1 ); + pnNodes = ABC_ALLOC( int, nBits + 1 ); memset( pnNodes, 0, sizeof(int) * (nBits + 1) ); Aig_ManForEachObj( p->pAig, pObj, i ) { @@ -183,7 +183,7 @@ Vec_Ptr_t * Fra_SmlSortUsingOnes( Fra_Sml_t * p, int fLatchCorr ) nNodes++; } // allocate memory for all the nodes - pMemory = ALLOC( int, nNodes + nBits + 1 ); + pMemory = ABC_ALLOC( int, nNodes + nBits + 1 ); // markup the memory for each node vNodes = Vec_PtrAlloc( nBits + 1 ); Vec_PtrPush( vNodes, pMemory ); @@ -222,8 +222,8 @@ Vec_Ptr_t * Fra_SmlSortUsingOnes( Fra_Sml_t * p, int fLatchCorr ) nTotal += pnNodes[i]; } assert( nTotal == nNodes + nBits + 1 ); - free( pnNodes ); - free( pnBits ); + ABC_FREE( pnNodes ); + ABC_FREE( pnBits ); return vNodes; } @@ -244,7 +244,7 @@ Vec_Int_t * Fra_SmlSelectMaxCost( Vec_Int_t * vImps, int * pCosts, int nCostMax, int * pCostCount, nImpCount, Imp, i, c; assert( Vec_IntSize(vImps) >= nImpLimit ); // count how many implications have each cost - pCostCount = ALLOC( int, nCostMax + 1 ); + pCostCount = ABC_ALLOC( int, nCostMax + 1 ); memset( pCostCount, 0, sizeof(int) * (nCostMax + 1) ); for ( i = 0; i < Vec_IntSize(vImps); i++ ) { @@ -271,7 +271,7 @@ Vec_Int_t * Fra_SmlSelectMaxCost( Vec_Int_t * vImps, int * pCosts, int nCostMax, if ( Vec_IntSize( vImpsNew ) == nImpLimit ) break; } - free( pCostCount ); + ABC_FREE( pCostCount ); if ( pCostRange ) *pCostRange = c; return vImpsNew; @@ -329,7 +329,7 @@ Vec_Int_t * Fra_ImpDerive( Fra_Man_t * p, int nImpMaxLimit, int nImpUseLimit, in assert( nImpMaxLimit > 0 && nImpUseLimit > 0 && nImpUseLimit <= nImpMaxLimit ); // normalize both managers pComb = Fra_SmlSimulateComb( p->pManAig, nSimWords ); - pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nSimWords, 1 ); + pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nSimWords, 1, 1 ); // get the nodes sorted by the number of 1s vNodes = Fra_SmlSortUsingOnes( pSeq, fLatchCorr ); // count the total number of implications @@ -340,7 +340,7 @@ Vec_Int_t * Fra_ImpDerive( Fra_Man_t * p, int nImpMaxLimit, int nImpUseLimit, in nImpsTotal++; // compute implications and their costs - pImpCosts = ALLOC( int, nImpMaxLimit ); + pImpCosts = ABC_ALLOC( int, nImpMaxLimit ); vImps = Vec_IntAlloc( nImpMaxLimit ); for ( k = pSeq->nWordsTotal * 32; k > 0; k-- ) for ( i = k - 1; i > 0; i-- ) @@ -384,8 +384,11 @@ finish: } // dealloc - free( pImpCosts ); - free( Vec_PtrEntry(vNodes, 0) ); + ABC_FREE( pImpCosts ); + { + void * pTemp = Vec_PtrEntry(vNodes, 0); + ABC_FREE( pTemp ); + } Vec_PtrFree( vNodes ); // reorder implications topologically qsort( (void *)Vec_IntArray(vImps), Vec_IntSize(vImps), sizeof(int), @@ -396,7 +399,7 @@ printf( "Implications: All = %d. Try = %d. NonSeq = %d. Comb = %d. Res = %d.\n", nImpsTotal, nImpsTried, nImpsNonSeq, nImpsComb, nImpsCollected ); printf( "Implication weight: Min = %d. Pivot = %d. Max = %d. ", CostMin, CostRange, CostMax ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } return vImps; } @@ -665,9 +668,9 @@ int Fra_ImpVerifyUsingSimulation( Fra_Man_t * p ) if ( p->pCla->vImps == NULL || Vec_IntSize(p->pCla->vImps) == 0 ) return 0; // simulate the AIG manager with combinational patterns - pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nFrames, nSimWords ); + pSeq = Fra_SmlSimulateSeq( p->pManAig, p->pPars->nFramesP, nFrames, nSimWords, 1 ); // go through the implications and check how many of them do not hold - pfFails = ALLOC( char, Vec_IntSize(p->pCla->vImps) ); + pfFails = ABC_ALLOC( char, Vec_IntSize(p->pCla->vImps) ); memset( pfFails, 0, sizeof(char) * Vec_IntSize(p->pCla->vImps) ); Vec_IntForEachEntry( p->pCla->vImps, Imp, i ) { @@ -679,7 +682,7 @@ int Fra_ImpVerifyUsingSimulation( Fra_Man_t * p ) Counter = 0; for ( i = 0; i < Vec_IntSize(p->pCla->vImps); i++ ) Counter += pfFails[i]; - free( pfFails ); + ABC_FREE( pfFails ); Fra_SmlStop( pSeq ); return Counter; } diff --git a/src/aig/fra/fraInd.c b/src/aig/fra/fraInd.c index c8b35b28..4f3812c6 100644 --- a/src/aig/fra/fraInd.c +++ b/src/aig/fra/fraInd.c @@ -198,7 +198,7 @@ void Fra_FramesAddMore( Aig_Man_t * p, int nFrames ) pObj->pData = pObj; // iterate and add objects nNodesOld = Aig_ManObjNumMax(p); - pLatches = ALLOC( Aig_Obj_t *, Aig_ManRegNum(p) ); + pLatches = ABC_ALLOC( Aig_Obj_t *, Aig_ManRegNum(p) ); for ( f = 0; f < nFrames; f++ ) { // clean latch inputs and outputs @@ -230,7 +230,7 @@ void Fra_FramesAddMore( Aig_Man_t * p, int nFrames ) pObj->pData = NULL; } } - free( pLatches ); + ABC_FREE( pLatches ); } @@ -308,7 +308,7 @@ Aig_Man_t * Fra_FraigInductionPart( Aig_Man_t * pAig, Fra_Ssw_t * pPars ) i, Vec_IntSize(vPart), Aig_ManPiNum(pTemp)-Vec_IntSize(vPart), nCountPis, nCountRegs, Aig_ManNodeNum(pTemp), pPars->nIters, nClasses ); Aig_ManStop( pNew ); Aig_ManStop( pTemp ); - free( pMapBack ); + ABC_FREE( pMapBack ); } // remap the AIG pNew = Aig_ManDupRepr( pAig, 0 ); @@ -320,7 +320,7 @@ Aig_Man_t * Fra_FraigInductionPart( Aig_Man_t * pAig, Fra_Ssw_t * pPars ) pPars->fVerbose = fVerbose; if ( fVerbose ) { - PRT( "Total time", clock() - clk ); + ABC_PRT( "Total time", clock() - clk ); } return pNew; } @@ -420,10 +420,10 @@ Aig_Man_t * Fra_FraigInduction( Aig_Man_t * pManAig, Fra_Ssw_t * pParams ) // refine the classes with more simulation rounds if ( pPars->fVerbose ) printf( "Simulating %d AIG nodes for %d cycles ... ", Aig_ManNodeNum(pManAig), pPars->nFramesP + 32 ); - p->pSml = Fra_SmlSimulateSeq( pManAig, pPars->nFramesP, 32, 1 ); //pPars->nFramesK + 1, 1 ); + p->pSml = Fra_SmlSimulateSeq( pManAig, pPars->nFramesP, 32, 1, 1 ); //pPars->nFramesK + 1, 1 ); if ( pPars->fVerbose ) { -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } Fra_ClassesPrepare( p->pCla, p->pPars->fLatchCorr, p->pPars->nMaxLevs ); // Fra_ClassesPostprocess( p->pCla ); @@ -556,7 +556,7 @@ clk2 = clock(); Fra_FraigSweep( p ); if ( pPars->fVerbose ) { - PRT( "T", clock() - clk3 ); + ABC_PRT( "T", clock() - clk3 ); } // Sat_SolverPrintStats( stdout, p->pSat ); @@ -589,7 +589,7 @@ clk2 = clock(); printf( "Implications failing the simulation test = %d (out of %d). ", Temp, Vec_IntSize(p->pCla->vImps) ); else printf( "All %d implications have passed the simulation test. ", Vec_IntSize(p->pCla->vImps) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } */ @@ -629,7 +629,7 @@ p->timeTotal = clock() - clk; p->nLitsEnd = Fra_ClassesCountLits( p->pCla ); p->nNodesEnd = Aig_ManNodeNum(pManAigNew); p->nRegsEnd = Aig_ManRegNum(pManAigNew); - // free the manager + // ABC_FREE the manager finish: Fra_ManStop( p ); // check the output diff --git a/src/aig/fra/fraIndVer.c b/src/aig/fra/fraIndVer.c index efc516c9..71faa346 100644 --- a/src/aig/fra/fraIndVer.c +++ b/src/aig/fra/fraIndVer.c @@ -150,7 +150,7 @@ int Fra_InvariantVerify( Aig_Man_t * pAig, int nFrames, Vec_Int_t * vClauses, Ve if ( CounterBase || CounterInd ) return 0; printf( "Invariant verification: %d clauses verified correctly. ", Vec_IntSize(vClauses) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); return 1; } diff --git a/src/aig/fra/fraLcr.c b/src/aig/fra/fraLcr.c index d3be9842..16912f46 100644 --- a/src/aig/fra/fraLcr.c +++ b/src/aig/fra/fraLcr.c @@ -77,12 +77,12 @@ struct Fra_Lcr_t_ Fra_Lcr_t * Lcr_ManAlloc( Aig_Man_t * pAig ) { Fra_Lcr_t * p; - p = ALLOC( Fra_Lcr_t, 1 ); + p = ABC_ALLOC( Fra_Lcr_t, 1 ); memset( p, 0, sizeof(Fra_Lcr_t) ); p->pAig = pAig; - p->pInToOutPart = ALLOC( int, Aig_ManPiNum(pAig) ); + p->pInToOutPart = ABC_ALLOC( int, Aig_ManPiNum(pAig) ); memset( p->pInToOutPart, 0, sizeof(int) * Aig_ManPiNum(pAig) ); - p->pInToOutNum = ALLOC( int, Aig_ManPiNum(pAig) ); + p->pInToOutNum = ABC_ALLOC( int, Aig_ManPiNum(pAig) ); memset( p->pInToOutNum, 0, sizeof(int) * Aig_ManPiNum(pAig) ); p->vFraigs = Vec_PtrAlloc( 1000 ); return p; @@ -106,12 +106,12 @@ void Lcr_ManPrint( Fra_Lcr_t * p ) printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n", p->nNodesBeg, p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg, p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/p->nRegsBeg ); - PRT( "AIG simulation ", p->timeSim ); - PRT( "AIG partitioning", p->timePart ); - PRT( "AIG rebuiding ", p->timeTrav ); - PRT( "FRAIGing ", p->timeFraig ); - PRT( "AIG updating ", p->timeUpdate ); - PRT( "TOTAL RUNTIME ", p->timeTotal ); + ABC_PRT( "AIG simulation ", p->timeSim ); + ABC_PRT( "AIG partitioning", p->timePart ); + ABC_PRT( "AIG rebuiding ", p->timeTrav ); + ABC_PRT( "FRAIGing ", p->timeFraig ); + ABC_PRT( "AIG updating ", p->timeUpdate ); + ABC_PRT( "TOTAL RUNTIME ", p->timeTotal ); } /**Function************************************************************* @@ -136,9 +136,9 @@ void Lcr_ManFree( Fra_Lcr_t * p ) Vec_PtrFree( p->vFraigs ); if ( p->pCla ) Fra_ClassesStop( p->pCla ); if ( p->vParts ) Vec_VecFree( (Vec_Vec_t *)p->vParts ); - free( p->pInToOutPart ); - free( p->pInToOutNum ); - free( p ); + ABC_FREE( p->pInToOutPart ); + ABC_FREE( p->pInToOutNum ); + ABC_FREE( p ); } /**Function************************************************************* @@ -157,7 +157,7 @@ Fra_Man_t * Fra_LcrAigPrepare( Aig_Man_t * pAig ) Fra_Man_t * p; Aig_Obj_t * pObj; int i; - p = ALLOC( Fra_Man_t, 1 ); + p = ABC_ALLOC( Fra_Man_t, 1 ); memset( p, 0, sizeof(Fra_Man_t) ); // Aig_ManForEachPi( pAig, pObj, i ) Aig_ManForEachObj( pAig, pObj, i ) @@ -550,10 +550,10 @@ Aig_Man_t * Fra_FraigLatchCorrespondence( Aig_Man_t * pAig, int nFramesP, int nC clk2 = clock(); if ( fVerbose ) printf( "Simulating AIG with %d nodes for %d cycles ... ", Aig_ManNodeNum(pAig), nFramesP + 32 ); - pSml = Fra_SmlSimulateSeq( pAig, nFramesP, 32, 1 ); + pSml = Fra_SmlSimulateSeq( pAig, nFramesP, 32, 1, 1 ); if ( fVerbose ) { -PRT( "Time", clock() - clk2 ); +ABC_PRT( "Time", clock() - clk2 ); } timeSim = clock() - clk2; @@ -592,7 +592,7 @@ printf( "Partitioning AIG ... " ); Aig_ManStop( pAigPart ); if ( fVerbose ) { -PRT( "Time", clock() - clk2 ); +ABC_PRT( "Time", clock() - clk2 ); p->timePart += clock() - clk2; } @@ -636,7 +636,7 @@ p->timeFraig += clock() - clk2; Aig_ManDumpBlif( pAigPart, Name, NULL, NULL ); } printf( "Finished part %4d (out of %4d). ", i, Vec_PtrSize(p->vParts) ); -PRT( "Time", clock() - clk3 ); +ABC_PRT( "Time", clock() - clk3 ); */ Aig_ManStop( pAigPart ); @@ -648,7 +648,7 @@ PRT( "Time", clock() - clk3 ); printf( "%3d : Const = %6d. Class = %6d. L = %6d. Part = %3d. ", nIter, Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses), Fra_ClassesCountLits(p->pCla), Vec_PtrSize(p->vParts) ); - PRT( "T", clock() - clk3 ); + ABC_PRT( "T", clock() - clk3 ); } // refine the classes Fra_LcrAigPrepareTwo( p->pAig, pTemp ); @@ -690,7 +690,7 @@ p->timeTotal = clock() - clk; p->nNodesEnd = Aig_ManNodeNum(pAigNew); p->nRegsEnd = Aig_ManRegNum(pAigNew); finish: - free( pTemp ); + ABC_FREE( pTemp ); Lcr_ManFree( p ); if ( pnIter ) *pnIter = nIter; return pAigNew; diff --git a/src/aig/fra/fraMan.c b/src/aig/fra/fraMan.c index b8cf13c5..8bdd147d 100644 --- a/src/aig/fra/fraMan.c +++ b/src/aig/fra/fraMan.c @@ -104,7 +104,7 @@ Fra_Man_t * Fra_ManStart( Aig_Man_t * pManAig, Fra_Par_t * pPars ) Aig_Obj_t * pObj; int i; // allocate the fraiging manager - p = ALLOC( Fra_Man_t, 1 ); + p = ABC_ALLOC( Fra_Man_t, 1 ); memset( p, 0, sizeof(Fra_Man_t) ); p->pPars = pPars; p->pManAig = pManAig; @@ -112,12 +112,12 @@ Fra_Man_t * Fra_ManStart( Aig_Man_t * pManAig, Fra_Par_t * pPars ) p->nFramesAll = pPars->nFramesK + 1; // allocate storage for sim pattern p->nPatWords = Aig_BitWordNum( (Aig_ManPiNum(pManAig) - Aig_ManRegNum(pManAig)) * p->nFramesAll + Aig_ManRegNum(pManAig) ); - p->pPatWords = ALLOC( unsigned, p->nPatWords ); + p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords ); p->vPiVars = Vec_PtrAlloc( 100 ); // equivalence classes p->pCla = Fra_ClassesStart( pManAig ); // allocate other members - p->pMemFraig = ALLOC( Aig_Obj_t *, p->nSizeAlloc * p->nFramesAll ); + p->pMemFraig = ABC_ALLOC( Aig_Obj_t *, p->nSizeAlloc * p->nFramesAll ); memset( p->pMemFraig, 0, sizeof(Aig_Obj_t *) * p->nSizeAlloc * p->nFramesAll ); // set random number generator // srand( 0xABCABC ); @@ -150,8 +150,8 @@ void Fra_ManClean( Fra_Man_t * p, int nNodesMax ) if ( p->nMemAlloc < nNodesMax ) { int nMemAllocNew = nNodesMax + 5000; - p->pMemFanins = REALLOC( Vec_Ptr_t *, p->pMemFanins, nMemAllocNew ); - p->pMemSatNums = REALLOC( int, p->pMemSatNums, nMemAllocNew ); + p->pMemFanins = ABC_REALLOC( Vec_Ptr_t *, p->pMemFanins, nMemAllocNew ); + p->pMemSatNums = ABC_REALLOC( int, p->pMemSatNums, nMemAllocNew ); p->nMemAlloc = nMemAllocNew; } // prepare for the new run @@ -191,9 +191,9 @@ Aig_Man_t * Fra_ManPrepareComb( Fra_Man_t * p ) pObj->pData = p; // allocate memory for mapping FRAIG nodes into SAT numbers and fanins p->nMemAlloc = p->nSizeAlloc; - p->pMemFanins = ALLOC( Vec_Ptr_t *, p->nMemAlloc ); + p->pMemFanins = ABC_ALLOC( Vec_Ptr_t *, p->nMemAlloc ); memset( p->pMemFanins, 0, sizeof(Vec_Ptr_t *) * p->nMemAlloc ); - p->pMemSatNums = ALLOC( int, p->nMemAlloc ); + p->pMemSatNums = ABC_ALLOC( int, p->nMemAlloc ); memset( p->pMemSatNums, 0, sizeof(int) * p->nMemAlloc ); // make sure the satisfying assignment is node assigned assert( pManFraig->pData == NULL ); @@ -242,7 +242,7 @@ void Fra_ManStop( Fra_Man_t * p ) if ( p->pManAig ) { if ( p->pManAig->pObjCopies ) - free( p->pManAig->pObjCopies ); + ABC_FREE( p->pManAig->pObjCopies ); p->pManAig->pObjCopies = p->pMemFraig; p->pMemFraig = NULL; } @@ -254,11 +254,11 @@ void Fra_ManStop( Fra_Man_t * p ) if ( p->pSml ) Fra_SmlStop( p->pSml ); if ( p->vCex ) Vec_IntFree( p->vCex ); if ( p->vOneHots ) Vec_IntFree( p->vOneHots ); - FREE( p->pMemFraig ); - FREE( p->pMemFanins ); - FREE( p->pMemSatNums ); - FREE( p->pPatWords ); - free( p ); + ABC_FREE( p->pMemFraig ); + ABC_FREE( p->pMemFanins ); + ABC_FREE( p->pMemSatNums ); + ABC_FREE( p->pPatWords ); + ABC_FREE( p ); } /**Function************************************************************* @@ -284,19 +284,19 @@ void Fra_ManPrint( Fra_Man_t * p ) p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/(p->nRegsBeg?p->nRegsBeg:1) ); if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat ); if ( p->pPars->fUse1Hot ) Fra_OneHotEstimateCoverage( p, p->vOneHots ); - PRT( "AIG simulation ", p->pSml->timeSim ); - PRT( "AIG traversal ", p->timeTrav ); + ABC_PRT( "AIG simulation ", p->pSml->timeSim ); + ABC_PRT( "AIG traversal ", p->timeTrav ); if ( p->timeRwr ) { - PRT( "AIG rewriting ", p->timeRwr ); + ABC_PRT( "AIG rewriting ", p->timeRwr ); } - PRT( "SAT solving ", p->timeSat ); - PRT( " Unsat ", p->timeSatUnsat ); - PRT( " Sat ", p->timeSatSat ); - PRT( " Fail ", p->timeSatFail ); - PRT( "Class refining ", p->timeRef ); - PRT( "TOTAL RUNTIME ", p->timeTotal ); - if ( p->time1 ) { PRT( "time1 ", p->time1 ); } + ABC_PRT( "SAT solving ", p->timeSat ); + ABC_PRT( " Unsat ", p->timeSatUnsat ); + ABC_PRT( " Sat ", p->timeSatSat ); + ABC_PRT( " Fail ", p->timeSatFail ); + ABC_PRT( "Class refining ", p->timeRef ); + ABC_PRT( "TOTAL RUNTIME ", p->timeTotal ); + if ( p->time1 ) { ABC_PRT( "time1 ", p->time1 ); } if ( p->nSpeculs ) printf( "Speculations = %d.\n", p->nSpeculs ); fflush( stdout ); diff --git a/src/aig/fra/fraPart.c b/src/aig/fra/fraPart.c index 1766b978..6dfbd2e9 100644 --- a/src/aig/fra/fraPart.c +++ b/src/aig/fra/fraPart.c @@ -59,7 +59,7 @@ void Fra_ManPartitionTest( Aig_Man_t * p, int nComLim ) // compute supports clk = clock(); vSupps = (Vec_Vec_t *)Aig_ManSupports( p ); -PRT( "Supports", clock() - clk ); +ABC_PRT( "Supports", clock() - clk ); // remove last entry Aig_ManForEachPo( p, pObj, i ) { @@ -76,9 +76,9 @@ clk = clock(); { vSup = Vec_VecEntry( vSupps, i ); Vec_IntForEachEntry( vSup, Entry, k ) - Vec_VecPush( vSuppsIn, Entry, (void *)(PORT_PTRUINT_T)i ); + Vec_VecPush( vSuppsIn, Entry, (void *)(ABC_PTRUINT_T)i ); } -PRT( "Inverse ", clock() - clk ); +ABC_PRT( "Inverse ", clock() - clk ); clk = clock(); // compute extended supports @@ -153,7 +153,7 @@ clk = clock(); */ } // Bar_ProgressStop( pProgress ); -PRT( "Scanning", clock() - clk ); +ABC_PRT( "Scanning", clock() - clk ); // print cumulative statistics printf( "PIs = %6d. POs = %6d. Lim = %3d. AveS = %3d. SN = %3d. R = %4.2f Max = %5d.\n", @@ -193,7 +193,7 @@ void Fra_ManPartitionTest2( Aig_Man_t * p ) // compute supports clk = clock(); vSupps = (Vec_Vec_t *)Aig_ManSupports( p ); -PRT( "Supports", clock() - clk ); +ABC_PRT( "Supports", clock() - clk ); // remove last entry Aig_ManForEachPo( p, pObj, i ) { @@ -212,13 +212,13 @@ clk = clock(); break; vSup = Vec_VecEntry( vSupps, i ); Vec_IntForEachEntry( vSup, Entry, k ) - Vec_VecPush( vSuppsIn, Entry, (void *)(PORT_PTRUINT_T)i ); + Vec_VecPush( vSuppsIn, Entry, (void *)(ABC_PTRUINT_T)i ); } -PRT( "Inverse ", clock() - clk ); +ABC_PRT( "Inverse ", clock() - clk ); // create affective supports clk = clock(); - pSupp = ALLOC( char, Aig_ManPiNum(p) ); + pSupp = ABC_ALLOC( char, Aig_ManPiNum(p) ); Aig_ManForEachPo( p, pObj, i ) { if ( i % 50 != 0 ) @@ -248,9 +248,9 @@ clk = clock(); printf( "%d(%d) ", Vec_IntSize(vSup), Counter ); } printf( "\n" ); -PRT( "Extension ", clock() - clk ); +ABC_PRT( "Extension ", clock() - clk ); - free( pSupp ); + ABC_FREE( pSupp ); Vec_VecFree( vSupps ); Vec_VecFree( vSuppsIn ); } diff --git a/src/aig/fra/fraSat.c b/src/aig/fra/fraSat.c index 8332fa77..c2eaf453 100644 --- a/src/aig/fra/fraSat.c +++ b/src/aig/fra/fraSat.c @@ -101,7 +101,7 @@ clk = clock(); pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase ); //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) @@ -145,7 +145,7 @@ clk = clock(); pLits[0] = toLitCond( Fra_ObjSatNum(pOld), 1 ); pLits[1] = toLitCond( Fra_ObjSatNum(pNew), pOld->fPhase ^ pNew->fPhase ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) @@ -177,12 +177,12 @@ p->timeSatFail += clock() - clk; // check BDD proof { int RetVal; - PRT( "Sat", clock() - clk2 ); + ABC_PRT( "Sat", clock() - clk2 ); clk2 = clock(); RetVal = Fra_NodesAreEquivBdd( pOld, pNew ); // printf( "%d ", RetVal ); assert( RetVal ); - PRT( "Bdd", clock() - clk2 ); + ABC_PRT( "Bdd", clock() - clk2 ); printf( "\n" ); } */ @@ -263,7 +263,7 @@ clk = clock(); pLits[1] = toLitCond( Fra_ObjSatNum(pNew), !fComplR ); //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) @@ -370,7 +370,7 @@ clk = clock(); pLits[1] = toLitCond( Fra_ObjSatNum(pNew), !fComplR ); //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) @@ -447,7 +447,7 @@ int Fra_NodeIsConst( Fra_Man_t * p, Aig_Obj_t * pNew ) clk = clock(); pLits[0] = toLitCond( Fra_ObjSatNum(pNew), pNew->fPhase ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 1, - (sint64)p->pPars->nBTLimitMiter, (sint64)0, + (ABC_INT64_T)p->pPars->nBTLimitMiter, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) diff --git a/src/aig/fra/fraSec.c b/src/aig/fra/fraSec.c index 7545059f..a97af278 100644 --- a/src/aig/fra/fraSec.c +++ b/src/aig/fra/fraSec.c @@ -121,7 +121,7 @@ clk = clock(); { printf( "Sequential cleanup: Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } RetValue = Fra_FraigMiterStatus( pNew ); if ( RetValue >= 0 ) @@ -140,7 +140,7 @@ clk = clock(); { printf( "Phase abstraction: Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } @@ -155,7 +155,7 @@ clk = clock(); { printf( "Forward retiming: Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } @@ -199,9 +199,9 @@ clk = clock(); printf( "The counter-example is invalid because of phase abstraction.\n" ); else { - FREE( p->pSeqModel ); + ABC_FREE( p->pSeqModel ); p->pSeqModel = Ssw_SmlDupCounterExample( pTemp->pSeqModel, Aig_ManRegNum(p) ); - FREE( pTemp->pSeqModel ); + ABC_FREE( pTemp->pSeqModel ); } } if ( pNew == NULL ) @@ -212,12 +212,12 @@ clk = clock(); if ( !pParSec->fSilent ) { printf( "Networks are NOT EQUIVALENT after simulation. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } if ( pParSec->fReportSolution && !pParSec->fRecursive ) { printf( "SOLUTION: FAIL " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } Aig_ManStop( pTemp ); return RetValue; @@ -233,7 +233,7 @@ PRT( "Time", clock() - clkTotal ); { printf( "Latch-corr (I=%3d): Latches = %5d. Nodes = %6d. ", nIter, Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } /* @@ -261,7 +261,7 @@ clk = clock(); { printf( "Fraiging: Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } @@ -302,7 +302,7 @@ clk = clock(); { printf( "Min-reg retiming: Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } @@ -370,7 +370,7 @@ clk = clock(); { printf( "K-step (K=%2d,I=%3d): Latches = %5d. Nodes = %6d. ", nFrames, pPars2->nIters, Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } if ( RetValue != -1 ) break; @@ -392,9 +392,9 @@ clk = clock(); { printf( "Min-reg retiming: Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); - } +ABC_PRT( "Time", clock() - clk ); } + } if ( pNew->nRegs ) pNew = Aig_ManConstReduce( pNew, 0 ); @@ -410,19 +410,19 @@ clk = clock(); { printf( "Rewriting: Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } // perform sequential simulation if ( pNew->nRegs ) { clk = clock(); - pSml = Fra_SmlSimulateSeq( pNew, 0, 128 * nFrames, 1 + 16/(1+Aig_ManNodeNum(pNew)/1000) ); + pSml = Fra_SmlSimulateSeq( pNew, 0, 128 * nFrames, 1 + 16/(1+Aig_ManNodeNum(pNew)/1000), 1 ); if ( pParSec->fVerbose ) { printf( "Seq simulation : Latches = %5d. Nodes = %6d. ", Aig_ManRegNum(pNew), Aig_ManNodeNum(pNew) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } if ( pSml->fNonConstOut ) { @@ -432,9 +432,9 @@ PRT( "Time", clock() - clk ); printf( "The counter-example is invalid because of phase abstraction.\n" ); else { - FREE( p->pSeqModel ); + ABC_FREE( p->pSeqModel ); p->pSeqModel = Ssw_SmlDupCounterExample( pNew->pSeqModel, Aig_ManRegNum(p) ); - FREE( pNew->pSeqModel ); + ABC_FREE( pNew->pSeqModel ); } Fra_SmlStop( pSml ); @@ -443,12 +443,12 @@ PRT( "Time", clock() - clk ); if ( !pParSec->fSilent ) { printf( "Networks are NOT EQUIVALENT after simulation. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } if ( pParSec->fReportSolution && !pParSec->fRecursive ) { printf( "SOLUTION: FAIL " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } return RetValue; } @@ -481,7 +481,7 @@ clk = clock(); if ( pNewOrpos->pSeqModel ) { Ssw_Cex_t * pCex; - FREE( pNew->pSeqModel ); + ABC_FREE( pNew->pSeqModel ); pCex = pNew->pSeqModel = pNewOrpos->pSeqModel; pNewOrpos->pSeqModel = NULL; pCex->iPo = Ssw_SmlFindOutputCounterExample( pNew, pNew->pSeqModel ); } @@ -498,7 +498,7 @@ clk = clock(); printf( "Property UNDECIDED after interpolation. " ); else assert( 0 ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } @@ -518,12 +518,12 @@ finish: if ( !pParSec->fSilent ) { printf( "Networks are equivalent. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } if ( pParSec->fReportSolution && !pParSec->fRecursive ) { printf( "SOLUTION: PASS " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } } else if ( RetValue == 0 ) @@ -531,12 +531,12 @@ PRT( "Time", clock() - clkTotal ); if ( !pParSec->fSilent ) { printf( "Networks are NOT EQUIVALENT. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } if ( pParSec->fReportSolution && !pParSec->fRecursive ) { printf( "SOLUTION: FAIL " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } } else @@ -544,12 +544,12 @@ PRT( "Time", clock() - clkTotal ); if ( !pParSec->fSilent ) { printf( "Networks are UNDECIDED. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } if ( pParSec->fReportSolution && !pParSec->fRecursive ) { printf( "SOLUTION: UNDECIDED " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } if ( !TimeOut && !pParSec->fSilent ) { @@ -566,9 +566,9 @@ PRT( "Time", clock() - clkTotal ); printf( "The counter-example is invalid because of phase abstraction.\n" ); else { - FREE( p->pSeqModel ); + ABC_FREE( p->pSeqModel ); p->pSeqModel = Ssw_SmlDupCounterExample( pNew->pSeqModel, Aig_ManRegNum(p) ); - FREE( pNew->pSeqModel ); + ABC_FREE( pNew->pSeqModel ); } } if ( ppResult != NULL ) diff --git a/src/aig/fra/fraSim.c b/src/aig/fra/fraSim.c index d1d73a03..aff21219 100644 --- a/src/aig/fra/fraSim.c +++ b/src/aig/fra/fraSim.c @@ -293,7 +293,7 @@ void Fra_SmlCheckOutputSavePattern( Fra_Man_t * p, Aig_Obj_t * pObjPo ) // determine the best pattern BestPat = i * 32 + k; // fill in the counter-example data - pModel = ALLOC( int, Aig_ManPiNum(p->pManFraig)+1 ); + pModel = ABC_ALLOC( int, Aig_ManPiNum(p->pManFraig)+1 ); Aig_ManForEachPi( p->pManAig, pObjPi, i ) { pModel[i] = Aig_InfoHasBit(Fra_ObjSim(p->pSml, pObjPi->Id), BestPat); @@ -804,7 +804,7 @@ printf( "Refined classes = %5d. Changes = %4d. Lits = %6d.\n", Vec_PtrSize( Fra_Sml_t * Fra_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFrame ) { Fra_Sml_t * p; - p = (Fra_Sml_t *)malloc( sizeof(Fra_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame ); + p = (Fra_Sml_t *)ABC_ALLOC( char, sizeof(Fra_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame ); memset( p, 0, sizeof(Fra_Sml_t) + sizeof(unsigned) * (nPref + nFrames) * nWordsFrame ); p->pAig = pAig; p->nPref = nPref; @@ -828,7 +828,7 @@ Fra_Sml_t * Fra_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFr ***********************************************************************/ void Fra_SmlStop( Fra_Sml_t * p ) { - free( p ); + ABC_FREE( p ); } @@ -863,12 +863,13 @@ Fra_Sml_t * Fra_SmlSimulateComb( Aig_Man_t * pAig, int nWords ) SeeAlso [] ***********************************************************************/ -Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords ) +Fra_Sml_t * Fra_SmlSimulateSeq( Aig_Man_t * pAig, int nPref, int nFrames, int nWords, int fCheckMiter ) { Fra_Sml_t * p; p = Fra_SmlStart( pAig, nPref, nFrames, nWords ); Fra_SmlInitialize( p, 1 ); Fra_SmlSimulateOne( p ); + if ( fCheckMiter ) p->fNonConstOut = Fra_SmlCheckNonConstOutputs( p ); return p; } @@ -888,7 +889,7 @@ Fra_Cex_t * Fra_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames ) { Fra_Cex_t * pCex; int nWords = Aig_BitWordNum( nRegs + nRealPis * nFrames ); - pCex = (Fra_Cex_t *)malloc( sizeof(Fra_Cex_t) + sizeof(unsigned) * nWords ); + 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->nRegs = nRegs; pCex->nPis = nRealPis; @@ -909,7 +910,7 @@ Fra_Cex_t * Fra_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames ) ***********************************************************************/ void Fra_SmlFreeCounterExample( Fra_Cex_t * pCex ) { - free( pCex ); + ABC_FREE( pCex ); } /**Function************************************************************* diff --git a/src/aig/fsim/fsim.h b/src/aig/fsim/fsim.h index c890ff29..4e1588a7 100644 --- a/src/aig/fsim/fsim.h +++ b/src/aig/fsim/fsim.h @@ -21,10 +21,6 @@ #ifndef __FSIM_H__ #define __FSIM_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/fsim/fsimFront.c b/src/aig/fsim/fsimFront.c index d40b1c6f..14906c0b 100644 --- a/src/aig/fsim/fsimFront.c +++ b/src/aig/fsim/fsimFront.c @@ -202,11 +202,11 @@ void Fsim_ManVerifyFront( Fsim_Man_t * p ) int * pFans0, * pFans1; // representation of fanins int * pFrontToId; // mapping of nodes into frontier variables int i, iVar0, iVar1; - pFans0 = ALLOC( int, p->nObjs ); - pFans1 = ALLOC( int, p->nObjs ); + pFans0 = ABC_ALLOC( int, p->nObjs ); + pFans1 = ABC_ALLOC( int, p->nObjs ); pFans0[0] = pFans1[0] = 0; pFans0[1] = pFans1[1] = 0; - pFrontToId = CALLOC( int, p->nFront ); + pFrontToId = ABC_CALLOC( int, p->nFront ); if ( Aig_ObjRefs(Aig_ManConst1(p->pAig)) ) pFrontToId[1] = 1; Fsim_ManForEachObj( p, pObj, i ) @@ -223,9 +223,9 @@ void Fsim_ManVerifyFront( Fsim_Man_t * p ) assert( pFans0[i] == p->pFans0[i] ); assert( pFans1[i] == p->pFans1[i] ); } - free( pFrontToId ); - free( pFans0 ); - free( pFans1 ); + ABC_FREE( pFrontToId ); + ABC_FREE( pFans0 ); + ABC_FREE( pFans1 ); } /**Function************************************************************* @@ -246,8 +246,8 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig ) int * pIdToFront; // mapping of nodes into frontier places int i, iVar0, iVar1, nCrossCut = 0, nCrossCutMax = 0; // start the frontier - pFront = CALLOC( char, p->nFront ); - pIdToFront = ALLOC( int, p->nObjs ); + pFront = ABC_CALLOC( char, p->nFront ); + pIdToFront = ABC_ALLOC( int, p->nObjs ); pIdToFront[0] = -1; pIdToFront[1] = -1; // add constant node @@ -261,13 +261,13 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig ) if ( fCompressAig ) { p->nDataAig = p->nObjs * 6; - p->pDataAig = ALLOC( unsigned char, p->nDataAig ); + p->pDataAig = ABC_ALLOC( unsigned char, p->nDataAig ); p->pDataCur = p->pDataAig; p->iNodePrev = 0; } else { - p->pDataAig2 = ALLOC( int, 3 * p->nObjs ); + p->pDataAig2 = ABC_ALLOC( int, 3 * p->nObjs ); p->pDataCur2 = p->pDataAig2 + 6; } // iterate through the objects @@ -349,12 +349,12 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig ) assert( nCrossCutMax == p->nCrossCutMax ); for ( i = 0; i < p->nFront; i++ ) assert( pFront[i] == 0 ); - free( pFront ); - free( pIdToFront ); + ABC_FREE( pFront ); + ABC_FREE( pIdToFront ); // Fsim_ManVerifyFront( p ); - FREE( p->pFans0 ); - FREE( p->pFans1 ); - FREE( p->pRefs ); + ABC_FREE( p->pFans0 ); + ABC_FREE( p->pFans1 ); + ABC_FREE( p->pRefs ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/fsim/fsimInt.h b/src/aig/fsim/fsimInt.h index 0944bf0c..f46a9024 100644 --- a/src/aig/fsim/fsimInt.h +++ b/src/aig/fsim/fsimInt.h @@ -21,10 +21,6 @@ #ifndef __FSIM_INT_H__ #define __FSIM_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -36,6 +32,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/fsim/fsimMan.c b/src/aig/fsim/fsimMan.c index f7a40f40..872e1604 100644 --- a/src/aig/fsim/fsimMan.c +++ b/src/aig/fsim/fsimMan.c @@ -102,7 +102,7 @@ Fsim_Man_t * Fsim_ManCreate( Aig_Man_t * pAig ) Aig_Obj_t * pObj; int i, nObjs; Aig_ManCleanData( pAig ); - p = (Fsim_Man_t *)ALLOC( Fsim_Man_t, 1 ); + p = (Fsim_Man_t *)ABC_ALLOC( Fsim_Man_t, 1 ); memset( p, 0, sizeof(Fsim_Man_t) ); p->pAig = pAig; p->nPis = Saig_ManPiNum(pAig); @@ -111,9 +111,9 @@ Fsim_Man_t * Fsim_ManCreate( Aig_Man_t * pAig ) p->nCos = Aig_ManPoNum(pAig); p->nNodes = Aig_ManNodeNum(pAig); nObjs = p->nCis + p->nCos + p->nNodes + 2; - p->pFans0 = ALLOC( int, nObjs ); - p->pFans1 = ALLOC( int, nObjs ); - p->pRefs = ALLOC( int, nObjs ); + p->pFans0 = ABC_ALLOC( int, nObjs ); + p->pFans1 = ABC_ALLOC( int, nObjs ); + p->pRefs = ABC_ALLOC( int, nObjs ); p->vCis2Ids = Vec_IntAlloc( Aig_ManPiNum(pAig) ); // add objects (0=unused; 1=const1) p->pFans0[0] = p->pFans1[0] = 0; @@ -168,17 +168,17 @@ void Fsim_ManDelete( Fsim_Man_t * p ) Vec_IntFree( p->vCis2Ids ); Vec_IntFree( p->vLos ); Vec_IntFree( p->vLis ); - FREE( p->pDataAig2 ); - FREE( p->pDataAig ); - FREE( p->pFans0 ); - FREE( p->pFans1 ); - FREE( p->pRefs ); - FREE( p->pDataSim ); - FREE( p->pDataSimCis ); - FREE( p->pDataSimCos ); - FREE( p->pData1 ); - FREE( p->pData2 ); - FREE( p ); + ABC_FREE( p->pDataAig2 ); + ABC_FREE( p->pDataAig ); + ABC_FREE( p->pFans0 ); + ABC_FREE( p->pFans1 ); + ABC_FREE( p->pRefs ); + ABC_FREE( p->pDataSim ); + ABC_FREE( p->pDataSimCis ); + ABC_FREE( p->pDataSimCos ); + ABC_FREE( p->pData1 ); + ABC_FREE( p->pData2 ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/fsim/fsimSim.c b/src/aig/fsim/fsimSim.c index 320c06a9..52dedc6d 100644 --- a/src/aig/fsim/fsimSim.c +++ b/src/aig/fsim/fsimSim.c @@ -385,7 +385,7 @@ void Fsim_ManSimulateRoundTest( Fsim_Man_t * p ) Fsim_ManForEachObj( p, pObj, i ) { } -// PRT( "Unpacking time", p->pPars->nIters * (clock() - clk) ); +// ABC_PRT( "Unpacking time", p->pPars->nIters * (clock() - clk) ); } /**Function************************************************************* @@ -437,7 +437,7 @@ Ssw_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int // fill in the binary data Aig_ManRandom( 1 ); Counter = p->nRegs; - pData = ALLOC( unsigned, nWords ); + pData = ABC_ALLOC( unsigned, nWords ); for ( f = 0; f <= iFrame; f++, Counter += p->nPis ) for ( i = 0; i < Aig_ManPiNum(pAig); i++ ) { @@ -449,7 +449,7 @@ Ssw_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int if ( Aig_InfoHasBit( pData, iPat ) ) Aig_InfoSetBit( p->pData, Counter + iPioId ); } - free( pData ); + ABC_FREE( pData ); return p; } @@ -470,16 +470,19 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars ) Sec_MtrStatus_t Status; int i, iOut, iPat, clk, clkTotal = clock(), clk2, clk2Total = 0; assert( Aig_ManRegNum(pAig) > 0 ); - Status = Sec_MiterStatus( pAig ); - if ( Status.nSat > 0 ) + if ( pPars->fCheckMiter ) { - printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut ); - return 1; - } - if ( Status.nUndec == 0 ) - { - printf( "Miter is trivially unsatisfiable.\n" ); - return 0; + Status = Sec_MiterStatus( pAig ); + if ( Status.nSat > 0 ) + { + printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut ); + return 1; + } + if ( Status.nUndec == 0 ) + { + printf( "Miter is trivially unsatisfiable.\n" ); + return 0; + } } // create manager clk = clock(); @@ -490,7 +493,7 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars ) printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ", p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront, 4.0*p->nWords*(p->nFront)/(1<<20) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // create simulation frontier clk = clock(); @@ -501,14 +504,14 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars ) p->iNumber, Aig_Base2Log(p->iNumber), 1.0*(p->pDataCur-p->pDataAig)/(1<<20), 1.0*(p->pDataCur-p->pDataAig)/p->nObjs ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // perform simulation Aig_ManRandom( 1 ); assert( p->pDataSim == NULL ); - p->pDataSim = ALLOC( unsigned, p->nWords * p->nFront * sizeof(unsigned) ); - p->pDataSimCis = ALLOC( unsigned, p->nWords * p->nCis * sizeof(unsigned) ); - p->pDataSimCos = ALLOC( unsigned, p->nWords * p->nCos * sizeof(unsigned) ); + p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->nFront ); + p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * p->nCis ); + p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * p->nCos ); Fsim_ManSimInfoInit( p ); for ( i = 0; i < pPars->nIters; i++ ) { @@ -542,9 +545,9 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars ) p->nCrossCutMax, p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20), 4.0*p->nWords*(p->nFront+p->nCis+p->nCos)/(1<<20) ); - PRT( "Sim time", clock() - clkTotal ); + ABC_PRT( "Sim time", clock() - clkTotal ); -// PRT( "Additional time", clk2Total ); +// ABC_PRT( "Additional time", clk2Total ); // Fsim_ManSimulateRoundTest( p ); // Fsim_ManSimulateRoundTest2( p ); } diff --git a/src/aig/fsim/fsimSwitch.c b/src/aig/fsim/fsimSwitch.c index 00046af6..97cb612f 100644 --- a/src/aig/fsim/fsimSwitch.c +++ b/src/aig/fsim/fsimSwitch.c @@ -28,559 +28,6 @@ /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoRandom( Fsim_Man_t * p, unsigned * pInfo, int nProbNum ) -{ - unsigned Mask; - int w, i; - if ( nProbNum ) - { - Mask = Aig_ManRandom( 0 ); - for ( i = 0; i < nProbNum; i++ ) - Mask &= Aig_ManRandom( 0 ); - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] ^= Mask; - } - else - { - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = Aig_ManRandom( 0 ); - } -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoRandomShift( Fsim_Man_t * p, unsigned * pInfo, int nProbNum ) -{ - unsigned Mask; - int w, i; - Mask = Aig_ManRandom( 0 ); - for ( i = 0; i < nProbNum; i++ ) - Mask &= Aig_ManRandom( 0 ); - if ( p->nWords == 1 ) - pInfo[0] = (pInfo[0] << 16) | ((pInfo[0] ^ Mask) & 0xffff); - else - { - assert( (p->nWords & 1) == 0 ); // should be even number - for ( w = p->nWords-1; w >= 0; w-- ) - if ( w >= p->nWords/2 ) - pInfo[w] = pInfo[w - p->nWords/2]; - else - pInfo[w] ^= Mask; - } -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoZero( Fsim_Man_t * p, unsigned * pInfo ) -{ - int w; - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = 0; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoOne( Fsim_Man_t * p, unsigned * pInfo ) -{ - int w; - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = ~0; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoCopy( Fsim_Man_t * p, unsigned * pInfo, unsigned * pInfo0 ) -{ - int w; - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = pInfo0[w]; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoCopyShift( Fsim_Man_t * p, unsigned * pInfo, unsigned * pInfo0 ) -{ - int w; - if ( p->nWords == 1 ) - pInfo[0] = (pInfo[0] << 16) | (pInfo0[0] & 0xffff); - else - { - assert( (p->nWords & 1) == 0 ); // should be even number - for ( w = p->nWords-1; w >= 0; w-- ) - { - if ( w >= p->nWords/2 ) - pInfo[w] = pInfo[w - p->nWords/2]; - else - pInfo[w] = pInfo0[w]; - } - } -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimulateCi( Fsim_Man_t * p, int iNode, int iCi ) -{ - unsigned * pInfo = Fsim_SimData( p, iNode % p->nFront ); - unsigned * pInfo0 = Fsim_SimDataCi( p, iCi ); - int w; - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = pInfo0[w]; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimulateCo( Fsim_Man_t * p, int iCo, int iFan0 ) -{ - unsigned * pInfo = Fsim_SimDataCo( p, iCo ); - unsigned * pInfo0 = Fsim_SimData( p, Fsim_Lit2Var(iFan0) % p->nFront ); - int w; - if ( Fsim_LitIsCompl(iFan0) ) - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = ~pInfo0[w]; - else //if ( !Fsim_LitIsCompl(iFan0) ) - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = pInfo0[w]; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimulateNode( Fsim_Man_t * p, int iNode, int iFan0, int iFan1 ) -{ - unsigned * pInfo = Fsim_SimData( p, iNode % p->nFront ); - unsigned * pInfo0 = Fsim_SimData( p, Fsim_Lit2Var(iFan0) % p->nFront ); - unsigned * pInfo1 = Fsim_SimData( p, Fsim_Lit2Var(iFan1) % p->nFront ); - int w; - if ( Fsim_LitIsCompl(iFan0) && Fsim_LitIsCompl(iFan1) ) - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = ~(pInfo0[w] | pInfo1[w]); - else if ( Fsim_LitIsCompl(iFan0) && !Fsim_LitIsCompl(iFan1) ) - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = ~pInfo0[w] & pInfo1[w]; - else if ( !Fsim_LitIsCompl(iFan0) && Fsim_LitIsCompl(iFan1) ) - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = pInfo0[w] & ~pInfo1[w]; - else //if ( !Fsim_LitIsCompl(iFan0) && !Fsim_LitIsCompl(iFan1) ) - for ( w = p->nWords-1; w >= 0; w-- ) - pInfo[w] = pInfo0[w] & pInfo1[w]; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoInit( Fsim_Man_t * p ) -{ - int iPioNum, i; - Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i ) - { - if ( iPioNum < p->nPis ) - Fsim_ManSwitchSimInfoRandom( p, Fsim_SimDataCi(p, i), 0 ); - else - Fsim_ManSwitchSimInfoZero( p, Fsim_SimDataCi(p, i) ); - } -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoTransfer( Fsim_Man_t * p, int nProbNum ) -{ - int iPioNum, i; - Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i ) - { - if ( iPioNum < p->nPis ) - Fsim_ManSwitchSimInfoRandom( p, Fsim_SimDataCi(p, i), nProbNum ); - else - Fsim_ManSwitchSimInfoCopy( p, Fsim_SimDataCi(p, i), Fsim_SimDataCo(p, p->nPos+iPioNum-p->nPis) ); - } -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimInfoTransferShift( Fsim_Man_t * p, int nProbNum ) -{ - int iPioNum, i; - Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i ) - { - if ( iPioNum < p->nPis ) - Fsim_ManSwitchSimInfoRandomShift( p, Fsim_SimDataCi(p, i), nProbNum ); - else - Fsim_ManSwitchSimInfoCopyShift( p, Fsim_SimDataCi(p, i), Fsim_SimDataCo(p, p->nPos+iPioNum-p->nPis) ); - } -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline int Fsim_ManSwitchSimInfoCountOnes( Fsim_Man_t * p, int iNode ) -{ - unsigned * pInfo; - int w, Counter = 0; - pInfo = Fsim_SimData( p, iNode % p->nFront ); - for ( w = p->nWords-1; w >= 0; w-- ) - Counter += Aig_WordCountOnes( pInfo[w] ); - return Counter; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline int Fsim_ManSwitchSimInfoCountTrans( Fsim_Man_t * p, int iNode ) -{ - unsigned * pInfo; - int w, Counter = 0; - assert( iNode % p->nFront ); - pInfo = Fsim_SimData( p, iNode % p->nFront ); - if ( p->nWords == 1 ) - return Aig_WordCountOnes( (pInfo[0] ^ (pInfo[0] >> 16)) & 0xffff ); - for ( w = p->nWords/2-1; w >= 0; w-- ) - Counter += Aig_WordCountOnes( pInfo[w] ^ pInfo[w + p->nWords/2] ); - return Counter; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -static inline void Fsim_ManSwitchSimulateRound( Fsim_Man_t * p, int fCount ) -{ - int * pCur, * pEnd; - int i, iCis = 0, iCos = 0; - if ( Aig_ObjRefs(Aig_ManConst1(p->pAig)) ) - Fsim_ManSwitchSimInfoOne( p, Fsim_SimData(p, 1) ); - pCur = p->pDataAig2 + 6; - pEnd = p->pDataAig2 + 3 * p->nObjs; - for ( i = 2; pCur < pEnd; i++ ) - { - if ( pCur[1] == 0 ) - Fsim_ManSwitchSimulateCi( p, pCur[0], iCis++ ); - else if ( pCur[2] == 0 ) - Fsim_ManSwitchSimulateCo( p, iCos++, pCur[1] ); - else - Fsim_ManSwitchSimulateNode( p, pCur[0], pCur[1], pCur[2] ); - if ( fCount && pCur[0] ) - { - if ( p->pData1 ) - p->pData1[i] += Fsim_ManSwitchSimInfoCountOnes( p, pCur[0] ); - if ( p->pData2 ) - p->pData2[i] += Fsim_ManSwitchSimInfoCountTrans( p, pCur[0] ); - } - pCur += 3; - } - assert( iCis == p->nCis ); - assert( iCos == p->nCos ); -} - -/**Function************************************************************* - - Synopsis [Computes switching activity of one node.] - - Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -float Fsim_ManSwitchComputeSwitching( int nOnes, int nSimWords ) -{ - int nTotal = 32 * nSimWords; - return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal; -} - -/**Function************************************************************* - - Synopsis [Computes switching activity of one node.] - - Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -float Fsim_ManSwitchComputeProbOne( int nOnes, int nSimWords ) -{ - int nTotal = 32 * nSimWords; - return (float)nOnes / nTotal; -} - -/**Function************************************************************* - - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Vec_Int_t * Fsim_ManSwitchSimulate( Aig_Man_t * pAig, Fsim_ParSwitch_t * pPars ) -{ - Vec_Int_t * vSwitching; - float * pSwitching; - Aig_Obj_t * pObj; - Fsim_Man_t * p; - int i, clk, clkTotal = clock(); - // create manager - clk = clock(); - p = Fsim_ManCreate( pAig ); - p->nWords = pPars->nWords; - // if the number of words is larger then 1, it should be even - if ( p->nWords > 1 && (p->nWords & 1) ) - p->nWords++; - // print stats - if ( pPars->fVerbose ) - { - printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ", - p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront, - 4.0*pPars->nWords*(p->nFront)/(1<<20) ); - PRT( "Time", clock() - clk ); - } - // create simulation frontier - clk = clock(); - Fsim_ManFront( p, 0 ); - if ( pPars->fVerbose ) - { - printf( "Max ID = %8d. Log max ID = %2d. AigMem = %7.2f Mb (%5.2f byte/obj). ", - p->iNumber, Aig_Base2Log(p->iNumber), - 1.0*(p->pDataCur-p->pDataAig)/(1<<20), - 1.0*(p->pDataCur-p->pDataAig)/p->nObjs ); - PRT( "Time", clock() - clk ); - } - // perform simulation - Aig_ManRandom( 1 ); - assert( p->pDataSim == NULL ); - p->pDataSim = ALLOC( unsigned, pPars->nWords * p->nFront * sizeof(unsigned) ); - p->pDataSimCis = ALLOC( unsigned, pPars->nWords * p->nCis * sizeof(unsigned) ); - p->pDataSimCos = ALLOC( unsigned, pPars->nWords * p->nCos * sizeof(unsigned) ); - if ( pPars->fProbOne ) - p->pData1 = CALLOC( int, p->nObjs * sizeof(int) ); - if ( pPars->fProbTrans ) - p->pData2 = CALLOC( int, p->nObjs * sizeof(int) ); - Fsim_ManSwitchSimInfoInit( p ); - for ( i = 0; i < pPars->nIters; i++ ) - { - Fsim_ManSwitchSimulateRound( p, i >= pPars->nPref ); - if ( i < pPars->nIters - 1 ) - { -// if ( pPars->fProbTrans ) - Fsim_ManSwitchSimInfoTransferShift( p, pPars->nRandPiNum ); -// else -// Fsim_ManSwitchSimInfoTransfer( p, pPars->nRandPiNum ); - } - } - if ( pPars->fVerbose ) - { - printf( "Maxcut = %8d. AigMem = %7.2f Mb. SimMem = %7.2f Mb. ", - p->nCrossCutMax, - p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20), - 4.0*pPars->nWords*(p->nFront+p->nCis+p->nCos)/(1<<20) ); - PRT( "Sim time", clock() - clkTotal ); - } - // derive the result - vSwitching = Vec_IntStart( Aig_ManObjNumMax(pAig) ); - pSwitching = (float *)vSwitching->pArray; -/* - if ( pPars->fProbOne && pPars->fProbTrans ) - { - Aig_ManForEachObj( pAig, pObj, i ) -// pSwitching[pObj->Id] = Fsim_ManSwitchComputeSwitching( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) ); - pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 ); - } - else if ( !pPars->fProbOne && pPars->fProbTrans ) - { - Aig_ManForEachObj( pAig, pObj, i ) - pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 ); - } - else if ( pPars->fProbOne && !pPars->fProbTrans ) - { - Aig_ManForEachObj( pAig, pObj, i ) - pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) ); - } - else - assert( 0 ); -*/ - if ( pPars->fProbOne && !pPars->fProbTrans ) - { - Aig_ManForEachObj( pAig, pObj, i ) - pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) ); - } - else if ( !pPars->fProbOne && pPars->fProbTrans ) - { - Aig_ManForEachObj( pAig, pObj, i ) - pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 ); - } - else - assert( 0 ); - Fsim_ManDelete( p ); - return vSwitching; - -} - -/**Function************************************************************* - - Synopsis [Computes probability of switching (or of being 1).] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Vec_Int_t * Saig_ManComputeSwitchProbs4( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ) -{ - Fsim_ParSwitch_t Pars, * pPars = &Pars; - Fsim_ManSetDefaultParamsSwitch( pPars ); - pPars->nWords = 1; - pPars->nIters = nFrames; - pPars->nPref = nPref; - if ( fProbOne ) - { - pPars->fProbOne = 1; - pPars->fProbTrans = 0; - } - else - { - pPars->fProbOne = 0; - pPars->fProbTrans = 1; - } - pPars->fVerbose = 0; - return Fsim_ManSwitchSimulate( p, pPars ); -} - //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/fsim/fsimTsim.c b/src/aig/fsim/fsimTsim.c index 963d7581..0de283e4 100644 --- a/src/aig/fsim/fsimTsim.c +++ b/src/aig/fsim/fsimTsim.c @@ -36,7 +36,7 @@ static inline int Aig_XsimNotCond( int Value, int fCompl ) return FSIM_ZER; return FSIM_ONE; } -static inline int Aig_XsimAndCond( int Value0, int Value1, int fCompl0, int fCompl1 ) +static inline int Aig_XsimAndCond( int Value0, int fCompl0, int Value1, int fCompl1 ) { if ( Value0 == FSIM_UND || Value1 == FSIM_UND ) return FSIM_UND; @@ -111,7 +111,7 @@ static inline void Fsim_ManTerSimulateNode( Fsim_Man_t * p, int iNode, int iFan0 { int Value0 = Fsim_ManTerSimInfoGet( p->pDataSim, Fsim_Lit2Var(iFan0) ); int Value1 = Fsim_ManTerSimInfoGet( p->pDataSim, Fsim_Lit2Var(iFan1) ); - Fsim_ManTerSimInfoSet( p->pDataSim, iNode, Aig_XsimAndCond( Value0, Value1, Fsim_LitIsCompl(iFan0), Fsim_LitIsCompl(iFan1) ) ); + Fsim_ManTerSimInfoSet( p->pDataSim, iNode, Aig_XsimAndCond( Value0, Fsim_LitIsCompl(iFan0), Value1, Fsim_LitIsCompl(iFan1) ) ); } /**Function************************************************************* @@ -253,7 +253,7 @@ unsigned * Fsim_ManTerStateCreate( unsigned * pInfo, int nPis, int nCis, int nWo { unsigned * pRes; int i; - pRes = (unsigned *)CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) ); + pRes = (unsigned *)ABC_CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) ); for ( i = nPis; i < nCis; i++ ) Fsim_ManTerSimInfoSet( pRes, i-nPis, Fsim_ManTerSimInfoGet(pInfo, i) ); return pRes; @@ -348,7 +348,7 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose ) printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ", p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront, 4.0*Aig_BitWordNum(2 * p->nFront)/(1<<20) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // create simulation frontier clk = clock(); @@ -359,19 +359,19 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose ) p->iNumber, Aig_Base2Log(p->iNumber), 1.0*(p->pDataCur-p->pDataAig)/(1<<20), 1.0*(p->pDataCur-p->pDataAig)/p->nObjs ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // allocate storage for terminary states nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) ); vStates = Vec_PtrAlloc( 1000 ); nBins = Aig_PrimeCudd( 500 ); - pBins = ALLOC( unsigned *, nBins ); + pBins = ABC_ALLOC( unsigned *, nBins ); memset( pBins, 0, sizeof(unsigned *) * nBins ); // perform simulation assert( p->pDataSim == NULL ); - p->pDataSim = ALLOC( unsigned, Aig_BitWordNum(2 * p->nFront) * sizeof(unsigned) ); - p->pDataSimCis = ALLOC( unsigned, Aig_BitWordNum(2 * p->nCis) * sizeof(unsigned) ); - p->pDataSimCos = ALLOC( unsigned, Aig_BitWordNum(2 * p->nCos) * sizeof(unsigned) ); + p->pDataSim = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nFront) * sizeof(unsigned) ); + p->pDataSimCis = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nCis) * sizeof(unsigned) ); + p->pDataSimCos = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nCos) * sizeof(unsigned) ); Fsim_ManTerSimInfoInit( p ); // hash the first state pState = Fsim_ManTerStateCreate( p->pDataSimCis, p->nPis, p->nCis, nWords ); @@ -395,9 +395,9 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose ) p->nCrossCutMax, p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20), 4.0*(Aig_BitWordNum(2 * p->nFront)+Aig_BitWordNum(2 * p->nCis)+Aig_BitWordNum(2 * p->nCos))/(1<<20) ); - PRT( "Sim time", clock() - clkTotal ); + ABC_PRT( "Sim time", clock() - clkTotal ); } - free( pBins ); + ABC_FREE( pBins ); Fsim_ManDelete( p ); return vStates; diff --git a/src/aig/gia/gia.c b/src/aig/gia/gia.c new file mode 100644 index 00000000..4cbb1731 --- /dev/null +++ b/src/aig/gia/gia.c @@ -0,0 +1,47 @@ +/**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" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h new file mode 100644 index 00000000..721056de --- /dev/null +++ b/src/aig/gia/gia.h @@ -0,0 +1,423 @@ +/**CFile**************************************************************** + + FileName [gia.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: gia.h,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#ifndef __GIA_H__ +#define __GIA_H__ + +//////////////////////////////////////////////////////////////////////// +/// INCLUDES /// +//////////////////////////////////////////////////////////////////////// + +#include "aig.h" + +//////////////////////////////////////////////////////////////////////// +/// PARAMETERS /// +//////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +#define GIA_NONE 0x1FFFFFFF + +//////////////////////////////////////////////////////////////////////// +/// BASIC TYPES /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Gia_Obj_t_ Gia_Obj_t; +struct Gia_Obj_t_ +{ + unsigned iDiff0 : 29; // the diff of the first fanin + unsigned fCompl0: 1; // the complemented attribute + unsigned fMark0 : 1; // first user-controlled mark + unsigned fTerm : 1; // terminal node (CI/CO) + + unsigned iDiff1 : 29; // the diff of the second fanin + unsigned fCompl1: 1; // the complemented attribute + unsigned fMark1 : 1; // second user-controlled mark + unsigned fPhase : 1; // value under 000 pattern + + unsigned Value; // application-specific value +}; + +typedef struct Gia_Man_t_ Gia_Man_t; +struct Gia_Man_t_ +{ + char * pName; // name of the AIG + int nRegs; // number of registers + int nRegsAlloc; // number of allocated registers + int nObjs; // number of objects + int nObjsAlloc; // number of allocated objects + Gia_Obj_t * pObjs; // the array of objects + Vec_Int_t * vCis; // the vector of CIs (PIs + LOs) + Vec_Int_t * vCos; // the vector of COs (POs + LIs) + int * pHTable; // hash table + int nHTable; // hash table size + int fAddStrash; // performs additional structural hashing + int * pRefs; // the reference count + int * pLevels; // levels of the nodes + int nLevels; // the mamixum level + int nTravIds; // the current traversal ID + int nFront; // frontier size + int * pReprs; // representatives (for CIs and ANDs) + int nTerLoop; // the state where loop begins + int nTerStates; // the total number of ternary states + int * pFanData; // the database to store fanout information + int nFansAlloc; // the size of fanout representation +}; + + + + +// frames parameters +typedef struct Gia_ParFra_t_ Gia_ParFra_t; +struct Gia_ParFra_t_ +{ + int nFrames; // the number of frames to unroll + int fInit; // initialize the timeframes + int fVerbose; // enables verbose output +}; + + + +// simulation parameters +typedef struct Gia_ParSim_t_ Gia_ParSim_t; +struct Gia_ParSim_t_ +{ + // user-controlled parameters + int nWords; // the number of machine words + int nIters; // the number of timeframes + int TimeLimit; // time limit in seconds + int fCheckMiter; // check if miter outputs are non-zero + int fVerbose; // enables verbose 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_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; } +static inline int Gia_Lit2Var( int Lit ) { return Lit >> 1; } +static inline int Gia_LitIsCompl( int Lit ) { return Lit & 1; } +static inline int Gia_LitNot( int Lit ) { return Lit ^ 1; } +static inline int Gia_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); } +static inline int Gia_LitRegular( int Lit ) { return Lit & ~01; } + +static inline Gia_Obj_t * Gia_Regular( Gia_Obj_t * p ) { return (Gia_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); } +static inline Gia_Obj_t * Gia_Not( Gia_Obj_t * p ) { return (Gia_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); } +static inline Gia_Obj_t * Gia_NotCond( Gia_Obj_t * p, int c ) { return (Gia_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); } +static inline int Gia_IsComplement( Gia_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); } + +static inline int Gia_ManCiNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCis); } +static inline int Gia_ManCoNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCos); } +static inline int Gia_ManPiNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCis) - p->nRegs; } +static inline int Gia_ManPoNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCos) - p->nRegs; } +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 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)); } +static inline Gia_Obj_t * Gia_ManObj( Gia_Man_t * p, int v ) { assert( v < p->nObjs ); return p->pObjs + v; } +static inline Gia_Obj_t * Gia_ManCi( Gia_Man_t * p, int v ) { return Gia_ManObj( p, Vec_IntEntry(p->vCis,v) ); } +static inline Gia_Obj_t * Gia_ManCo( Gia_Man_t * p, int v ) { return Gia_ManObj( p, Vec_IntEntry(p->vCos,v) ); } +static inline Gia_Obj_t * Gia_ManPi( Gia_Man_t * p, int v ) { assert( v < Gia_ManPiNum(p) ); return Gia_ManCi( p, v ); } +static inline Gia_Obj_t * Gia_ManPo( Gia_Man_t * p, int v ) { assert( v < Gia_ManPoNum(p) ); return Gia_ManCo( p, v ); } +static inline Gia_Obj_t * Gia_ManRo( Gia_Man_t * p, int v ) { assert( v < Gia_ManRegNum(p) ); return Gia_ManCi( p, Gia_ManRegNum(p)+v ); } +static inline Gia_Obj_t * Gia_ManRi( Gia_Man_t * p, int v ) { assert( v < Gia_ManRegNum(p) ); return Gia_ManCo( p, Gia_ManRegNum(p)+v ); } + +static inline int Gia_ObjIsTerm( Gia_Obj_t * pObj ) { return pObj->fTerm; } +static inline int Gia_ObjIsAndOrConst0( Gia_Obj_t * pObj ) { return!pObj->fTerm; } +static inline int Gia_ObjIsCi( Gia_Obj_t * pObj ) { return pObj->fTerm && pObj->iDiff0 == GIA_NONE; } +static inline int Gia_ObjIsCo( Gia_Obj_t * pObj ) { return pObj->fTerm && pObj->iDiff0 != GIA_NONE; } +static inline int Gia_ObjIsAnd( Gia_Obj_t * pObj ) { return!pObj->fTerm && pObj->iDiff0 != GIA_NONE; } +static inline int Gia_ObjIsConst0( Gia_Obj_t * pObj ) { return pObj->iDiff0 == GIA_NONE && pObj->iDiff1 == GIA_NONE; } +static inline int Gia_ManObjIsConst0( Gia_Man_t * p, Gia_Obj_t * pObj){ return pObj == p->pObjs; } + +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_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); } + +static inline int Gia_ObjIsPi( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCi(pObj) && Gia_ObjCioId(pObj) < Gia_ManPiNum(p); } +static inline int Gia_ObjIsPo( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCo(pObj) && Gia_ObjCioId(pObj) < Gia_ManPoNum(p); } +static inline int Gia_ObjIsRo( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCi(pObj) && Gia_ObjCioId(pObj) >= Gia_ManPiNum(p); } +static inline int Gia_ObjIsRi( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjIsCo(pObj) && Gia_ObjCioId(pObj) >= Gia_ManPoNum(p); } + +static inline Gia_Obj_t * Gia_ObjRoToRi( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsRo(p, pObj) ); return Gia_ManCo(p, Gia_ManCoNum(p) - Gia_ManCiNum(p) + Gia_ObjCioId(pObj)); } +static inline Gia_Obj_t * Gia_ObjRiToRo( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsRi(p, pObj) ); return Gia_ManCi(p, Gia_ManCiNum(p) - Gia_ManCoNum(p) + Gia_ObjCioId(pObj)); } + +static inline int Gia_ObjDiff0( Gia_Obj_t * pObj ) { return pObj->iDiff0; } +static inline int Gia_ObjDiff1( Gia_Obj_t * pObj ) { return pObj->iDiff1; } +static inline int Gia_ObjFaninC0( Gia_Obj_t * pObj ) { return pObj->fCompl0; } +static inline int Gia_ObjFaninC1( Gia_Obj_t * pObj ) { return pObj->fCompl1; } +static inline Gia_Obj_t * Gia_ObjFanin0( Gia_Obj_t * pObj ) { return pObj - pObj->iDiff0; } +static inline Gia_Obj_t * Gia_ObjFanin1( Gia_Obj_t * pObj ) { return pObj - pObj->iDiff1; } +static inline Gia_Obj_t * Gia_ObjChild0( Gia_Obj_t * pObj ) { return Gia_NotCond( Gia_ObjFanin0(pObj), Gia_ObjFaninC0(pObj) ); } +static inline Gia_Obj_t * Gia_ObjChild1( Gia_Obj_t * pObj ) { return Gia_NotCond( Gia_ObjFanin1(pObj), Gia_ObjFaninC1(pObj) ); } +static inline int Gia_ObjFaninId0( Gia_Obj_t * pObj, int ObjId ) { return ObjId - pObj->iDiff0; } +static inline int Gia_ObjFaninId1( Gia_Obj_t * pObj, int ObjId ) { return ObjId - pObj->iDiff1; } +static inline int Gia_ObjFaninId0p( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjFaninId0( pObj, Gia_ObjId(p, pObj) ); } +static inline int Gia_ObjFaninId1p( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjFaninId1( pObj, Gia_ObjId(p, pObj) ); } +static inline int Gia_ObjFaninLit0( Gia_Obj_t * pObj, int ObjId ) { return Gia_Var2Lit( Gia_ObjFaninId0(pObj, ObjId), Gia_ObjFaninC0(pObj) ); } +static inline int Gia_ObjFaninLit1( Gia_Obj_t * pObj, int ObjId ) { return Gia_Var2Lit( Gia_ObjFaninId1(pObj, ObjId), Gia_ObjFaninC1(pObj) ); } +static inline int Gia_ObjFaninLit0p( Gia_Man_t * p, Gia_Obj_t * pObj) { return Gia_Var2Lit( Gia_ObjFaninId0p(p, pObj), Gia_ObjFaninC0(pObj) ); } +static inline int Gia_ObjFaninLit1p( Gia_Man_t * p, Gia_Obj_t * pObj) { return Gia_Var2Lit( Gia_ObjFaninId1p(p, pObj), Gia_ObjFaninC1(pObj) ); } +static inline void Gia_ObjFlipFaninC0( Gia_Obj_t * pObj ) { assert( Gia_ObjIsCo(pObj) ); pObj->fCompl0 ^= 1; } +static inline int Gia_ObjWhatFanin( Gia_Obj_t * pObj, Gia_Obj_t * pFanin ) { return Gia_ObjFanin0(pObj) == pFanin ? 0 : (Gia_ObjFanin1(pObj) == pFanin ? 1 : -1); } + +static inline int Gia_ObjFanin0Copy( Gia_Obj_t * pObj ) { return Gia_LitNotCond( Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj) ); } +static inline int Gia_ObjFanin1Copy( Gia_Obj_t * pObj ) { return Gia_LitNotCond( Gia_ObjFanin1(pObj)->Value, Gia_ObjFaninC1(pObj) ); } + +static inline Gia_Obj_t * Gia_ObjFromLit( Gia_Man_t * p, int iLit ) { return Gia_NotCond( Gia_ManObj(p, Gia_Lit2Var(iLit)), Gia_LitIsCompl(iLit) ); } +static inline int Gia_ObjToLit( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_LitNotCond( Gia_ObjId(p, 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_ObjRefs( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); return p->pRefs[Gia_ObjId(p, pObj)]; } +static inline void Gia_ObjRefInc( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); p->pRefs[Gia_ObjId(p, pObj)]++; } +static inline void Gia_ObjRefDec( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( p->pRefs); 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)); } +static inline void Gia_ObjRefFanin1Inc(Gia_Man_t * p, Gia_Obj_t * pObj){ assert( p->pRefs); Gia_ObjRefInc(p, Gia_ObjFanin1(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); } + +// AIG construction +extern void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout ); +static inline Gia_Obj_t * Gia_ManAppendObj( Gia_Man_t * p ) +{ + if ( p->nObjs == p->nObjsAlloc ) + { +// printf("Reallocing %d.\n", 2 * p->nObjsAlloc ); + assert( p->nObjsAlloc > 0 ); + p->pObjs = ABC_REALLOC( Gia_Obj_t, p->pObjs, 2 * p->nObjsAlloc ); + memset( p->pObjs + p->nObjsAlloc, 0, sizeof(Gia_Obj_t) * p->nObjsAlloc ); + p->nObjsAlloc *= 2; + } + return Gia_ManObj( p, p->nObjs++ ); +} +static inline int Gia_ManAppendCi( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj = Gia_ManAppendObj( p ); + pObj->fTerm = 1; + pObj->iDiff0 = GIA_NONE; + pObj->iDiff1 = Vec_IntSize( p->vCis ); + Vec_IntPush( p->vCis, Gia_ObjId(p, pObj) ); + return Gia_ObjId( p, pObj ) << 1; +} +static inline int Gia_ManAppendAnd( Gia_Man_t * p, int iLit0, int iLit1 ) +{ + Gia_Obj_t * pObj = Gia_ManAppendObj( p ); + assert( iLit0 != iLit1 ); + if ( iLit0 < iLit1 ) + { + pObj->iDiff0 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit0); + pObj->fCompl0 = Gia_LitIsCompl(iLit0); + pObj->iDiff1 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit1); + pObj->fCompl1 = Gia_LitIsCompl(iLit1); + } + else + { + pObj->iDiff1 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit0); + pObj->fCompl1 = Gia_LitIsCompl(iLit0); + pObj->iDiff0 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit1); + pObj->fCompl0 = Gia_LitIsCompl(iLit1); + } + if ( p->pFanData ) + { + Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj ); + Gia_ObjAddFanout( p, Gia_ObjFanin1(pObj), pObj ); + } + return Gia_ObjId( p, pObj ) << 1; +} +static inline int Gia_ManAppendCo( Gia_Man_t * p, int iLit0 ) +{ + Gia_Obj_t * pObj = Gia_ManAppendObj( p ); + pObj->fTerm = 1; + pObj->iDiff0 = Gia_ObjId(p, pObj) - Gia_Lit2Var(iLit0); + pObj->fCompl0 = Gia_LitIsCompl(iLit0); + pObj->iDiff1 = Vec_IntSize( p->vCos ); + Vec_IntPush( p->vCos, Gia_ObjId(p, pObj) ); + if ( p->pFanData ) + Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj ); + return Gia_ObjId( p, pObj ) << 1; +} + +#define GIA_ZER 1 +#define GIA_ONE 2 +#define GIA_UND 3 + +static inline int Gia_XsimNotCond( int Value, int fCompl ) +{ + if ( Value == GIA_UND ) + return GIA_UND; + if ( Value == GIA_ZER + fCompl ) + return GIA_ZER; + return GIA_ONE; +} +static inline int Gia_XsimAndCond( int Value0, int fCompl0, int Value1, int fCompl1 ) +{ + if ( Value0 == GIA_ZER + fCompl0 || Value1 == GIA_ZER + fCompl1 ) + return GIA_ZER; + if ( Value0 == GIA_UND || Value1 == GIA_UND ) + return GIA_UND; + return GIA_ONE; +} + +//////////////////////////////////////////////////////////////////////// +/// MACRO DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +#define Gia_ManForEachObj( p, pObj, i ) \ + for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) +#define Gia_ManForEachObj1( p, pObj, i ) \ + for ( i = 1; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) +#define Gia_ManForEachObjVec( vVec, p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ ) +#define Gia_ManForEachAnd( p, pObj, i ) \ + for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) if ( !Gia_ObjIsAnd(pObj) ) {} else +#define Gia_ManForEachCi( p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(p->vCis)) && ((pObj) = Gia_ManCi(p, i)); i++ ) +#define Gia_ManForEachCo( p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(p->vCos)) && ((pObj) = Gia_ManCo(p, i)); i++ ) +#define Gia_ManForEachCoDriver( p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(p->vCos)) && ((pObj) = Gia_ObjFanin0(Gia_ManCo(p, i))); i++ ) +#define Gia_ManForEachPi( p, pObj, i ) \ + for ( i = 0; (i < Gia_ManPiNum(p)) && ((pObj) = Gia_ManCi(p, i)); i++ ) +#define Gia_ManForEachPo( p, pObj, i ) \ + for ( i = 0; (i < Gia_ManPoNum(p)) && ((pObj) = Gia_ManCo(p, i)); i++ ) +#define Gia_ManForEachRo( p, pObj, i ) \ + for ( i = 0; (i < Gia_ManRegNum(p)) && ((pObj) = Gia_ManCi(p, Gia_ManPiNum(p)+i)); i++ ) +#define Gia_ManForEachRi( p, pObj, i ) \ + for ( i = 0; (i < Gia_ManRegNum(p)) && ((pObj) = Gia_ManCo(p, Gia_ManPoNum(p)+i)); i++ ) +#define Gia_ManForEachRiRo( p, pObjRi, pObjRo, i ) \ + for ( i = 0; (i < Gia_ManRegNum(p)) && ((pObjRi) = Gia_ManCo(p, Gia_ManPoNum(p)+i)) && ((pObjRo) = Gia_ManCi(p, Gia_ManPiNum(p)+i)); i++ ) + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +/*=== giaAig.c ============================================================*/ +extern Gia_Man_t * Gia_ManFromAig( Aig_Man_t * p ); +extern Gia_Man_t * Gia_ManFromAigSwitch( Aig_Man_t * p ); +extern Aig_Man_t * Gia_ManToAig( Gia_Man_t * p ); +/*=== giaAiger.c ==========================================================*/ +extern Gia_Man_t * Gia_ReadAiger( char * pFileName, int fCheck ); +extern void Gia_WriteAiger( Gia_Man_t * p, char * pFileName, int fWriteSymbols, int fCompact ); +/*=== giaCof.c ============================================================*/ +extern void Gia_ManPrintFanio( Gia_Man_t * pGia, int nNodes ); +/*=== 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 int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNodes ); +extern int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes ); +/*=== giaDup.c ============================================================*/ +extern Gia_Man_t * Gia_ManDup( Gia_Man_t * p ); +extern Gia_Man_t * Gia_ManDupMarked( Gia_Man_t * p ); +extern Gia_Man_t * Gia_ManDupTimes( Gia_Man_t * p, int nTimes ); +extern Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p ); +extern Gia_Man_t * Gia_ManDupDfsSkip( Gia_Man_t * p ); +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 ); +extern Gia_Man_t * Gia_ManDupCofactored( Gia_Man_t * p, int iVar ); +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 ); +/*=== 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 ); +extern void Gia_ManFanoutStart( Gia_Man_t * p ); +extern void Gia_ManFanoutStop( Gia_Man_t * p ); +/*=== giaFrames.c =========================================================*/ +extern void Gia_ManFraSetDefaultParams( Gia_ParFra_t * p ); +extern Gia_Man_t * Gia_ManFrames( Gia_Man_t * pAig, Gia_ParFra_t * pPars ); +/*=== giaFront.c ==========================================================*/ +extern Gia_Man_t * Gia_ManFront( Gia_Man_t * p ); +extern void Gia_ManFrontTest( Gia_Man_t * p ); +/*=== giaHash.c ===========================================================*/ +extern void Gia_ManHashAlloc( Gia_Man_t * p ); +extern void Gia_ManHashStart( Gia_Man_t * p ); +extern void Gia_ManHashStop( Gia_Man_t * p ); +extern int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 ); +extern int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 ); +extern int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 ); +extern Gia_Man_t * Gia_ManRehash( Gia_Man_t * p ); +/*=== giaLogic.c ===========================================================*/ +extern void Gia_ManTestDistance( Gia_Man_t * p ); + /*=== giaMan.c ===========================================================*/ +extern Gia_Man_t * Gia_ManStart( int nObjsMax ); +extern void Gia_ManStop( Gia_Man_t * p ); +extern void Gia_ManPrintStats( Gia_Man_t * p ); +extern void Gia_ManPrintStatsShort( Gia_Man_t * p ); +extern void Gia_ManPrintMiterStatus( Gia_Man_t * p ); +extern void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs ); +/*=== giaSat.c ============================================================*/ +extern int Sat_ManTest( Gia_Man_t * pGia, Gia_Obj_t * pObj, int nConfsMax ); +/*=== giaScl.c ============================================================*/ +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 ); +/*=== giaSim.c ============================================================*/ +extern int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars ); +/*=== giaTsim.c ============================================================*/ +extern Gia_Man_t * Gia_ManReduceConst( Gia_Man_t * pAig, int fVerbose ); +/*=== giaUtil.c ===========================================================*/ +extern void Gia_ManSetMark0( Gia_Man_t * p ); +extern void Gia_ManCleanMark0( Gia_Man_t * p ); +extern void Gia_ManSetMark1( Gia_Man_t * p ); +extern void Gia_ManCleanMark1( Gia_Man_t * p ); +extern void Gia_ManCleanValue( Gia_Man_t * p ); +extern void Gia_ManFillValue( Gia_Man_t * p ); +extern void Gia_ManSetPhase( Gia_Man_t * p ); +extern int Gia_ManLevelNum( Gia_Man_t * p ); +extern void Gia_ManSetRefs( Gia_Man_t * p ); +extern void Gia_ManCreateRefs( Gia_Man_t * p ); +extern int Gia_ManCrossCut( Gia_Man_t * p ); +extern int Gia_ManIsNormalized( Gia_Man_t * p ); +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 ); + +#ifdef __cplusplus +} +#endif + +#endif + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + diff --git a/src/aig/gia/giaAig.c b/src/aig/gia/giaAig.c new file mode 100644 index 00000000..8b59341a --- /dev/null +++ b/src/aig/gia/giaAig.c @@ -0,0 +1,214 @@ +/**CFile**************************************************************** + + FileName [giaAig.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Transformation between AIG manager.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaAig.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// 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) ); } + +static inline Aig_Obj_t * Gia_ObjChild0Copy2( Aig_Obj_t ** ppNodes, Gia_Obj_t * pObj, int Id ) { return Aig_NotCond( ppNodes[Gia_ObjFaninId0(pObj, Id)], Gia_ObjFaninC0(pObj) ); } +static inline Aig_Obj_t * Gia_ObjChild1Copy2( Aig_Obj_t ** ppNodes, Gia_Obj_t * pObj, int Id ) { return Aig_NotCond( ppNodes[Gia_ObjFaninId1(pObj, Id)], Gia_ObjFaninC1(pObj) ); } + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Derives combinational miter of the two AIGs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFromAig_rec( Gia_Man_t * pNew, Aig_Obj_t * pObj ) +{ + if ( pObj->pData ) + return; + if ( Aig_ObjIsPi(pObj) ) + { + pObj->iData = Gia_ManAppendCi( pNew ); + return; + } + assert( Aig_ObjIsNode(pObj) ); + Gia_ManFromAig_rec( pNew, Aig_ObjFanin0(pObj) ); + Gia_ManFromAig_rec( pNew, Aig_ObjFanin1(pObj) ); + pObj->iData = Gia_ManAppendAnd( pNew, Gia_ObjChild0Copy(pObj), Gia_ObjChild1Copy(pObj) ); +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManFromAig( Aig_Man_t * p ) +{ + Gia_Man_t * pNew; + Aig_Obj_t * pObj; + int i; + // add fake POs to all the dangling nodes (choices) + Aig_ManForEachNode( p, pObj, i ) + assert( Aig_ObjRefs(pObj) > 0 ); + // create the new manager + pNew = Gia_ManStart( Aig_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + // create the PIs + Aig_ManCleanData( p ); + Aig_ManConst1(p)->iData = 1; + Aig_ManForEachPi( p, pObj, i ) + { +// if ( Aig_ObjRefs(pObj) == 0 ) + pObj->iData = Gia_ManAppendCi( pNew ); + } + // add logic for the POs + Aig_ManForEachPo( p, pObj, i ) + { + Gia_ManFromAig_rec( pNew, Aig_ObjFanin0(pObj) ); + Gia_ManAppendCo( pNew, Gia_ObjChild0Copy(pObj) ); + } + Gia_ManSetRegNum( pNew, Aig_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Handles choices as additional combinational outputs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManFromAigSwitch( Aig_Man_t * p ) +{ + Gia_Man_t * pNew; + Aig_Obj_t * pObj; + int i; + // create the new manager + pNew = Gia_ManStart( Aig_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + // create the PIs + Aig_ManCleanData( p ); + Aig_ManConst1(p)->iData = 1; + Aig_ManForEachPi( p, pObj, i ) + pObj->iData = Gia_ManAppendCi( pNew ); + // add POs corresponding to the nodes with choices + Aig_ManForEachNode( p, pObj, i ) + if ( Aig_ObjRefs(pObj) == 0 ) + { + Gia_ManFromAig_rec( pNew, pObj ); + Gia_ManAppendCo( pNew, pObj->iData ); + } + // add logic for the POs + Aig_ManForEachPo( p, pObj, i ) + { + Gia_ManFromAig_rec( pNew, Aig_ObjFanin0(pObj) ); + Gia_ManAppendCo( pNew, Gia_ObjChild0Copy(pObj) ); + } + Gia_ManSetRegNum( pNew, Aig_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Derives combinational miter of the two AIGs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManToAig_rec( Aig_Man_t * pNew, Aig_Obj_t ** ppNodes, Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + if ( ppNodes[Gia_ObjId(p, pObj)] ) + return; + if ( Gia_ObjIsCi(pObj) ) + { + ppNodes[Gia_ObjId(p, pObj)] = Aig_ObjCreatePi( pNew ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + Gia_ManToAig_rec( pNew, ppNodes, p, Gia_ObjFanin0(pObj) ); + Gia_ManToAig_rec( pNew, ppNodes, p, Gia_ObjFanin1(pObj) ); + ppNodes[Gia_ObjId(p, pObj)] = Aig_And( pNew, Gia_ObjChild0Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)), Gia_ObjChild1Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)) ); +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Aig_Man_t * Gia_ManToAig( Gia_Man_t * p ) +{ + Aig_Man_t * pNew; + Aig_Obj_t ** ppNodes; + Gia_Obj_t * pObj; + int i; + + // create the new manager + pNew = Aig_ManStart( Gia_ManAndNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + ppNodes = ABC_CALLOC( Aig_Obj_t *, Gia_ManObjNum(p) ); + // create the PIs + ppNodes[0] = Aig_ManConst0(pNew); + Gia_ManForEachCi( p, pObj, i ) + { +// if ( Aig_ObjRefs(pObj) == 0 ) + ppNodes[Gia_ObjId(p, pObj)] = Aig_ObjCreatePi( pNew ); + } + // add logic for the POs + Gia_ManForEachCo( p, pObj, i ) + { + Gia_ManToAig_rec( pNew, ppNodes, p, Gia_ObjFanin0(pObj) ); + ppNodes[Gia_ObjId(p, pObj)] = Aig_ObjCreatePo( pNew, Gia_ObjChild0Copy2(ppNodes, pObj, Gia_ObjId(p, pObj)) ); + } + Aig_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + ABC_FREE( ppNodes ); + return pNew; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaAiger.c b/src/aig/gia/giaAiger.c new file mode 100644 index 00000000..40c5329d --- /dev/null +++ b/src/aig/gia/giaAiger.c @@ -0,0 +1,553 @@ +/**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" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// 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 [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 = Aig_UtilStrsav( FileName ); + if ( (pDot = strrchr( pRes, '.' )) ) + *pDot = 0; + return pRes; +} + +/**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( <ime ); + TimeStamp = asctime( localtime( <ime ) ); + TimeStamp[ strlen(TimeStamp) - 1 ] = 0; + strcpy( Buffer, TimeStamp ); + return Buffer; +} + +/**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 = Aig_UtilStrsav( pName ); +// pNew->pSpec = Aig_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 ); + + // 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 [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 [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) ) + 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\n" ); + if ( p->pName ) + fprintf( pFile, ".model %s\n", p->pName ); + fprintf( pFile, "This file was produced by the AIG package 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 ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaCof.c b/src/aig/gia/giaCof.c new file mode 100644 index 00000000..d58429cd --- /dev/null +++ b/src/aig/gia/giaCof.c @@ -0,0 +1,688 @@ +/**CFile**************************************************************** + + FileName [giaCof.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Cofactor estimation procedures.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaCof.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Cof_Fan_t_ Cof_Fan_t; +struct Cof_Fan_t_ +{ + unsigned iFan : 31; // ID of the fanin/fanout + unsigned fCompl : 1; // complemented attribute +}; + +typedef struct Cof_Obj_t_ Cof_Obj_t; +struct Cof_Obj_t_ +{ + unsigned fTerm : 1; // terminal node (CI/CO) + unsigned fPhase : 1; // value under 000 pattern + unsigned fMark0 : 1; // first user-controlled mark + unsigned fMark1 : 1; // second user-controlled mark + unsigned nFanins : 4; // the number of fanins + unsigned nFanouts : 24; // total number of fanouts + unsigned Value; // application specific data + int Id; // ID of the node + int iNext; // next one in the linked list + int iLit; // literal of the node after rehashing + Cof_Fan_t Fanios[0]; // the array of fanins/fanouts +}; + +typedef struct Cof_Man_t_ Cof_Man_t; +struct Cof_Man_t_ +{ + Gia_Man_t * pGia; // the original AIG manager + Vec_Int_t * vCis; // the vector of CIs (PIs + LOs) + Vec_Int_t * vCos; // the vector of COs (POs + LIs) + int nObjs; // the number of objects + int nNodes; // the number of nodes + int nTravIds; // traversal ID of the network + int * pObjData; // the logic network defined for the AIG + int nObjData; // the size of array to store the logic network + int * pLevels; // the linked lists of levels + int nLevels; // the max number of logic levels +}; + +static inline unsigned Gia_ObjHandle( Gia_Obj_t * pObj ) { return pObj->Value; } + +static inline int Cof_ObjLevel( Cof_Man_t * p, Cof_Obj_t * pObj ) { return Gia_ObjLevel(p->pGia, Gia_ManObj(p->pGia,pObj->Id)); } + +static inline unsigned Cof_ObjHandle( Cof_Man_t * p, Cof_Obj_t * pObj ) { return (unsigned)(((int *)pObj) - p->pObjData); } +static inline unsigned Cof_ObjHandleDiff( Cof_Obj_t * pObj, Cof_Obj_t * pFanin ) { return (unsigned)(((int *)pObj) - ((int *)pFanin)); } + +static inline int Cof_ObjIsTerm( Cof_Obj_t * pObj ) { return pObj->fTerm; } +static inline int Cof_ObjIsCi( Cof_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 0; } +static inline int Cof_ObjIsCo( Cof_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 1; } +static inline int Cof_ObjIsNode( Cof_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins > 0; } +static inline int Cof_ObjIsConst0( Cof_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins == 0; } + +static inline int Cof_ObjFaninNum( Cof_Obj_t * pObj ) { return pObj->nFanins; } +static inline int Cof_ObjFanoutNum( Cof_Obj_t * pObj ) { return pObj->nFanouts; } +static inline int Cof_ObjSize( Cof_Obj_t * pObj ) { return sizeof(Cof_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; } + +static inline Cof_Obj_t * Cof_ManObj( Cof_Man_t * p, unsigned iHandle ) { return (Cof_Obj_t *)(p->pObjData + iHandle); } +static inline Cof_Obj_t * Cof_ObjFanin( Cof_Obj_t * pObj, int i ) { return (Cof_Obj_t *)(((int *)pObj) - pObj->Fanios[i].iFan); } +static inline Cof_Obj_t * Cof_ObjFanout( Cof_Obj_t * pObj, int i ) { return (Cof_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i].iFan); } + +static inline int Cof_ManObjNum( Cof_Man_t * p ) { return p->nObjs; } +static inline int Cof_ManNodeNum( Cof_Man_t * p ) { return p->nNodes; } + +static inline void Cof_ManResetTravId( Cof_Man_t * p ) { extern void Cof_ManCleanValue( Cof_Man_t * p ); Cof_ManCleanValue( p ); p->nTravIds = 1; } +static inline void Cof_ManIncrementTravId( Cof_Man_t * p ) { p->nTravIds++; } +static inline void Cof_ObjSetTravId( Cof_Obj_t * pObj, int TravId ) { pObj->Value = TravId; } +static inline void Cof_ObjSetTravIdCurrent( Cof_Man_t * p, Cof_Obj_t * pObj ) { pObj->Value = p->nTravIds; } +static inline void Cof_ObjSetTravIdPrevious( Cof_Man_t * p, Cof_Obj_t * pObj ) { pObj->Value = p->nTravIds - 1; } +static inline int Cof_ObjIsTravIdCurrent( Cof_Man_t * p, Cof_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds); } +static inline int Cof_ObjIsTravIdPrevious( Cof_Man_t * p, Cof_Obj_t * pObj ) { return ((int)pObj->Value == p->nTravIds - 1); } + +#define Cof_ManForEachObj( p, pObj, i ) \ + for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) ) +#define Cof_ManForEachNode( p, pObj, i ) \ + for ( i = 0; (i < p->nObjData) && (pObj = Cof_ManObj(p,i)); i += Cof_ObjSize(pObj) ) if ( Cof_ObjIsTerm(pObj) ) {} else +#define Cof_ObjForEachFanin( pObj, pNext, i ) \ + for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Cof_ObjFanin(pObj,i)); i++ ) +#define Cof_ObjForEachFanout( pObj, pNext, i ) \ + for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Cof_ObjFanout(pObj,i)); i++ ) + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Creates logic network isomorphic to the given AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Cof_Man_t * Cof_ManCreateLogicSimple( Gia_Man_t * pGia ) +{ + Cof_Man_t * p; + Cof_Obj_t * pObjLog, * pFanLog; + Gia_Obj_t * pObj; + int i, iHandle = 0; + p = ABC_CALLOC( Cof_Man_t, 1 ); + p->pGia = pGia; + p->vCis = Vec_IntAlloc( Gia_ManCiNum(pGia) ); + p->vCos = Vec_IntAlloc( Gia_ManCoNum(pGia) ); + p->nObjData = (sizeof(Cof_Obj_t) / 4) * Gia_ManObjNum(pGia) + 4 * Gia_ManAndNum(pGia) + 2 * Gia_ManCoNum(pGia); + p->pObjData = ABC_CALLOC( int, p->nObjData ); + ABC_FREE( pGia->pRefs ); + Gia_ManCreateRefs( pGia ); + Gia_ManForEachObj( pGia, pObj, i ) + { + pObj->Value = iHandle; + pObjLog = Cof_ManObj( p, iHandle ); + pObjLog->nFanins = 0; + pObjLog->nFanouts = Gia_ObjRefs( pGia, pObj ); + pObjLog->Id = i; + pObjLog->Value = 0; + if ( Gia_ObjIsAnd(pObj) ) + { + pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin0(pObj)) ); + pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan = + pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog ); + pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC0(pObj); + + pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin1(pObj)) ); + pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan = + pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog ); + pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC1(pObj); + p->nNodes++; + } + else if ( Gia_ObjIsCo(pObj) ) + { + pFanLog = Cof_ManObj( p, Gia_ObjHandle(Gia_ObjFanin0(pObj)) ); + pFanLog->Fanios[pFanLog->nFanins + pFanLog->Value++].iFan = + pObjLog->Fanios[pObjLog->nFanins].iFan = Cof_ObjHandleDiff( pObjLog, pFanLog ); + pObjLog->Fanios[pObjLog->nFanins++].fCompl = Gia_ObjFaninC0(pObj); + + pObjLog->fTerm = 1; + Vec_IntPush( p->vCos, iHandle ); + } + else if ( Gia_ObjIsCi(pObj) ) + { + pObjLog->fTerm = 1; + Vec_IntPush( p->vCis, iHandle ); + } + iHandle += Cof_ObjSize( pObjLog ); + p->nObjs++; + } + assert( iHandle == p->nObjData ); + Gia_ManForEachObj( pGia, pObj, i ) + { + pObjLog = Cof_ManObj( p, Gia_ObjHandle(pObj) ); + assert( pObjLog->nFanouts == pObjLog->Value ); + } + return p; +} + +/**Function************************************************************* + + Synopsis [Creates logic network isomorphic to the given AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cof_ManStop( Cof_Man_t * p ) +{ + Vec_IntFree( p->vCis ); + Vec_IntFree( p->vCos ); + ABC_FREE( p->pObjData ); + ABC_FREE( p->pLevels ); + ABC_FREE( p ); +} + + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_ManTfoSize_rec( Cof_Man_t * p, Cof_Obj_t * pObj ) +{ + Cof_Obj_t * pNext; + unsigned i, Counter = 0; + if ( Cof_ObjIsTravIdCurrent(p, pObj) ) + return 0; + Cof_ObjSetTravIdCurrent(p, pObj); + if ( Cof_ObjIsCo(pObj) ) + return 0; + assert( Cof_ObjIsCi(pObj) || Cof_ObjIsNode(pObj) ); + Cof_ObjForEachFanout( pObj, pNext, i ) + Counter += Cof_ManTfoSize_rec( p, pNext ); + return 1 + Counter; +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_ManTfoSize( Cof_Man_t * p, Cof_Obj_t ** ppObjs, int nObjs ) +{ + int i, Counter = 0; + Cof_ManIncrementTravId( p ); + for ( i = 0; i < nObjs; i++ ) + Counter += Cof_ManTfoSize_rec( p, ppObjs[i] ) - 1; + return Counter; +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_ManTfiSize_rec( Cof_Man_t * p, Cof_Obj_t * pObj ) +{ + Cof_Obj_t * pNext; + unsigned i, Counter = 0; + if ( Cof_ObjIsTravIdCurrent(p, pObj) ) + return 0; + Cof_ObjSetTravIdCurrent(p, pObj); + if ( Cof_ObjIsCi(pObj) ) + return 0; + assert( Cof_ObjIsNode(pObj) ); + Cof_ObjForEachFanin( pObj, pNext, i ) + Counter += Cof_ManTfiSize_rec( p, pNext ); + return 1 + Counter; +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_ManTfiSize( Cof_Man_t * p, Cof_Obj_t ** ppObjs, int nObjs ) +{ + int i, Counter = 0; + Cof_ManIncrementTravId( p ); + for ( i = 0; i < nObjs; i++ ) + if ( Cof_ObjIsCo(ppObjs[i]) ) + Counter += Cof_ManTfiSize_rec( p, Cof_ObjFanin(ppObjs[i],0) ); + else + Counter += Cof_ManTfiSize_rec( p, ppObjs[i] ); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_ManSuppSize_rec( Cof_Man_t * p, Cof_Obj_t * pObj ) +{ + Cof_Obj_t * pNext; + unsigned i, Counter = 0; + if ( Cof_ObjIsTravIdCurrent(p, pObj) ) + return 0; + Cof_ObjSetTravIdCurrent(p, pObj); + if ( Cof_ObjIsCi(pObj) ) + return 1; + assert( Cof_ObjIsNode(pObj) ); + Cof_ObjForEachFanin( pObj, pNext, i ) + Counter += Cof_ManSuppSize_rec( p, pNext ); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_ManSuppSize( Cof_Man_t * p, Cof_Obj_t ** ppObjs, int nObjs ) +{ + int i, Counter = 0; + Cof_ManIncrementTravId( p ); + for ( i = 0; i < nObjs; i++ ) + if ( Cof_ObjIsCo(ppObjs[i]) ) + Counter += Cof_ManSuppSize_rec( p, Cof_ObjFanin(ppObjs[i],0) ); + else + Counter += Cof_ManSuppSize_rec( p, ppObjs[i] ); + return Counter; +} + + +/**Function************************************************************* + + Synopsis [Cleans the value.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cof_ManCleanValue( Cof_Man_t * p ) +{ + Cof_Obj_t * pObj; + int i; + Cof_ManForEachObj( p, pObj, i ) + pObj->Value = 0; +} + +/**Function************************************************************* + + Synopsis [Returns sorted array of node handles with largest fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cof_ManInsertEntry_rec( Vec_Ptr_t * vNodes, Cof_Obj_t * pNode, int nNodeMax ) +{ + Cof_Obj_t * pLast; + if ( Vec_PtrSize(vNodes) == 0 ) + { + Vec_PtrPush(vNodes, pNode); + return; + } + pLast = Vec_PtrPop(vNodes); + if ( Cof_ObjFanoutNum(pLast) < Cof_ObjFanoutNum(pNode) ) + { + Cof_ManInsertEntry_rec( vNodes, pNode, nNodeMax ); + if ( Vec_PtrSize(vNodes) < nNodeMax ) + Vec_PtrPush( vNodes, pLast ); + } + else + { + Vec_PtrPush( vNodes, pLast ); + if ( Vec_PtrSize(vNodes) < nNodeMax ) + Vec_PtrPush( vNodes, pNode ); + } +} + +/**Function************************************************************* + + Synopsis [Returns sorted array of node handles with largest fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Ptr_t * Cof_ManCollectHighFanout( Cof_Man_t * p, int nNodes ) +{ + Vec_Ptr_t * vNodes; + Cof_Obj_t * pObj; + int i; + vNodes = Vec_PtrAlloc( nNodes ); + Cof_ManForEachObj( p, pObj, i ) + if ( Cof_ObjIsCi(pObj) || Cof_ObjIsNode(pObj) ) + Cof_ManInsertEntry_rec( vNodes, pObj, nNodes ); + return vNodes; +} + +/**Function************************************************************* + + Synopsis [Returns sorted array of node handles with largest fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_ManCountRemoved( Cof_Man_t * p, Cof_Obj_t * pRoot, int fConst1 ) +{ + Gia_Obj_t * pNextGia; + Cof_Obj_t * pTemp, * pNext, * pFanin0, * pFanin1; + int Counter = 0, LevelStart, LevelNext; + int i, k, iHandle, iLit0, iLit1, iNextNew; + // restart the trav ids + Cof_ManIncrementTravId( p ); + Cof_ObjSetTravIdCurrent( p, pRoot ); + // add the node to the queue + LevelStart = Cof_ObjLevel(p, pRoot); + assert( p->pLevels[LevelStart] == 0 ); + pRoot->iNext = 0; + p->pLevels[LevelStart] = Cof_ObjHandle( p, pRoot ); + // set the new literal + pRoot->iLit = Gia_Var2Lit( 0, fConst1 ); + // process nodes in the levelized order + for ( i = LevelStart; i < p->nLevels; i++ ) + { + for ( iHandle = p->pLevels[i]; + iHandle && (pTemp = Cof_ManObj(p, iHandle)); + iHandle = pTemp->iNext ) + { + assert( pTemp->Id != Gia_Lit2Var(pTemp->iLit) ); + Cof_ObjForEachFanout( pTemp, pNext, k ) + { + if ( Cof_ObjIsCo(pNext) ) + continue; + if ( Cof_ObjIsTravIdCurrent(p, pNext) ) + continue; + pFanin0 = Cof_ObjFanin( pNext, 0 ); + pFanin1 = Cof_ObjFanin( pNext, 1 ); + assert( pFanin0 == pTemp || pFanin1 == pTemp ); + pNextGia = Gia_ManObj( p->pGia, pNext->Id ); + if ( Cof_ObjIsTravIdCurrent(p, pFanin0) ) + iLit0 = Gia_LitNotCond( pFanin0->iLit, Gia_ObjFaninC0(pNextGia) ); + else + iLit0 = Gia_ObjFaninLit0( pNextGia, pNext->Id ); + if ( Cof_ObjIsTravIdCurrent(p, pFanin1) ) + iLit1 = Gia_LitNotCond( pFanin1->iLit, Gia_ObjFaninC1(pNextGia) ); + else + iLit1 = Gia_ObjFaninLit1( pNextGia, pNext->Id ); + iNextNew = Gia_ManHashAndTry( p->pGia, iLit0, iLit1 ); + if ( iNextNew == -1 ) + continue; + Cof_ObjSetTravIdCurrent(p, pNext); + // set the new literal + pNext->iLit = iNextNew; + // add it to be processed + LevelNext = Cof_ObjLevel( p, pNext ); + assert( LevelNext > i && LevelNext < p->nLevels ); + pNext->iNext = p->pLevels[LevelNext]; + p->pLevels[LevelNext] = Cof_ObjHandle( p, pNext ); + Counter++; + } + } + p->pLevels[i] = 0; + } + return Counter; +} + +/**Function************************************************************* + + Synopsis [Returns sorted array of node handles with largest fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cof_ManPrintHighFanoutOne( Cof_Man_t * p, Cof_Obj_t * pObj ) +{ + printf( "%7d : ", pObj->Id ); + printf( "fi =%2d ", Cof_ObjFaninNum(pObj) ); + printf( "fo =%5d ", Cof_ObjFanoutNum(pObj) ); + printf( "l =%4d ", Cof_ObjLevel(p, pObj) ); + printf( "s =%5d ", Cof_ManSuppSize(p, &pObj, 1) ); + printf( "TFI =%7d ", Cof_ManTfiSize(p, &pObj, 1) ); + printf( "TFO =%7d ", Cof_ManTfoSize(p, &pObj, 1) ); + printf( "C0 =%6d ", Cof_ManCountRemoved(p, pObj, 0) ); + printf( "C1 =%6d", Cof_ManCountRemoved(p, pObj, 1) ); + printf( "\n" ); +} + +/**Function************************************************************* + + Synopsis [Returns sorted array of node handles with largest fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cof_ManPrintHighFanout( Cof_Man_t * p, int nNodes ) +{ + Vec_Ptr_t * vNodes; + Cof_Obj_t * pObj; + int i; + vNodes = Cof_ManCollectHighFanout( p, nNodes ); + Vec_PtrForEachEntry( vNodes, pObj, i ) + Cof_ManPrintHighFanoutOne( p, pObj ); + Vec_PtrFree( vNodes ); +} + +/**Function************************************************************* + + Synopsis [Prints the distribution of fanins/fanouts in the network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Cof_ManPrintFanio( Cof_Man_t * p ) +{ + char Buffer[100]; + Cof_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; + Cof_ManForEachNode( p, pNode, i ) + { + if ( i == 0 ) continue; + nFanins = Cof_ObjFaninNum(pNode); + nFanouts = Cof_ObjFanoutNum(pNode); + nFaninsAll += nFanins; + nFanoutsAll += nFanouts; + nFaninsMax = ABC_MAX( nFaninsMax, nFanins ); + nFanoutsMax = ABC_MAX( nFanoutsMax, nFanouts ); + } + + // allocate storage for fanin/fanout numbers + nSizeMax = AIG_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 + Cof_ManForEachNode( p, pNode, i ) + { + if ( i == 0 ) continue; + nFanins = Cof_ObjFaninNum(pNode); + nFanouts = Cof_ObjFanoutNum(pNode); +// nFanouts = Cof_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/Cof_ManNodeNum(p), + nFanoutsMax, 1.0*nFanoutsAll/Cof_ManNodeNum(p) ); +} + +/**Function************************************************************* + + Synopsis [Returns sorted array of node handles with largest fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPrintFanio( Gia_Man_t * pGia, int nNodes ) +{ + Cof_Man_t * p; + int clk = clock(); + p = Cof_ManCreateLogicSimple( pGia ); + p->nLevels = 1 + Gia_ManLevelNum( pGia ); + p->pLevels = ABC_CALLOC( int, p->nLevels ); + Cof_ManPrintFanio( p ); + + Cof_ManResetTravId( p ); + Gia_ManHashStart( pGia ); + Cof_ManPrintHighFanout( p, nNodes ); + Gia_ManHashStop( pGia ); +ABC_PRM( "Memory for logic network", 4*p->nObjData ); +ABC_PRT( "Time", clock() - clk ); + Cof_ManStop( p ); +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaConstr.c b/src/aig/gia/giaConstr.c new file mode 100644 index 00000000..14768cc2 --- /dev/null +++ b/src/aig/gia/giaConstr.c @@ -0,0 +1,47 @@ +/**CFile**************************************************************** + + FileName [giaConstr.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Constraint propagation in CNF-based solver.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaConstr.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaDfs.c b/src/aig/gia/giaDfs.c new file mode 100644 index 00000000..a978dcc3 --- /dev/null +++ b/src/aig/gia/giaDfs.c @@ -0,0 +1,243 @@ +/**CFile**************************************************************** + + FileName [giaDfs.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [DFS procedures.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaDfs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Counts the support size of the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectCis_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSupp ) +{ + if ( Gia_ObjIsTravIdCurrent(p, pObj) ) + return; + Gia_ObjSetTravIdCurrent(p, pObj); + if ( Gia_ObjIsCi(pObj) ) + { + Vec_IntPush( vSupp, Gia_ObjId(p, pObj) ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + Gia_ManCollectCis_rec( p, Gia_ObjFanin0(pObj), vSupp ); + Gia_ManCollectCis_rec( p, Gia_ObjFanin1(pObj), vSupp ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectCis( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vSupp ) +{ + Gia_Obj_t * pObj; + int i; + Vec_IntClear( vSupp ); + 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_ManCollectCis_rec( p, Gia_ObjFanin0(pObj), vSupp ); + else + Gia_ManCollectCis_rec( p, pObj, vSupp ); + } +} + +/**Function************************************************************* + + Synopsis [Counts the support size of the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectAnds_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) ) + return; + assert( Gia_ObjIsAnd(pObj) ); + Gia_ManCollectAnds_rec( p, Gia_ObjFanin0(pObj), vNodes ); + Gia_ManCollectAnds_rec( p, Gia_ObjFanin1(pObj), vNodes ); + Vec_IntPush( vNodes, Gia_ObjId(p, pObj) ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCollectAnds( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vNodes ) +{ + Gia_Obj_t * pObj; + int i; + Vec_IntClear( vNodes ); + 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_ManCollectAnds_rec( p, Gia_ObjFanin0(pObj), vNodes ); + else + Gia_ManCollectAnds_rec( p, pObj, vNodes ); + } +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSuppSize_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_ManSuppSize_rec( p, Gia_ObjFanin0(pObj) ) + + Gia_ManSuppSize_rec( p, Gia_ObjFanin1(pObj) ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNodes ) +{ + Gia_Obj_t * pObj; + int i, Counter = 0; + 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) ) + Counter += Gia_ManSuppSize_rec( p, Gia_ObjFanin0(pObj) ); + else + Counter += Gia_ManSuppSize_rec( p, pObj ); + } + return Counter; +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManConeSize_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 0; + assert( Gia_ObjIsAnd(pObj) ); + return 1 + Gia_ManConeSize_rec( p, Gia_ObjFanin0(pObj) ) + + Gia_ManConeSize_rec( p, Gia_ObjFanin1(pObj) ); +} + +/**Function************************************************************* + + Synopsis [Collects support nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes ) +{ + Gia_Obj_t * pObj; + int i, Counter = 0; + 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) ) + Counter += Gia_ManConeSize_rec( p, Gia_ObjFanin0(pObj) ); + else + Counter += Gia_ManConeSize_rec( p, pObj ); + } + return Counter; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c new file mode 100644 index 00000000..f8d759be --- /dev/null +++ b/src/aig/gia/giaDup.c @@ -0,0 +1,698 @@ +/**CFile**************************************************************** + + FileName [giaDup.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Duplication procedures.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaDup.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Duplicates AIG without any changes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDup( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachObj1( p, pObj, i ) + { + if ( Gia_ObjIsAnd(pObj) ) + pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + else if ( Gia_ObjIsCi(pObj) ) + pObj->Value = Gia_ManAppendCi( pNew ); + else if ( Gia_ObjIsCo(pObj) ) + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + } + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG without any changes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupMarked( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i, nRos = 0, nRis = 0; + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachObj1( p, pObj, i ) + { + if ( pObj->fMark0 ) + continue; + if ( Gia_ObjIsAnd(pObj) ) + pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + else if ( Gia_ObjIsCi(pObj) ) + { + pObj->Value = Gia_ManAppendCi( pNew ); + nRos += Gia_ObjIsRo(p, pObj); + } + else if ( Gia_ObjIsCo(pObj) ) + { + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + nRis += Gia_ObjIsRi(p, pObj); + } + } + assert( nRos == nRis ); + Gia_ManSetRegNum( pNew, nRos ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG while creating "parallel" copies.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupTimes( Gia_Man_t * p, int nTimes ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + Vec_Int_t * vPis, * vPos, * vRis, * vRos; + int i, t, Entry; + assert( nTimes > 0 ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + vPis = Vec_IntAlloc( Gia_ManPiNum(p) * nTimes ); + vPos = Vec_IntAlloc( Gia_ManPoNum(p) * nTimes ); + vRis = Vec_IntAlloc( Gia_ManRegNum(p) * nTimes ); + vRos = Vec_IntAlloc( Gia_ManRegNum(p) * nTimes ); + for ( t = 0; t < nTimes; t++ ) + { + Gia_ManForEachObj1( p, pObj, i ) + { + if ( Gia_ObjIsAnd(pObj) ) + pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + else if ( Gia_ObjIsCi(pObj) ) + { + pObj->Value = Gia_ManAppendCi( pNew ); + if ( Gia_ObjIsPi(p, pObj) ) + Vec_IntPush( vPis, Gia_Lit2Var(pObj->Value) ); + else + Vec_IntPush( vRos, Gia_Lit2Var(pObj->Value) ); + } + else if ( Gia_ObjIsCo(pObj) ) + { + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + if ( Gia_ObjIsPo(p, pObj) ) + Vec_IntPush( vPos, Gia_Lit2Var(pObj->Value) ); + else + Vec_IntPush( vRis, Gia_Lit2Var(pObj->Value) ); + } + } + } + Vec_IntClear( pNew->vCis ); + Vec_IntForEachEntry( vPis, Entry, i ) + { + Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCis) ); + Vec_IntPush( pNew->vCis, Entry ); + } + Vec_IntForEachEntry( vRos, Entry, i ) + { + Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCis) ); + Vec_IntPush( pNew->vCis, Entry ); + } + Vec_IntClear( pNew->vCos ); + Vec_IntForEachEntry( vPos, Entry, i ) + { + Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCos) ); + Vec_IntPush( pNew->vCos, Entry ); + } + Vec_IntForEachEntry( vRis, Entry, i ) + { + Gia_ObjSetCioId( Gia_ManObj(pNew, Entry), Vec_IntSize(pNew->vCos) ); + Vec_IntPush( pNew->vCos, Entry ); + } + Vec_IntFree( vPis ); + Vec_IntFree( vPos ); + Vec_IntFree( vRis ); + Vec_IntFree( vRos ); + Gia_ManSetRegNum( pNew, nTimes * Gia_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates the AIG in the DFS order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManDupDfs_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + if ( ~pObj->Value ) + return pObj->Value; + if ( p->pReprs && ~p->pReprs[Gia_ObjId(p, pObj)] ) + { + Gia_Obj_t * pRepr = Gia_ManObj( p, p->pReprs[Gia_ObjId(p, pObj)] ); + pObj->Value = Gia_ManDupDfs_rec( pNew, p, pRepr ); + return pObj->Value = Gia_LitNotCond( pObj->Value, Gia_ObjPhaseReal(pRepr) ^ Gia_ObjPhaseReal(pObj) ); + } + if ( Gia_ObjIsCi(pObj) ) + return pObj->Value = Gia_ManAppendCi(pNew); + Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin0(pObj) ); + if ( Gia_ObjIsCo(pObj) ) + return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + Gia_ManDupDfs_rec( pNew, p, Gia_ObjFanin1(pObj) ); + if ( pNew->pHTable ) + return pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj, * pObjNew; + int i; + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCo( p, pObj, i ) + Gia_ManDupDfs_rec( pNew, p, pObj ); + Gia_ManForEachCi( p, pObj, i ) + if ( ~pObj->Value == 0 ) + pObj->Value = Gia_ManAppendCi(pNew); + assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(p) ); + // remap combinational inputs + Gia_ManForEachCi( p, pObj, i ) + { + pObjNew = Gia_ObjFromLit( pNew, pObj->Value ); + assert( !Gia_IsComplement(pObjNew) ); + Vec_IntWriteEntry( pNew->vCis, Gia_ObjCioId(pObj), Gia_ObjId(pNew, pObjNew) ); + Gia_ObjSetCioId( pObjNew, Gia_ObjCioId(pObj) ); + } + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order while putting CIs first.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupDfsSkip( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + pObj->Value = Gia_ManAppendCi(pNew); + Gia_ManForEachCo( p, pObj, i ) + if ( pObj->fMark1 == 0 ) + Gia_ManDupDfs_rec( pNew, p, pObj ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order while putting CIs first.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupDfsCone( Gia_Man_t * p, Gia_Obj_t * pRoot ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + assert( Gia_ObjIsCo(pRoot) ); + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + pObj->Value = Gia_ManAppendCi(pNew); + Gia_ManDupDfs_rec( pNew, p, pRoot ); + Gia_ManSetRegNum( pNew, 0 ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order while putting CIs first.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupDfsLitArray( Gia_Man_t * p, Vec_Int_t * vLits ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i, iLit, iLitRes; + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + pObj->Value = Gia_ManAppendCi(pNew); + Vec_IntForEachEntry( vLits, iLit, i ) + { + iLitRes = Gia_ManDupDfs_rec( pNew, p, Gia_ManObj(p, Gia_Lit2Var(iLit)) ); + Gia_ManAppendCo( pNew, Gia_LitNotCond( iLitRes, Gia_LitIsCompl(iLit)) ); + } + Gia_ManSetRegNum( pNew, 0 ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order while putting CIs first.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupNormalized( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + 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) ); + Gia_ManForEachCo( p, pObj, i ) + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + assert( Gia_ManIsNormalized(pNew) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order while putting CIs first.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupTrimmed( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManSetRefs( p ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + if ( pObj->Value > 0 || Gia_ObjIsRo(p, pObj) ) + pObj->Value = Gia_ManAppendCi(pNew); + Gia_ManForEachAnd( p, pObj, i ) + pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + Gia_ManForEachCo( p, pObj, i ) + if ( !Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) || Gia_ObjIsRi(p, pObj) ) + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order while putting CIs first.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupCofactored( Gia_Man_t * p, int iVar ) +{ + Gia_Man_t * pNew, * pTemp; + Gia_Obj_t * pObj, * pPivot; + int i; + assert( Gia_ManRegNum(p) == 0 ); + assert( iVar < Gia_ManObjNum(p) ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManHashAlloc( pNew ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + pObj->Value = Gia_ManAppendCi(pNew); + // find the cofactoring variable + pPivot = Gia_ManObj(p, iVar); + // compute the negative cofactor + if ( Gia_ObjIsCi(pPivot) ) + pPivot->Value = Gia_Var2Lit( 0, 0 ); + Gia_ManForEachAnd( p, pObj, i ) + { + pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + if ( pObj == pPivot ) + pPivot->Value = Gia_Var2Lit( 0, 0 ); + } + Gia_ManForEachCo( p, pObj, i ) + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + // compute the positive cofactor + if ( Gia_ObjIsCi(pPivot) ) + pPivot->Value = Gia_Var2Lit( 0, 1 ); + Gia_ManForEachAnd( p, pObj, i ) + { + pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + if ( pObj == pPivot ) + pPivot->Value = Gia_Var2Lit( 0, 1 ); + } + Gia_ManForEachCo( p, pObj, i ) + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + Gia_ManHashStop( pNew ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + // rehash the result + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Print representatives.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPrintRepr( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + Gia_ManForEachObj( p, pObj, i ) + if ( ~p->pReprs[i] ) + printf( "%d->%d ", i, p->pReprs[i] ); + printf( "\n" ); +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupDfsCiMap( Gia_Man_t * p, int * pCi2Lit, Vec_Int_t * vLits ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + { + pObj->Value = Gia_ManAppendCi(pNew); + if ( ~pCi2Lit[i] ) + pObj->Value = Gia_LitNotCond( Gia_ManObj(p, Gia_Lit2Var(pCi2Lit[i]))->Value, Gia_LitIsCompl(pCi2Lit[i]) ); + } + Gia_ManHashAlloc( pNew ); + if ( vLits ) + { + int iLit, iLitRes; + Vec_IntForEachEntry( vLits, iLit, i ) + { + iLitRes = Gia_ManDupDfs_rec( pNew, p, Gia_ManObj(p, Gia_Lit2Var(iLit)) ); + Gia_ManAppendCo( pNew, Gia_LitNotCond( iLitRes, Gia_LitIsCompl(iLit)) ); + } + } + else + { + Gia_ManForEachCo( p, pObj, i ) + Gia_ManDupDfs_rec( pNew, p, pObj ); + } + Gia_ManHashStop( pNew ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Duplicates AIG in the DFS order.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupDfsClasses( Gia_Man_t * p ) +{ + Gia_Man_t * pNew, * pTemp; + Gia_Obj_t * pObj; + int i; + assert( p->pReprs != NULL ); + Gia_ManFillValue( p ); + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachCi( p, pObj, i ) + pObj->Value = Gia_ManAppendCi(pNew); + Gia_ManHashAlloc( pNew ); + Gia_ManForEachCo( p, pObj, i ) + Gia_ManDupDfs_rec( pNew, p, pObj ); + Gia_ManHashStop( pNew ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Detect topmost gate.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupTopAnd_iter( Gia_Man_t * p, int fVerbose ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + Vec_Int_t * vFront, * vLeaves; + int i, iLit, iObjId, nCiLits, * pCi2Lit; + char * pVar2Val; + // collect the frontier + vFront = Vec_IntAlloc( 1000 ); + vLeaves = Vec_IntAlloc( 1000 ); + Gia_ManForEachCo( p, pObj, i ) + { + if ( Gia_ObjIsConst0( Gia_ObjFanin0(pObj) ) ) + continue; + if ( Gia_ObjFaninC0(pObj) ) + Vec_IntPush( vLeaves, Gia_ObjFaninLit0p(p, pObj) ); + else + Vec_IntPush( vFront, Gia_ObjFaninId0p(p, pObj) ); + } + if ( Vec_IntSize(vFront) == 0 ) + { + if ( fVerbose ) + printf( "The AIG cannot be decomposed using AND-decomposition.\n" ); + Vec_IntFree( vFront ); + Vec_IntFree( vLeaves ); + return Gia_ManDupNormalized( p ); + } + // expand the frontier + Gia_ManForEachObjVec( vFront, p, pObj, i ) + { + if ( Gia_ObjIsCi(pObj) ) + { + Vec_IntPush( vLeaves, Gia_Var2Lit( Gia_ObjId(p, pObj), 0 ) ); + continue; + } + assert( Gia_ObjIsAnd(pObj) ); + if ( Gia_ObjFaninC0(pObj) ) + Vec_IntPush( vLeaves, Gia_ObjFaninLit0p(p, pObj) ); + else + Vec_IntPush( vFront, Gia_ObjFaninId0p(p, pObj) ); + if ( Gia_ObjFaninC1(pObj) ) + Vec_IntPush( vLeaves, Gia_ObjFaninLit1p(p, pObj) ); + else + Vec_IntPush( vFront, Gia_ObjFaninId1p(p, pObj) ); + } + Vec_IntFree( vFront ); + // sort the literals + nCiLits = 0; + pCi2Lit = ABC_FALLOC( int, Gia_ManObjNum(p) ); + pVar2Val = ABC_FALLOC( char, Gia_ManObjNum(p) ); + Vec_IntForEachEntry( vLeaves, iLit, i ) + { + iObjId = Gia_Lit2Var(iLit); + pObj = Gia_ManObj(p, iObjId); + if ( Gia_ObjIsCi(pObj) ) + { + pCi2Lit[Gia_ObjCioId(pObj)] = !Gia_LitIsCompl(iLit); + nCiLits++; + } + if ( pVar2Val[iObjId] != 0 && pVar2Val[iObjId] != 1 ) + pVar2Val[iObjId] = Gia_LitIsCompl(iLit); + else if ( pVar2Val[iObjId] != Gia_LitIsCompl(iLit) ) + break; + } + if ( i < Vec_IntSize(vLeaves) ) + { + printf( "Problem is trivially UNSAT.\n" ); + ABC_FREE( pCi2Lit ); + ABC_FREE( pVar2Val ); + Vec_IntFree( vLeaves ); + return Gia_ManDupNormalized( p ); + } + // create array of input literals + Vec_IntClear( vLeaves ); + Gia_ManForEachObj( p, pObj, i ) + if ( !Gia_ObjIsCi(pObj) && (pVar2Val[i] == 0 || pVar2Val[i] == 1) ) + Vec_IntPush( vLeaves, Gia_Var2Lit(i, pVar2Val[i]) ); + if ( fVerbose ) + printf( "Detected %6d AND leaves and %6d CI leaves.\n", Vec_IntSize(vLeaves), nCiLits ); + // create the input map + if ( nCiLits == 0 ) + pNew = Gia_ManDupDfsLitArray( p, vLeaves ); + else + pNew = Gia_ManDupDfsCiMap( p, pCi2Lit, vLeaves ); + ABC_FREE( pCi2Lit ); + ABC_FREE( pVar2Val ); + Vec_IntFree( vLeaves ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Detect topmost gate.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupTopAnd( Gia_Man_t * p, int fVerbose ) +{ + Gia_Man_t * pNew, * pTemp; + int fContinue, iIter = 0; + pNew = Gia_ManDupNormalized( p ); + for ( fContinue = 1; fContinue; ) + { + pNew = Gia_ManDupTopAnd_iter( pTemp = pNew, fVerbose ); + if ( Gia_ManCoNum(pNew) == Gia_ManCoNum(pTemp) && Gia_ManAndNum(pNew) == Gia_ManAndNum(pTemp) ) + fContinue = 0; + Gia_ManStop( pTemp ); + if ( fVerbose ) + { + printf( "Iter %2d : ", ++iIter ); + Gia_ManPrintStatsShort( pNew ); + } + } + return pNew; +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaFanout.c b/src/aig/gia/giaFanout.c new file mode 100644 index 00000000..42ccd7e7 --- /dev/null +++ b/src/aig/gia/giaFanout.c @@ -0,0 +1,197 @@ +/**CFile**************************************************************** + + FileName [giaFanout.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: giaFanout.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +// 0: first iFan +// 1: prev iFan0 +// 2: prev iFan1 +// 3: next iFan0 +// 4: next iFan1 + +static inline int Gia_FanoutCreate( int FanId, int Num ) { assert( Num < 2 ); return (FanId << 1) | Num; } +static inline int * Gia_FanoutObj( int * pData, int ObjId ) { return pData + 5*ObjId; } +static inline int * Gia_FanoutPrev( int * pData, int iFan ) { return pData + 5*(iFan >> 1) + 1 + (iFan & 1); } +static inline int * Gia_FanoutNext( int * pData, int iFan ) { return pData + 5*(iFan >> 1) + 3 + (iFan & 1); } + +// these two procedures are only here for the use inside the iterator +static inline int Gia_ObjFanout0Int( Gia_Man_t * p, int ObjId ) { assert(ObjId < p->nFansAlloc); return p->pFanData[5*ObjId]; } +static inline int Gia_ObjFanoutNext( Gia_Man_t * p, int iFan ) { assert(iFan/2 < p->nFansAlloc); return p->pFanData[5*(iFan >> 1) + 3 + (iFan & 1)]; } +// iterator over the fanouts +#define Gia_ObjForEachFanout( p, pObj, pFanout, iFan, i ) \ + for ( assert(p->pFanData), i = 0; (i < (int)(pObj)->nRefs) && \ + (((iFan) = i? Gia_ObjFanoutNext(p, iFan) : Gia_ObjFanout0Int(p, Gia_ObjId(p, pObj))), 1) && \ + (((pFanout) = Gia_ManObj(p, iFan>>1)), 1); i++ ) + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Create fanout for all objects in the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFanoutStart( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + // allocate fanout datastructure + assert( p->pFanData == NULL ); + p->nFansAlloc = 2 * Gia_ManObjNum(p); + if ( p->nFansAlloc < (1<<12) ) + p->nFansAlloc = (1<<12); + p->pFanData = ABC_ALLOC( int, 5 * p->nFansAlloc ); + memset( p->pFanData, 0, sizeof(int) * 5 * p->nFansAlloc ); + // add fanouts for all objects + Gia_ManForEachObj( p, pObj, i ) + { + if ( Gia_ObjChild0(pObj) ) + Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj ); + if ( Gia_ObjChild1(pObj) ) + Gia_ObjAddFanout( p, Gia_ObjFanin1(pObj), pObj ); + } +} + +/**Function************************************************************* + + Synopsis [Deletes fanout for all objects in the manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFanoutStop( Gia_Man_t * p ) +{ + assert( p->pFanData != NULL ); + ABC_FREE( p->pFanData ); + p->nFansAlloc = 0; +} + +/**Function************************************************************* + + Synopsis [Adds fanout (pFanout) of node (pObj).] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ObjAddFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout ) +{ + int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext; + assert( p->pFanData ); + assert( !Gia_IsComplement(pObj) && !Gia_IsComplement(pFanout) ); + assert( Gia_ObjId(p, pFanout) > 0 ); + if ( Gia_ObjId(p, pObj) >= p->nFansAlloc || Gia_ObjId(p, pFanout) >= p->nFansAlloc ) + { + int nFansAlloc = 2 * AIG_MAX( Gia_ObjId(p, pObj), Gia_ObjId(p, pFanout) ); + p->pFanData = ABC_REALLOC( int, p->pFanData, 5 * nFansAlloc ); + memset( p->pFanData + 5 * p->nFansAlloc, 0, sizeof(int) * 5 * (nFansAlloc - p->nFansAlloc) ); + p->nFansAlloc = nFansAlloc; + } + assert( Gia_ObjId(p, pObj) < p->nFansAlloc && Gia_ObjId(p, pFanout) < p->nFansAlloc ); + iFan = Gia_FanoutCreate( Gia_ObjId(p, pFanout), Gia_ObjWhatFanin(pFanout, pObj) ); + pPrevC = Gia_FanoutPrev( p->pFanData, iFan ); + pNextC = Gia_FanoutNext( p->pFanData, iFan ); + pFirst = Gia_FanoutObj( p->pFanData, Gia_ObjId(p, pObj) ); + if ( *pFirst == 0 ) + { + *pFirst = iFan; + *pPrevC = iFan; + *pNextC = iFan; + } + else + { + pPrev = Gia_FanoutPrev( p->pFanData, *pFirst ); + pNext = Gia_FanoutNext( p->pFanData, *pPrev ); + assert( *pNext == *pFirst ); + *pPrevC = *pPrev; + *pNextC = *pFirst; + *pPrev = iFan; + *pNext = iFan; + } +} + +/**Function************************************************************* + + Synopsis [Removes fanout (pFanout) of node (pObj).] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ObjRemoveFanout( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanout ) +{ + int iFan, * pFirst, * pPrevC, * pNextC, * pPrev, * pNext; + assert( p->pFanData && Gia_ObjId(p, pObj) < p->nFansAlloc && Gia_ObjId(p, pFanout) < p->nFansAlloc ); + assert( !Gia_IsComplement(pObj) && !Gia_IsComplement(pFanout) ); + assert( Gia_ObjId(p, pFanout) > 0 ); + iFan = Gia_FanoutCreate( Gia_ObjId(p, pFanout), Gia_ObjWhatFanin(pFanout, pObj) ); + pPrevC = Gia_FanoutPrev( p->pFanData, iFan ); + pNextC = Gia_FanoutNext( p->pFanData, iFan ); + pPrev = Gia_FanoutPrev( p->pFanData, *pNextC ); + pNext = Gia_FanoutNext( p->pFanData, *pPrevC ); + assert( *pPrev == iFan ); + assert( *pNext == iFan ); + pFirst = Gia_FanoutObj( p->pFanData, Gia_ObjId(p, pObj) ); + assert( *pFirst > 0 ); + if ( *pFirst == iFan ) + { + if ( *pNextC == iFan ) + { + *pFirst = 0; + *pPrev = 0; + *pNext = 0; + *pPrevC = 0; + *pNextC = 0; + return; + } + *pFirst = *pNextC; + } + *pPrev = *pPrevC; + *pNext = *pNextC; + *pPrevC = 0; + *pNextC = 0; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaForce.c b/src/aig/gia/giaForce.c new file mode 100644 index 00000000..eae0a1cc --- /dev/null +++ b/src/aig/gia/giaForce.c @@ -0,0 +1,164 @@ +/**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" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [This is implementation of qsort in MiniSat.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static int num_cmp ( int * x, int * y) { return ((*x) < (*y)) ? -1 : 1; } +// Returns a random float 0 <= x < 1. Seed must never be 0. +static inline double drand(double* seed) { + int q; + *seed *= 1389796; + q = (int)(*seed / 2147483647); + *seed -= (double)q * 2147483647; + return *seed / 2147483647; } +// Returns a random integer 0 <= x < size. Seed must never be 0. +static inline int irand(double* seed, int size) { + return (int)(drand(seed) * size); } +static inline void selectionsort(int* array, int size, int(*comp)(const void *, const void *)) +{ + int i, j, best_i; + int tmp; + for (i = 0; i < size-1; i++){ + best_i = i; + for (j = i+1; j < size; j++){ + if (comp(array + j, array + best_i) < 0) + best_i = j; + } + tmp = array[i]; array[i] = array[best_i]; array[best_i] = tmp; + } +} +static void sortrnd(int* array, int size, int(*comp)(const void *, const void *), double* seed) +{ + if (size <= 15) + selectionsort(array, size, comp); + else{ + int * pivot = array + irand(seed, size); + int tmp; + int i = -1; + int j = size; + for(;;){ + do i++; while(comp(array + i, pivot)<0); + do j--; while(comp(pivot, array + j)<0); + if (i >= j) break; + tmp = array[i]; array[i] = array[j]; array[j] = tmp; + } + sortrnd(array , i , comp, seed); + sortrnd(&array[i], size-i, comp, seed); + } +} +void minisat_sort(int* array, int size, int(*comp)(const void *, const void *)) +{ + double seed = 91648253; + sortrnd(array,size,comp,&seed); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int * Gia_SortGetTest( int nSize ) +{ + int i, * pArray; + Aig_ManRandom( 1 ); + pArray = ABC_ALLOC( int, nSize ); + for ( i = 0; i < nSize; i++ ) + pArray[i] = (Aig_ManRandom( 0 ) >> 2); + return pArray; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_SortVerifySorted( int * pArray, int nSize ) +{ + int i; + for ( i = 1; i < nSize; i++ ) + assert( pArray[i-1] <= pArray[i] ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_SortTest() +{ + int nSize = 1000000; + int * pArray; + int clk = clock(); + pArray = Gia_SortGetTest( nSize ); +clk = clock(); + qsort( pArray, nSize, 4, (int (*)(const void *, const void *)) num_cmp ); +ABC_PRT( "qsort ", clock() - clk ); + Gia_SortVerifySorted( pArray, nSize ); + ABC_FREE( pArray ); + pArray = Gia_SortGetTest( nSize ); +clk = clock(); + minisat_sort( pArray, nSize, (int (*)(const void *, const void *)) num_cmp ); +ABC_PRT( "minisat", clock() - clk ); + Gia_SortVerifySorted( pArray, nSize ); + ABC_FREE( pArray ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaFrames.c b/src/aig/gia/giaFrames.c new file mode 100644 index 00000000..e99ef514 --- /dev/null +++ b/src/aig/gia/giaFrames.c @@ -0,0 +1,346 @@ +/**CFile**************************************************************** + + FileName [giaFrames.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Timeframe unrolling.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaFrames.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Gia_ManFra_t_ Gia_ManFra_t; +struct Gia_ManFra_t_ +{ + Gia_ParFra_t * pPars; // parameters + Gia_Man_t * pAig; // AIG to unroll + Vec_Ptr_t * vIns; // inputs of each timeframe + Vec_Ptr_t * vAnds; // nodes of each timeframe + Vec_Ptr_t * vOuts; // outputs of each timeframe +}; + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [This procedure sets default parameters.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFraSetDefaultParams( Gia_ParFra_t * p ) +{ + memset( p, 0, sizeof(Gia_ParFra_t) ); + p->nFrames = 32; // the number of frames to unroll + p->fInit = 0; // initialize the timeframes + p->fVerbose = 0; // enables verbose output +} + +/**Function************************************************************* + + Synopsis [Creates manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_ManFra_t * Gia_ManFraStart( Gia_Man_t * pAig, Gia_ParFra_t * pPars ) +{ + Gia_ManFra_t * p; + p = ABC_ALLOC( Gia_ManFra_t, 1 ); + memset( p, 0, sizeof(Gia_ManFra_t) ); + p->pAig = pAig; + p->pPars = pPars; + return p; +} + +/**Function************************************************************* + + Synopsis [Deletes manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFraStop( Gia_ManFra_t * p ) +{ + Vec_VecFree( (Vec_Vec_t *)p->vIns ); + Vec_VecFree( (Vec_Vec_t *)p->vAnds ); + Vec_VecFree( (Vec_Vec_t *)p->vOuts ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [Computes supports of all timeframes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFraSupports( Gia_ManFra_t * p ) +{ + Vec_Int_t * vIns = NULL, * vAnds, * vOuts; + Gia_Obj_t * pObj; + int f, i; + 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 ); + for ( f = p->pPars->nFrames - 1; f >= 0; f-- ) + { + vOuts = Gia_ManCollectPoIds( p->pAig ); + if ( vIns ) + Gia_ManForEachObjVec( vIns, p->pAig, pObj, i ) + if ( Gia_ObjIsRo(p->pAig, pObj) ) + Vec_IntPush( vOuts, Gia_ObjId( p->pAig, Gia_ObjRoToRi(p->pAig, pObj) ) ); + vIns = Vec_IntAlloc( 100 ); + Gia_ManCollectCis( p->pAig, Vec_IntArray(vOuts), Vec_IntSize(vOuts), vIns ); + vAnds = Vec_IntAlloc( 100 ); + Gia_ManCollectAnds( p->pAig, Vec_IntArray(vOuts), Vec_IntSize(vOuts), vAnds ); + Vec_PtrWriteEntry( p->vIns, f, vIns ); + Vec_PtrWriteEntry( p->vAnds, f, vAnds ); + Vec_PtrWriteEntry( p->vOuts, f, vOuts ); + } +} + +/**Function************************************************************* + + Synopsis [Moves the first nRegs entries to the end.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFraTransformCis( Gia_Man_t * pAig, Vec_Int_t * vCis ) +{ + int i, k = 0, Entry; + Vec_IntForEachEntryStop( vCis, Entry, i, Gia_ManRegNum(pAig) ) + assert( Entry == i+1 ); + Vec_IntForEachEntryStart( vCis, Entry, i, Gia_ManRegNum(pAig) ) + Vec_IntWriteEntry( vCis, k++, Entry ); + for ( i = 0; i < Gia_ManRegNum(pAig); i++ ) + Vec_IntWriteEntry( vCis, k++, i+1 ); + assert( k == Vec_IntSize(vCis) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManFramesInit( Gia_Man_t * pAig, Gia_ParFra_t * pPars ) +{ + int fUseAllPis = 1; + Gia_Man_t * pFrames, * pTemp; + Gia_ManFra_t * p; + Gia_Obj_t * pObj; + Vec_Int_t * vIns, * vAnds, * vOuts; + int i, f; + p = Gia_ManFraStart( pAig, pPars ); + Gia_ManFraSupports( p ); + pFrames = Gia_ManStart( Vec_VecSizeSize((Vec_Vec_t*)p->vIns)+ + Vec_VecSizeSize((Vec_Vec_t*)p->vAnds)+Vec_VecSizeSize((Vec_Vec_t*)p->vOuts) ); + pFrames->pName = Aig_UtilStrsav( pAig->pName ); + Gia_ManHashAlloc( pFrames ); + 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 ); + if ( pPars->fVerbose ) + printf( "Frame %3d : CI = %6d. AND = %6d. CO = %6d.\n", + f, Vec_IntSize(vIns), Vec_IntSize(vAnds), Vec_IntSize(vOuts) ); + if ( fUseAllPis ) + { + Gia_ManForEachPi( pAig, pObj, i ) + pObj->Value = Gia_ManAppendCi( pFrames ); + if ( f == 0 ) + { + Gia_ManForEachObjVec( vIns, pAig, pObj, i ) + { + assert( Gia_ObjIsCi(pObj) ); + if ( !Gia_ObjIsPi(pAig, pObj) ) + pObj->Value = 0; + } + } + else + { + Gia_ManForEachObjVec( vIns, pAig, pObj, i ) + { + assert( Gia_ObjIsCi(pObj) ); + if ( !Gia_ObjIsPi(pAig, pObj) ) + pObj->Value = Gia_ObjRoToRi(pAig, pObj)->Value; + } + } + } + else + { + if ( f == 0 ) + { + Gia_ManForEachObjVec( vIns, pAig, pObj, i ) + { + assert( Gia_ObjIsCi(pObj) ); + if ( Gia_ObjIsPi(pAig, pObj) ) + pObj->Value = Gia_ManAppendCi( pFrames ); + else + pObj->Value = 0; + } + } + else + { + Gia_ManForEachObjVec( vIns, pAig, pObj, i ) + { + assert( Gia_ObjIsCi(pObj) ); + if ( Gia_ObjIsPi(pAig, pObj) ) + pObj->Value = Gia_ManAppendCi( pFrames ); + else + pObj->Value = Gia_ObjRoToRi(pAig, pObj)->Value; + } + } + } + Gia_ManForEachObjVec( vAnds, pAig, pObj, i ) + { + assert( Gia_ObjIsAnd(pObj) ); + pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + } + Gia_ManForEachObjVec( vOuts, pAig, pObj, i ) + { + assert( Gia_ObjIsCo(pObj) ); + if ( Gia_ObjIsPo(pAig, pObj) ) + pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) ); + else + pObj->Value = Gia_ObjFanin0Copy(pObj); + } + } + Gia_ManFraStop( p ); + Gia_ManHashStop( pFrames ); + if ( Gia_ManCombMarkUsed(pFrames) < Gia_ManAndNum(pFrames) ) + { + pFrames = Gia_ManDupMarked( pTemp = pFrames ); + if ( pPars->fVerbose ) + printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n", + Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) ); + Gia_ManStop( pTemp ); + } + else if ( pPars->fVerbose ) + printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n", + Gia_ManAndNum(pFrames), Gia_ManAndNum(pFrames) ); + return pFrames; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManFrames( Gia_Man_t * pAig, Gia_ParFra_t * pPars ) +{ + Gia_Man_t * pFrames, * pTemp; + Gia_Obj_t * pObj; + int i, f; + assert( Gia_ManRegNum(pAig) > 0 ); + assert( pPars->nFrames > 0 ); + if ( pPars->fInit ) + return Gia_ManFramesInit( pAig, pPars ); + pFrames = Gia_ManStart( pPars->nFrames * Gia_ManObjNum(pAig) ); + pFrames->pName = Aig_UtilStrsav( pAig->pName ); + Gia_ManHashAlloc( pFrames ); + Gia_ManConst0(pAig)->Value = 0; + for ( f = 0; f < pPars->nFrames; f++ ) + { + if ( f == 0 ) + { + Gia_ManForEachRo( pAig, pObj, i ) + pObj->Value = Gia_ManAppendCi( pFrames ); + } + else + { + Gia_ManForEachRo( pAig, pObj, i ) + pObj->Value = Gia_ObjRoToRi( pAig, pObj )->Value; + } + Gia_ManForEachPi( pAig, pObj, i ) + pObj->Value = Gia_ManAppendCi( pFrames ); + Gia_ManForEachAnd( pAig, pObj, i ) + pObj->Value = Gia_ManHashAnd( pFrames, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + Gia_ManForEachPo( pAig, pObj, i ) + pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) ); + if ( f == pPars->nFrames - 1 ) + { + Gia_ManForEachRi( pAig, pObj, i ) + pObj->Value = Gia_ManAppendCo( pFrames, Gia_ObjFanin0Copy(pObj) ); + } + else + { + Gia_ManForEachRi( pAig, pObj, i ) + pObj->Value = Gia_ObjFanin0Copy(pObj); + } + } + Gia_ManHashStop( pFrames ); + Gia_ManFraTransformCis( pAig, pFrames->vCis ); + Gia_ManSetRegNum( pFrames, Gia_ManRegNum(pAig) ); + if ( Gia_ManCombMarkUsed(pFrames) < Gia_ManAndNum(pFrames) ) + { + pFrames = Gia_ManDupMarked( pTemp = pFrames ); + if ( pPars->fVerbose ) + printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n", + Gia_ManAndNum(pTemp), Gia_ManAndNum(pFrames) ); + Gia_ManStop( pTemp ); + } + else if ( pPars->fVerbose ) + printf( "Before cleanup = %d nodes. After cleanup = %d nodes.\n", + Gia_ManAndNum(pFrames), Gia_ManAndNum(pFrames) ); + return pFrames; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaFront.c b/src/aig/gia/giaFront.c new file mode 100644 index 00000000..ee9e5b5f --- /dev/null +++ b/src/aig/gia/giaFront.c @@ -0,0 +1,248 @@ +/**CFile**************************************************************** + + FileName [giaFront.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Frontier representation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaFront.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Find the next place on the frontier.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Gia_ManFrontFindNext( char * pFront, int nFront, int iFront ) +{ + assert( iFront < nFront ); + for ( ; pFront[iFront]; iFront = (iFront + 1) % nFront ); + assert( pFront[iFront] == 0 ); + pFront[iFront] = 1; + return iFront; +} + +/**Function************************************************************* + + Synopsis [Transforms the frontier manager to its initial state.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFrontTransform( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i, * pFrontToId; // mapping of nodes into frontier variables + assert( p->nFront > 0 ); + pFrontToId = ABC_ALLOC( int, p->nFront ); + Gia_ManForEachObj( p, pObj, i ) + { + if ( Gia_ObjIsCo(pObj) ) + { + assert( pObj->Value == GIA_NONE ); + pObj->iDiff0 = i - pFrontToId[Gia_ObjDiff0(pObj)]; + } + else if ( Gia_ObjIsAnd(pObj) ) + { + assert( (int)pObj->Value < p->nFront ); + pObj->iDiff0 = i - pFrontToId[Gia_ObjDiff0(pObj)]; + pObj->iDiff1 = i - pFrontToId[Gia_ObjDiff1(pObj)]; + pFrontToId[pObj->Value] = i; + } + else + { + assert( (int)pObj->Value < p->nFront ); + pFrontToId[pObj->Value] = i; + } + pObj->Value = 0; + } + ABC_FREE( pFrontToId ); +} + +/**Function************************************************************* + + Synopsis [Determine the frontier.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManFront( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj, * pFanin0New, * pFanin1New, * pObjNew; + char * pFront; // places used for the frontier + int i, iLit, nCrossCut = 0, nCrossCutMax = 0; + int nCrossCutMaxInit = Gia_ManCrossCut( p ); + int iFront = 0, clk = clock(); + // set references for all objects + Gia_ManSetRefs( p ); + // start the new manager + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + pNew->nFront = 1 + (int)((float)1.1 * nCrossCutMaxInit); + // start the frontier + pFront = ABC_CALLOC( char, pNew->nFront ); + // add constant node + Gia_ManConst0(pNew)->Value = iFront = Gia_ManFrontFindNext( pFront, pNew->nFront, iFront ); + if ( Gia_ObjValue(Gia_ManConst0(p)) == 0 ) + pFront[iFront] = 0; + else + nCrossCut = 1; + // iterate through the objects + Gia_ManForEachObj1( p, pObj, i ) + { + if ( Gia_ObjIsCi(pObj) ) + { + if ( Gia_ObjValue(pObj) && nCrossCutMax < ++nCrossCut ) + nCrossCutMax = nCrossCut; + // create new node + iLit = Gia_ManAppendCi( pNew ); + pObjNew = Gia_ManObj( pNew, Gia_Lit2Var(iLit) ); + assert( Gia_ObjId(pNew, pObjNew) == Gia_ObjId(p, pObj) ); + pObjNew->Value = iFront = Gia_ManFrontFindNext( pFront, pNew->nFront, iFront ); + // handle CIs without fanout + if ( Gia_ObjValue(pObj) == 0 ) + pFront[iFront] = 0; + continue; + } + if ( Gia_ObjIsCo(pObj) ) + { + assert( Gia_ObjValue(pObj) == 0 ); + // create new node + iLit = Gia_ManAppendCo( pNew, 0 ); + pObjNew = Gia_ManObj( pNew, Gia_Lit2Var(iLit) ); + assert( Gia_ObjId(pNew, pObjNew) == Gia_ObjId(p, pObj) ); + // get the fanin + pFanin0New = Gia_ManObj( pNew, Gia_ObjFaninId0(pObj, i) ); + assert( pFanin0New->Value != GIA_NONE ); + pObjNew->Value = GIA_NONE; + pObjNew->iDiff0 = pFanin0New->Value; + pObjNew->fCompl0 = Gia_ObjFaninC0(pObj); + // deref the fanin + if ( --Gia_ObjFanin0(pObj)->Value == 0 ) + { + pFront[pFanin0New->Value] = 0; + nCrossCut--; + } + continue; + } + if ( Gia_ObjValue(pObj) && nCrossCutMax < ++nCrossCut ) + nCrossCutMax = nCrossCut; + // create new node + pObjNew = Gia_ManAppendObj( pNew ); + assert( Gia_ObjId(pNew, pObjNew) == Gia_ObjId(p, pObj) ); + // assign the first fanin + pFanin0New = Gia_ManObj( pNew, Gia_ObjFaninId0(pObj, i) ); + assert( pFanin0New->Value != GIA_NONE ); + pObjNew->iDiff0 = pFanin0New->Value; + pObjNew->fCompl0 = Gia_ObjFaninC0(pObj); + // assign the second fanin + pFanin1New = Gia_ManObj( pNew, Gia_ObjFaninId1(pObj, i) ); + assert( pFanin1New->Value != GIA_NONE ); + pObjNew->iDiff1 = pFanin1New->Value; + pObjNew->fCompl1 = Gia_ObjFaninC1(pObj); + // assign the frontier number + pObjNew->Value = iFront = Gia_ManFrontFindNext( pFront, pNew->nFront, iFront ); + // deref the fanins + if ( --Gia_ObjFanin0(pObj)->Value == 0 ) + { + pFront[pFanin0New->Value] = 0; + nCrossCut--; + } + if ( --Gia_ObjFanin1(pObj)->Value == 0 ) + { + pFront[pFanin1New->Value] = 0; + nCrossCut--; + } + // handle nodes without fanout (choice nodes) + if ( Gia_ObjValue(pObj) == 0 ) + pFront[iFront] = 0; + } + assert( pNew->nObjs == p->nObjs ); + assert( nCrossCut == 0 && nCrossCutMax == nCrossCutMaxInit ); + for ( i = 0; i < pNew->nFront; i++ ) + assert( pFront[i] == 0 ); + ABC_FREE( pFront ); +//printf( "Crosscut = %6d. Frontier = %6d. ", nCrossCutMaxInit, pNew->nFront ); +//ABC_PRT( "Time", clock() - clk ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFrontTest( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + pNew = Gia_ManFront( p ); + Gia_ManFrontTransform( pNew ); +// Gia_ManCleanValue( p ); +// Gia_ManCleanValue( pNew ); + if ( memcmp( pNew->pObjs, p->pObjs, sizeof(Gia_Obj_t) * p->nObjs ) ) + { +/* + Gia_Obj_t * pObj, * pObjNew; + int i; + Gia_ManForEachObj( p, pObj, i ) + { + pObjNew = Gia_ManObj( pNew, i ); + printf( "%5d %5d %5d %5d\n", + pObj->iDiff0, pObjNew->iDiff0, + pObj->iDiff1, pObjNew->iDiff1 ); + } +*/ + printf( "Verification failed.\n" ); + } + else + printf( "Verification successful.\n" ); + Gia_ManStop( pNew ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaGlitch.c b/src/aig/gia/giaGlitch.c new file mode 100644 index 00000000..bbc509c4 --- /dev/null +++ b/src/aig/gia/giaGlitch.c @@ -0,0 +1,743 @@ +/**CFile**************************************************************** + + FileName [giaGlitch.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Glitch simulation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaGlitch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Gli_Obj_t_ Gli_Obj_t; +struct Gli_Obj_t_ +{ + unsigned fTerm : 1; // terminal node + unsigned fPhase : 1; // value under 000 pattern + unsigned fPhase2 : 1; // value under 000 pattern + unsigned fMark : 1; // user-controlled mark + unsigned nFanins : 3; // the number of fanins + unsigned nFanouts : 25; // total number of fanouts + unsigned Handle; // ID of the node + unsigned uTruth[2]; // truth table of the node + unsigned uSimInfo; // simulation info of the node + union + { + int iFanin; // the number of fanins added + int nSwitches; // the number of switches + }; + union + { + int iFanout; // the number of fanouts added + int nGlitches; // the number of glitches ( nGlitches >= nSwitches ) + }; + int Fanios[0]; // the array of fanins/fanouts +}; + +typedef struct Gli_Man_t_ Gli_Man_t; +struct Gli_Man_t_ +{ + Vec_Int_t * vCis; // the vector of CIs (PIs + LOs) + Vec_Int_t * vCos; // the vector of COs (POs + LIs) + Vec_Int_t * vCisChanged; // the changed CIs + Vec_Int_t * vAffected; // the affected nodes + Vec_Int_t * vFrontier; // the fanouts of these nodes + int nObjs; // the number of objects + int nRegs; // the number of registers + int nTravIds; // traversal ID of the network + int iObjData; // pointer to the current data + int nObjData; // the size of array to store the logic network + int * pObjData; // the internal nodes + unsigned * pSimInfoPrev; // previous values of the CIs +}; + + +static inline int Gli_ManCiNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCis); } +static inline int Gli_ManCoNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCos); } +static inline int Gli_ManPiNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCis) - p->nRegs; } +static inline int Gli_ManPoNum( Gli_Man_t * p ) { return Vec_IntSize(p->vCos) - p->nRegs; } +static inline int Gli_ManRegNum( Gli_Man_t * p ) { return p->nRegs; } +static inline int Gli_ManObjNum( Gli_Man_t * p ) { return p->nObjs; } +static inline int Gli_ManNodeNum( Gli_Man_t * p ) { return p->nObjs - Vec_IntSize(p->vCis) - Vec_IntSize(p->vCos); } + +static inline Gli_Obj_t * Gli_ManObj( Gli_Man_t * p, int v ) { return (Gli_Obj_t *)(p->pObjData + v); } +static inline Gli_Obj_t * Gli_ManCi( Gli_Man_t * p, int v ) { return Gli_ManObj( p, Vec_IntEntry(p->vCis,v) ); } +static inline Gli_Obj_t * Gli_ManCo( Gli_Man_t * p, int v ) { return Gli_ManObj( p, Vec_IntEntry(p->vCos,v) ); } +static inline Gli_Obj_t * Gli_ManPi( Gli_Man_t * p, int v ) { assert( v < Gli_ManPiNum(p) ); return Gli_ManCi( p, v ); } +static inline Gli_Obj_t * Gli_ManPo( Gli_Man_t * p, int v ) { assert( v < Gli_ManPoNum(p) ); return Gli_ManCo( p, v ); } +static inline Gli_Obj_t * Gli_ManRo( Gli_Man_t * p, int v ) { assert( v < Gli_ManRegNum(p) ); return Gli_ManCi( p, Gli_ManRegNum(p)+v ); } +static inline Gli_Obj_t * Gli_ManRi( Gli_Man_t * p, int v ) { assert( v < Gli_ManRegNum(p) ); return Gli_ManCo( p, Gli_ManRegNum(p)+v ); } + +static inline int Gli_ObjIsTerm( Gli_Obj_t * pObj ) { return pObj->fTerm; } +static inline int Gli_ObjIsCi( Gli_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 0; } +static inline int Gli_ObjIsCo( Gli_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 1; } +static inline int Gli_ObjIsNode( Gli_Obj_t * pObj ) { return!pObj->fTerm; } + +static inline int Gli_ObjFaninNum( Gli_Obj_t * pObj ) { return pObj->nFanins; } +static inline int Gli_ObjFanoutNum( Gli_Obj_t * pObj ) { return pObj->nFanouts; } +static inline int Gli_ObjSize( Gli_Obj_t * pObj ) { return sizeof(Gli_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; } + +static inline Gli_Obj_t * Gli_ObjFanin( Gli_Obj_t * pObj, int i ) { return (Gli_Obj_t *)(((int *)pObj) - pObj->Fanios[i]); } +static inline Gli_Obj_t * Gli_ObjFanout( Gli_Obj_t * pObj, int i ) { return (Gli_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i]); } + +#define Gli_ManForEachObj( p, pObj, i ) \ + for ( i = 0; (i < p->nObjData) && (pObj = Gli_ManObj(p,i)); i += Gli_ObjSize(pObj) ) +#define Gli_ManForEachNode( p, pObj, i ) \ + for ( i = 0; (i < p->nObjData) && (pObj = Gli_ManObj(p,i)); i += Gli_ObjSize(pObj) ) if ( Gli_ObjIsTerm(pObj) ) {} else + +#define Gli_ManForEachEntry( vVec, p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(vVec)) && (pObj = Gli_ManObj(p,Vec_IntEntry(vVec,i))); i++ ) +#define Gli_ManForEachCi( p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(p->vCis)) && (pObj = Gli_ManObj(p,Vec_IntEntry(p->vCis,i))); i++ ) +#define Gli_ManForEachCo( p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(p->vCos)) && (pObj = Gli_ManObj(p,Vec_IntEntry(p->vCos,i))); i++ ) + +#define Gli_ManForEachPi( p, pObj, i ) \ + for ( i = 0; (i < Gli_ManPiNum(p)) && ((pObj) = Gli_ManCi(p, i)); i++ ) +#define Gli_ManForEachPo( p, pObj, i ) \ + for ( i = 0; (i < Gli_ManPoNum(p)) && ((pObj) = Gli_ManCo(p, i)); i++ ) +#define Gli_ManForEachRo( p, pObj, i ) \ + for ( i = 0; (i < Gli_ManRegNum(p)) && ((pObj) = Gli_ManCi(p, Gli_ManPiNum(p)+i)); i++ ) +#define Gli_ManForEachRi( p, pObj, i ) \ + for ( i = 0; (i < Gli_ManRegNum(p)) && ((pObj) = Gli_ManCo(p, Gli_ManPoNum(p)+i)); i++ ) +#define Gli_ManForEachRiRo( p, pObjRi, pObjRo, i ) \ + for ( i = 0; (i < Gli_ManRegNum(p)) && ((pObjRi) = Gli_ManCo(p, Gli_ManPoNum(p)+i)) && ((pObjRo) = Gli_ManCi(p, Gli_ManPiNum(p)+i)); i++ ) + +#define Gli_ObjForEachFanin( pObj, pNext, i ) \ + for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Gli_ObjFanin(pObj,i)); i++ ) +#define Gli_ObjForEachFanout( pObj, pNext, i ) \ + for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Gli_ObjFanout(pObj,i)); i++ ) + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Creates logic network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gli_Man_t * Gli_ManAlloc( int nObjs, int nRegs, int nFanioPairs ) +{ + Gli_Man_t * p; + p = (Gli_Man_t *)ABC_CALLOC( int, (sizeof(Gli_Man_t) / 4) + (sizeof(Gli_Obj_t) / 4) * nObjs + 2 * nFanioPairs ); + p->nRegs = nRegs; + p->vCis = Vec_IntAlloc( 1000 ); + p->vCos = Vec_IntAlloc( 1000 ); + p->vCisChanged = Vec_IntAlloc( 1000 ); + p->vAffected = Vec_IntAlloc( 1000 ); + p->vFrontier = Vec_IntAlloc( 1000 ); + p->nObjData = (sizeof(Gli_Obj_t) / 4) * nObjs + 2 * nFanioPairs; + p->pObjData = (int *)(p + 1); + return p; +} + +/**Function************************************************************* + + Synopsis [Deletes logic network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManStop( Gli_Man_t * p ) +{ + Vec_IntFree( p->vCis ); + Vec_IntFree( p->vCos ); + Vec_IntFree( p->vCisChanged ); + Vec_IntFree( p->vAffected ); + Vec_IntFree( p->vFrontier ); + ABC_FREE( p->pSimInfoPrev ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [Checks logic network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManPrintObjects( Gli_Man_t * p ) +{ + Gli_Obj_t * pObj, * pNext; + int i, k; + Gli_ManForEachObj( p, pObj, i ) + { + printf( "Node %d \n", pObj->Handle ); + printf( "Fanins: " ); + Gli_ObjForEachFanin( pObj, pNext, k ) + printf( "%d ", pNext->Handle ); + printf( "\n" ); + printf( "Fanouts: " ); + Gli_ObjForEachFanout( pObj, pNext, k ) + printf( "%d ", pNext->Handle ); + printf( "\n" ); + } +} + +/**Function************************************************************* + + Synopsis [Checks logic network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManFinalize( Gli_Man_t * p ) +{ + Gli_Obj_t * pObj; + int i; + assert( p->iObjData == p->nObjData ); + Gli_ManForEachObj( p, pObj, i ) + { + assert( pObj->iFanin == (int)pObj->nFanins ); + assert( pObj->iFanout == (int)pObj->nFanouts ); + pObj->iFanin = 0; + pObj->iFanout = 0; + } +} + +/**Function************************************************************* + + Synopsis [Creates fanin/fanout pair.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ObjAddFanin( Gli_Obj_t * pObj, Gli_Obj_t * pFanin ) +{ + assert( pObj->iFanin < (int)pObj->nFanins ); + assert( pFanin->iFanout < (int)pFanin->nFanouts ); + pFanin->Fanios[pFanin->nFanins + pFanin->iFanout++] = + pObj->Fanios[pObj->iFanin++] = pObj->Handle - pFanin->Handle; +} + +/**Function************************************************************* + + Synopsis [Allocates object.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gli_Obj_t * Gli_ObjAlloc( Gli_Man_t * p, int nFanins, int nFanouts ) +{ + Gli_Obj_t * pObj; + pObj = Gli_ManObj( p, p->iObjData ); + pObj->Handle = p->iObjData; + pObj->nFanins = nFanins; + pObj->nFanouts = nFanouts; + p->iObjData += Gli_ObjSize( pObj ); + p->nObjs++; + return pObj; +} + +/**Function************************************************************* + + Synopsis [Creates CI.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gli_ManCreateCi( Gli_Man_t * p, int nFanouts ) +{ + Gli_Obj_t * pObj; + pObj = Gli_ObjAlloc( p, 0, nFanouts ); + pObj->fTerm = 1; + Vec_IntPush( p->vCis, pObj->Handle ); + return pObj->Handle; +} + +/**Function************************************************************* + + Synopsis [Creates CO.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gli_ManCreateCo( Gli_Man_t * p, int iFanin ) +{ + Gli_Obj_t * pObj, * pFanin; + pObj = Gli_ObjAlloc( p, 1, 0 ); + pObj->fTerm = 1; + pFanin = Gli_ManObj( p, iFanin ); + Gli_ObjAddFanin( pObj, pFanin ); + pObj->fPhase = pObj->fPhase2 = pFanin->fPhase; + Vec_IntPush( p->vCos, pObj->Handle ); + return pObj->Handle; +} + +/**Function************************************************************* + + Synopsis [Creates node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Gli_NodeComputeValue( Gli_Obj_t * pNode ) +{ + int i, Phase = 0; + for ( i = 0; i < (int)pNode->nFanins; i++ ) + Phase |= (Gli_ObjFanin(pNode, i)->fPhase << i); + return Aig_InfoHasBit( pNode->uTruth, Phase ); +} + +/**Function************************************************************* + + Synopsis [Creates node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Gli_NodeComputeValue2( Gli_Obj_t * pNode ) +{ + int i, Phase = 0; + for ( i = 0; i < (int)pNode->nFanins; i++ ) + Phase |= (Gli_ObjFanin(pNode, i)->fPhase2 << i); + return Aig_InfoHasBit( pNode->uTruth, Phase ); +} + +/**Function************************************************************* + + Synopsis [Creates node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gli_ManCreateNode( Gli_Man_t * p, Vec_Int_t * vFanins, int nFanouts, unsigned * puTruth ) +{ + Gli_Obj_t * pObj, * pFanin; + int i; + assert( Vec_IntSize(vFanins) <= 6 ); + pObj = Gli_ObjAlloc( p, Vec_IntSize(vFanins), nFanouts ); + Gli_ManForEachEntry( vFanins, p, pFanin, i ) + Gli_ObjAddFanin( pObj, pFanin ); + pObj->uTruth[0] = puTruth[0]; + pObj->uTruth[1] = puTruth[Vec_IntSize(vFanins) == 6]; + pObj->fPhase = pObj->fPhase2 = Gli_NodeComputeValue( pObj ); + return pObj->Handle; +} + +/**Function************************************************************* + + Synopsis [Returns the number of switches of the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gli_ObjNumSwitches( Gli_Man_t * p, int iNode ) +{ + return Gli_ManObj( p, iNode )->nSwitches; +} + +/**Function************************************************************* + + Synopsis [Returns the number of glitches of the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gli_ObjNumGlitches( Gli_Man_t * p, int iNode ) +{ + return Gli_ManObj( p, iNode )->nGlitches; +} + + +/**Function************************************************************* + + Synopsis [Sets random info at the PIs and collects changed PIs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManSetPiRandom( Gli_Man_t * p, float PiTransProb ) +{ + Gli_Obj_t * pObj; + float Multi = 1.0 / (1 << 16); + int i; + assert( 0.0 < PiTransProb && PiTransProb < 1.0 ); + Vec_IntClear( p->vCisChanged ); + Gli_ManForEachCi( p, pObj, i ) + if ( Multi * (Aig_ManRandom(0) & 0xffff) < PiTransProb ) + { + Vec_IntPush( p->vCisChanged, pObj->Handle ); + pObj->fPhase ^= 1; + pObj->fPhase2 ^= 1; + pObj->nSwitches++; + pObj->nGlitches++; + } +} + +/**Function************************************************************* + + Synopsis [Sets random info at the PIs and collects changed PIs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManSetPiFromSaved( Gli_Man_t * p, int iBit ) +{ + Gli_Obj_t * pObj; + int i; + Vec_IntClear( p->vCisChanged ); + Gli_ManForEachCi( p, pObj, i ) + if ( (p->pSimInfoPrev[i] ^ pObj->uSimInfo) & (1 << iBit) ) + { + Vec_IntPush( p->vCisChanged, pObj->Handle ); + pObj->fPhase ^= 1; + pObj->fPhase2 ^= 1; + pObj->nSwitches++; + pObj->nGlitches++; + } +} + +/**Function************************************************************* + + Synopsis [Computes switching activity of each node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManSwitching( Gli_Man_t * p ) +{ + Gli_Obj_t * pThis; + int i; + Gli_ManForEachNode( p, pThis, i ) + { + if ( ((int)pThis->fPhase) == Gli_NodeComputeValue(pThis) ) + continue; + pThis->fPhase ^= 1; + pThis->nSwitches++; + } +} + +/**Function************************************************************* + + Synopsis [Computes glitching activity of each node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManGlitching( Gli_Man_t * p ) +{ + Gli_Obj_t * pThis, * pFanout, * pOther = Gli_ManObj(p, 41); + int i, k, Handle; +// Gli_ManForEachObj( p, pThis, i ) +// assert( pThis->fMark == 0 ); + // start the array of affected nodes + Vec_IntClear( p->vAffected ); + Vec_IntForEachEntry( p->vCisChanged, Handle, i ) + Vec_IntPush( p->vAffected, Handle ); + // iteration propagation + while ( Vec_IntSize(p->vAffected) > 0 ) + { + // compute the frontier + Vec_IntClear( p->vFrontier ); + Gli_ManForEachEntry( p->vAffected, p, pThis, i ) + { + Gli_ObjForEachFanout( pThis, pFanout, k ) + { + if ( Gli_ObjIsCo(pFanout) ) + continue; + if ( pFanout->fMark ) + continue; + pFanout->fMark = 1; + Vec_IntPush( p->vFrontier, pFanout->Handle ); + } + } + // compute the next set of affected nodes + Vec_IntClear( p->vAffected ); + Gli_ManForEachEntry( p->vFrontier, p, pThis, i ) + { + pThis->fMark = 0; + if ( ((int)pThis->fPhase2) == Gli_NodeComputeValue2(pThis) ) + continue; + pThis->fPhase2 ^= 1; + pThis->nGlitches++; + Vec_IntPush( p->vAffected, pThis->Handle ); + } + } +} + +/**Function************************************************************* + + Synopsis [Checks that the resulting values are the same.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManVerify( Gli_Man_t * p ) +{ + Gli_Obj_t * pObj; + int i; + Gli_ManForEachObj( p, pObj, i ) + { + assert( pObj->fPhase == pObj->fPhase2 ); + assert( pObj->nGlitches >= pObj->nSwitches ); + } +} + +/**Function************************************************************* + + Synopsis [Simulates one node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned Gli_ManSimulateSeqNode( Gli_Man_t * p, Gli_Obj_t * pNode ) +{ + unsigned pSimInfos[6], Result = 0; + int nFanins = Gli_ObjFaninNum(pNode); + int i, k, Phase; + Gli_Obj_t * pFanin; + assert( nFanins <= 6 ); + Gli_ObjForEachFanin( pNode, pFanin, i ) + pSimInfos[i] = pFanin->uSimInfo; + for ( i = 0; i < 32; i++ ) + { + Phase = 0; + for ( k = 0; k < nFanins; k++ ) + if ( (pSimInfos[k] >> i) & 1 ) + Phase |= (1 << k); + if ( Aig_InfoHasBit( pNode->uTruth, Phase ) ) + Result |= (1 << i); + } + return Result; +} + +/**Function************************************************************* + + Synopsis [Simulates one node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline unsigned Gli_ManUpdateRandomInput( unsigned uInfo, float PiTransProb ) +{ + float Multi = 1.0 / (1 << 16); + int i; + if ( PiTransProb == 0.5 ) + return Aig_ManRandom(0); + for ( i = 0; i < 32; i++ ) + if ( Multi * (Aig_ManRandom(0) & 0xffff) < PiTransProb ) + uInfo ^= 1; + return uInfo; +} + +/**Function************************************************************* + + Synopsis [Simulates sequential network randomly for the given number of frames.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gli_ManSimulateSeqOne( Gli_Man_t * p, float PiTransProb ) +{ + Gli_Obj_t * pObj, * pObjRi, * pObjRo; + int i; + Gli_ManForEachPi( p, pObj, i ) + pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, PiTransProb ); + Gli_ManForEachNode( p, pObj, i ) + pObj->uSimInfo = Gli_ManSimulateSeqNode( p, pObj ); + Gli_ManForEachRi( p, pObj, i ) + pObj->uSimInfo = Gli_ObjFanin(pObj, 0)->uSimInfo; + Gli_ManForEachRiRo( p, pObjRi, pObjRo, i ) + pObjRo->uSimInfo = pObjRi->uSimInfo; +} + +/**Function************************************************************* + + Synopsis [Simulates sequential network randomly for the given number of frames.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gli_ManSaveCiInfo( Gli_Man_t * p ) +{ + Gli_Obj_t * pObj; + int i; + if ( p->pSimInfoPrev == NULL ) + p->pSimInfoPrev = ABC_ALLOC( unsigned, Gli_ManCiNum(p) ); + Gli_ManForEachCi( p, pObj, i ) + p->pSimInfoPrev[i] = pObj->uSimInfo; +} + +/**Function************************************************************* + + Synopsis [Simulates sequential network randomly for the given number of frames.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManSimulateSeqPref( Gli_Man_t * p, int nPref ) +{ + Gli_Obj_t * pObj; + int i, f; + Gli_ManForEachRo( p, pObj, i ) + pObj->uSimInfo = 0; + for ( f = 0; f < nPref; f++ ) + Gli_ManSimulateSeqOne( p, 0.5 ); +} + +/**Function************************************************************* + + Synopsis [Computes glitching activity of each node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb, int fVerbose ) +{ + int i, k, clk = clock(); + Aig_ManRandom( 1 ); + Gli_ManFinalize( p ); + if ( p->nRegs == 0 ) + { + for ( i = 0; i < nPatterns; i++ ) + { + Gli_ManSetPiRandom( p, PiTransProb ); + Gli_ManSwitching( p ); + Gli_ManGlitching( p ); +// Gli_ManVerify( p ); + } + } + else + { + Gli_ManSimulateSeqPref( p, 16 ); + for ( k = Aig_BitWordNum(nPatterns) - 1; k >= 0; k-- ) + { + Gli_ManSaveCiInfo( p ); + Gli_ManSimulateSeqOne( p, PiTransProb ); + for ( i = 0; i < 32; i++ ) + { + Gli_ManSetPiFromSaved( p, i ); + Gli_ManSwitching( p ); + Gli_ManGlitching( p ); +// Gli_ManVerify( p ); + } + } + } + if ( fVerbose ) + { + printf( "\nSimulated %d patterns. ", nPatterns ); + ABC_PRM( "Memory", 4*p->nObjData ); + ABC_PRT( "Time", clock() - clk ); + } +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaHash.c b/src/aig/gia/giaHash.c new file mode 100644 index 00000000..c2bde6ba --- /dev/null +++ b/src/aig/gia/giaHash.c @@ -0,0 +1,541 @@ +/**CFile**************************************************************** + + FileName [giaHash.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Structural hashing.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaHash.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Hashing the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Gia_ManHashOne( int iLit0, int iLit1, int TableSize ) +{ + unsigned Key = 0; + assert( iLit0 < iLit1 ); + Key ^= Gia_Lit2Var(iLit0) * 7937; + Key ^= Gia_Lit2Var(iLit1) * 2971; + Key ^= Gia_LitIsCompl(iLit0) * 911; + Key ^= Gia_LitIsCompl(iLit1) * 353; + return (int)(Key % TableSize); +} + +/**Function************************************************************* + + Synopsis [Returns the place where this node is stored (or should be stored).] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +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 ) + if ( Gia_ObjFaninLit0p(p, pThis) == iLit0 && Gia_ObjFaninLit1p(p, pThis) == iLit1 ) + break; + return pPlace; +} + +/**Function************************************************************* + + Synopsis [Starts the hash table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManHashAlloc( Gia_Man_t * p ) +{ + assert( p->pHTable == NULL ); + p->nHTable = Aig_PrimeCudd( p->nObjsAlloc / 3 ); + p->pHTable = ABC_CALLOC( int, p->nHTable ); +} + +/**Function************************************************************* + + Synopsis [Starts the hash table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManHashStart( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int * pPlace, i; + Gia_ManHashAlloc( p ); + Gia_ManCleanValue( p ); + Gia_ManForEachAnd( p, pObj, i ) + { + pPlace = Gia_ManHashFind( p, Gia_ObjFaninLit0(pObj, i), Gia_ObjFaninLit1(pObj, i) ); + assert( *pPlace == 0 ); + *pPlace = Gia_Var2Lit( i, 0 ); + } +} + +/**Function************************************************************* + + Synopsis [Stops the hash table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManHashStop( Gia_Man_t * p ) +{ + ABC_FREE( p->pHTable ); + p->nHTable = 0; +} + +/**Function************************************************************* + + Synopsis [Resizes the hash table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManHashResize( Gia_Man_t * p ) +{ + Gia_Obj_t * pThis; + int * pHTableOld, * pPlace; + int nHTableOld, iNext, Counter, Counter2, i; + assert( p->pHTable != NULL ); + // replace the table + pHTableOld = p->pHTable; + nHTableOld = p->nHTable; + p->nHTable = Aig_PrimeCudd( 2 * Gia_ManAndNum(p) ); + p->pHTable = ABC_CALLOC( int, p->nHTable ); + // rehash the entries from the old table + Counter = 0; + for ( i = 0; i < nHTableOld; i++ ) + for ( pThis = (pHTableOld[i]? Gia_ManObj(p, Gia_Lit2Var(pHTableOld[i])) : NULL), + iNext = (pThis? pThis->Value : 0); + pThis; pThis = (iNext? Gia_ManObj(p, Gia_Lit2Var(iNext)) : NULL), + iNext = (pThis? pThis->Value : 0) ) + { + pThis->Value = 0; + pPlace = Gia_ManHashFind( p, Gia_ObjFaninLit0p(p, pThis), Gia_ObjFaninLit1p(p, pThis) ); + assert( *pPlace == 0 ); // should not be there + *pPlace = Gia_Var2Lit( Gia_ObjId(p, pThis), 0 ); + assert( *pPlace != 0 ); + Counter++; + } + Counter2 = Gia_ManAndNum(p); + assert( Counter == Counter2 ); + ABC_FREE( pHTableOld ); +} + + +/**Function************************************************************* + + Synopsis [Recognizes what nodes are control and data inputs of a MUX.] + + Description [If the node is a MUX, returns the control variable C. + Assigns nodes T and E to be the then and else variables of the MUX. + Node C is never complemented. Nodes T and E can be complemented. + This function also recognizes EXOR/NEXOR gates as MUXes.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline Gia_Obj_t * Gia_ObjRecognizeMuxTwo( Gia_Obj_t * pNode0, Gia_Obj_t * pNode1, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE ) +{ + assert( !Gia_IsComplement(pNode0) ); + assert( !Gia_IsComplement(pNode1) ); + // find the control variable + if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p2) ) + if ( Gia_ObjFaninC1(pNode0) ) + { // pNode2->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + return Gia_ObjChild1(pNode1);//pNode2->p2; + } + else + { // pNode1->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + return Gia_ObjChild1(pNode0);//pNode1->p2; + } + } + else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p1) ) + if ( Gia_ObjFaninC0(pNode0) ) + { // pNode2->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + return Gia_ObjChild0(pNode1);//pNode2->p1; + } + else + { // pNode1->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + return Gia_ObjChild0(pNode0);//pNode1->p1; + } + } + else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p1) ) + if ( Gia_ObjFaninC0(pNode0) ) + { // pNode2->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + return Gia_ObjChild1(pNode1);//pNode2->p2; + } + else + { // pNode1->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + return Gia_ObjChild0(pNode0);//pNode1->p1; + } + } + else if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p2) ) + if ( Gia_ObjFaninC1(pNode0) ) + { // pNode2->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + return Gia_ObjChild0(pNode1);//pNode2->p1; + } + else + { // pNode1->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + return Gia_ObjChild1(pNode0);//pNode1->p2; + } + } + assert( 0 ); // this is not MUX + return NULL; +} + + +/**Function************************************************************* + + Synopsis [Rehashes AIG with mapping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline Gia_Obj_t * Gia_ManHashAndP( Gia_Man_t * p, Gia_Obj_t * p0, Gia_Obj_t * p1 ) +{ + return Gia_ObjFromLit( p, Gia_ManHashAnd( p, Gia_ObjToLit(p, p0), Gia_ObjToLit(p, p1) ) ); +} + +/**Function************************************************************* + + Synopsis [Rehashes AIG with mapping.] + + Description [http://fmv.jku.at/papers/BrummayerBiere-MEMICS06.pdf] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline Gia_Obj_t * Gia_ManAddStrash( Gia_Man_t * p, Gia_Obj_t * p0, Gia_Obj_t * p1 ) +{ + Gia_Obj_t * pNode0, * pNode1, * pFanA, * pFanB, * pFanC, * pFanD; + assert( p->fAddStrash ); + if ( !Gia_ObjIsAnd(Gia_Regular(p0)) && !Gia_ObjIsAnd(Gia_Regular(p1)) ) + return NULL; + pNode0 = Gia_Regular(p0); + pNode1 = Gia_Regular(p1); + pFanA = Gia_ObjChild0(pNode0); + pFanB = Gia_ObjChild1(pNode0); + pFanC = Gia_ObjChild0(pNode1); + pFanD = Gia_ObjChild1(pNode1); + if ( Gia_IsComplement(p0) ) + { + if ( pFanA == Gia_Not(p1) || pFanB == Gia_Not(p1) ) + return p1; + if ( pFanB == p1 ) + return Gia_ManHashAndP( p, Gia_Not(pFanA), pFanB ); + if ( pFanA == p1 ) + return Gia_ManHashAndP( p, Gia_Not(pFanB), pFanA ); + } + else + { + if ( pFanA == Gia_Not(p1) || pFanB == Gia_Not(p1) ) + return Gia_ManConst0(p); + if ( pFanA == p1 || pFanB == p1 ) + return p0; + } + if ( Gia_IsComplement(p1) ) + { + if ( pFanC == Gia_Not(p0) || pFanD == Gia_Not(p0) ) + return p0; + if ( pFanD == p0 ) + return Gia_ManHashAndP( p, Gia_Not(pFanC), pFanD ); + if ( pFanC == p0 ) + return Gia_ManHashAndP( p, Gia_Not(pFanD), pFanC ); + } + else + { + if ( pFanC == Gia_Not(p0) || pFanD == Gia_Not(p0) ) + return Gia_ManConst0(p); + if ( pFanC == p0 || pFanD == p0 ) + return p1; + } + if ( !Gia_IsComplement(p0) && !Gia_IsComplement(p1) ) + { + if ( pFanA == Gia_Not(pFanC) || pFanA == Gia_Not(pFanD) || pFanB == Gia_Not(pFanC) || pFanB == Gia_Not(pFanD) ) + return Gia_ManConst0(p); + if ( pFanA == pFanC || pFanB == pFanC ) + return Gia_ManHashAndP( p, p0, pFanD ); + if ( pFanB == pFanC || pFanB == pFanD ) + return Gia_ManHashAndP( p, pFanA, p1 ); + if ( pFanA == pFanD || pFanB == pFanD ) + return Gia_ManHashAndP( p, p0, pFanC ); + if ( pFanA == pFanC || pFanA == pFanD ) + return Gia_ManHashAndP( p, pFanB, p1 ); + } + else if ( Gia_IsComplement(p0) && !Gia_IsComplement(p1) ) + { + if ( pFanA == Gia_Not(pFanC) || pFanA == Gia_Not(pFanD) || pFanB == Gia_Not(pFanC) || pFanB == Gia_Not(pFanD) ) + return p1; + if ( pFanB == pFanC || pFanB == pFanD ) + return Gia_ManHashAndP( p, Gia_Not(pFanA), p1 ); + if ( pFanA == pFanC || pFanA == pFanD ) + return Gia_ManHashAndP( p, Gia_Not(pFanB), p1 ); + } + else if ( !Gia_IsComplement(p0) && Gia_IsComplement(p1) ) + { + if ( pFanC == Gia_Not(pFanA) || pFanC == Gia_Not(pFanB) || pFanD == Gia_Not(pFanA) || pFanD == Gia_Not(pFanB) ) + return p0; + if ( pFanD == pFanA || pFanD == pFanB ) + return Gia_ManHashAndP( p, Gia_Not(pFanC), p0 ); + if ( pFanC == pFanA || pFanC == pFanB ) + return Gia_ManHashAndP( p, Gia_Not(pFanD), p0 ); + } + else // if ( Gia_IsComplement(p0) && Gia_IsComplement(p1) ) + { + if ( pFanA == pFanD && pFanB == Gia_Not(pFanC) ) + return Gia_Not(pFanA); + if ( pFanB == pFanC && pFanA == Gia_Not(pFanD) ) + return Gia_Not(pFanB); + if ( pFanA == pFanC && pFanB == Gia_Not(pFanD) ) + return Gia_Not(pFanA); + if ( pFanB == pFanD && pFanA == Gia_Not(pFanC) ) + return Gia_Not(pFanB); + } + if ( !Gia_IsComplement(p0) || !Gia_IsComplement(p1) ) + return NULL; + if ( !Gia_ObjIsAnd(pNode0) || !Gia_ObjIsAnd(pNode1) ) + return NULL; + if ( (Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1))) || + (Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1))) || + (Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1))) || + (Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1))) ) + { + Gia_Obj_t * pNodeC, * pNodeT, * pNodeE; + int fCompl; + pNodeC = Gia_ObjRecognizeMuxTwo( pNode0, pNode1, &pNodeT, &pNodeE ); + // using non-standard canonical rule for MUX (d0 is not compl; d1 may be compl) + if ( (fCompl = Gia_IsComplement(pNodeE)) ) + { + pNodeE = Gia_Not(pNodeE); + pNodeT = Gia_Not(pNodeT); + } + pNode0 = Gia_ManHashAndP( p, Gia_Not(pNodeC), pNodeE ); + pNode1 = Gia_ManHashAndP( p, pNodeC, pNodeT ); + return Gia_NotCond( Gia_ManHashAndP( p, pNode0, pNode1 ), !fCompl ); + } + return NULL; +} + +/**Function************************************************************* + + Synopsis [Rehashes AIG with mapping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 ) +{ + if ( iLit0 < 2 ) + return iLit0 ? iLit1 : 0; + if ( iLit1 < 2 ) + return iLit1 ? iLit0 : 0; + if ( iLit0 == iLit1 ) + return iLit1; + if ( iLit0 == Gia_LitNot(iLit1) ) + return 0; + if ( (p->nObjs & 0xFF) == 0 && 2 * p->nHTable < Gia_ManAndNum(p) ) + Gia_ManHashResize( p ); + if ( p->fAddStrash ) + { + Gia_Obj_t * pObj = Gia_ManAddStrash( p, Gia_ObjFromLit(p, iLit0), Gia_ObjFromLit(p, iLit1) ); + if ( pObj != NULL ) + return Gia_ObjToLit( p, pObj ); + } + if ( iLit0 > iLit1 ) + iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1; + { + int * pPlace = Gia_ManHashFind( p, iLit0, iLit1 ); + if ( *pPlace ) + return *pPlace; + if ( p->nObjs < p->nObjsAlloc ) + return *pPlace = Gia_ManAppendAnd( p, iLit0, iLit1 ); + else + { + int iNode = Gia_ManAppendAnd( p, iLit0, iLit1 ); + pPlace = Gia_ManHashFind( p, iLit0, iLit1 ); + assert( *pPlace == 0 ); + return *pPlace = iNode; + } + } +} + +/**Function************************************************************* + + Synopsis [Rehashes AIG with mapping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 ) +{ + if ( iLit0 < 2 ) + return iLit0 ? iLit1 : 0; + if ( iLit1 < 2 ) + return iLit1 ? iLit0 : 0; + if ( iLit0 == iLit1 ) + return iLit1; + if ( iLit0 == Gia_LitNot(iLit1) ) + return 0; + if ( iLit0 > iLit1 ) + iLit0 ^= iLit1, iLit1 ^= iLit0, iLit0 ^= iLit1; + { + int * pPlace = Gia_ManHashFind( p, iLit0, iLit1 ); + if ( *pPlace ) + return *pPlace; + return -1; + } +} + +/**Function************************************************************* + + Synopsis [Rehashes AIG with mapping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 ) +{ + int fCompl = Gia_LitIsCompl(iLit0) ^ Gia_LitIsCompl(iLit1); + int iTemp0 = Gia_ManHashAnd( p, Gia_LitRegular(iLit0), Gia_LitNot(Gia_LitRegular(iLit1)) ); + int iTemp1 = Gia_ManHashAnd( p, Gia_LitRegular(iLit1), Gia_LitNot(Gia_LitRegular(iLit0)) ); + return Gia_LitNotCond( Gia_ManHashAnd( p, Gia_LitNot(iTemp0), Gia_LitNot(iTemp1) ), !fCompl ); +} + +/**Function************************************************************* + + Synopsis [Rehashes AIG with mapping.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManRehash( Gia_Man_t * p ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObj; + int i; + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Aig_UtilStrsav( p->pName ); + Gia_ManHashAlloc( pNew ); + Gia_ManConst0(p)->Value = 0; + Gia_ManForEachObj( p, pObj, i ) + { + if ( Gia_ObjIsAnd(pObj) ) + pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + else if ( Gia_ObjIsCi(pObj) ) + pObj->Value = Gia_ManAppendCi( pNew ); + else if ( Gia_ObjIsCo(pObj) ) + pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + } + Gia_ManHashStop( pNew ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); +// printf( "Top gate is %s\n", Gia_ObjFaninC0(Gia_ManCo(pNew, 0))? "OR" : "AND" ); + return pNew; +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaLogic.c b/src/aig/gia/giaLogic.c new file mode 100644 index 00000000..825cec02 --- /dev/null +++ b/src/aig/gia/giaLogic.c @@ -0,0 +1,725 @@ +/**CFile**************************************************************** + + FileName [giaLogic.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Logic network derived from AIG.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaLogic.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Log_Obj_t_ Log_Obj_t; +struct Log_Obj_t_ +{ + unsigned fTerm : 1; // terminal node (CI/CO) + unsigned fMark0 : 1; // first user-controlled mark + unsigned fMark1 : 1; // second user-controlled mark + unsigned nFanins : 28; // the number of fanins + unsigned nFanouts; // the number of fanouts + unsigned hHandle; // the handle of the node + union { + unsigned TravId; // user-specified value + unsigned iFanin; + }; + union { + unsigned Value; // user-specified value + unsigned iFanout; + }; + int Fanios[0]; // the array of fanins/fanouts +}; + +typedef struct Log_Man_t_ Log_Man_t; +struct Log_Man_t_ +{ + Gia_Man_t * pGia; // the original AIG manager + Vec_Int_t * vCis; // the vector of CIs (PIs + LOs) + Vec_Int_t * vCos; // the vector of COs (POs + LIs) + int nObjs; // the number of objects + int nNodes; // the number of nodes + int nTravIds; // traversal ID of the network + int * pObjData; // the array containing data for objects + int nObjData; // the size of array to store the logic network +}; + +static inline int Log_ManCiNum( Log_Man_t * p ) { return Vec_IntSize(p->vCis); } +static inline int Log_ManCoNum( Log_Man_t * p ) { return Vec_IntSize(p->vCos); } +static inline int Log_ManObjNum( Log_Man_t * p ) { return p->nObjs; } +static inline int Log_ManNodeNum( Log_Man_t * p ) { return p->nNodes; } + +static inline Log_Obj_t * Log_ManObj( Log_Man_t * p, unsigned hHandle ) { return (Log_Obj_t *)(p->pObjData + hHandle); } +static inline Log_Obj_t * Log_ManCi( Log_Man_t * p, int i ) { return Log_ManObj( p, Vec_IntEntry(p->vCis,i) ); } +static inline Log_Obj_t * Log_ManCo( Log_Man_t * p, int i ) { return Log_ManObj( p, Vec_IntEntry(p->vCos,i) ); } + +static inline int Log_ObjIsTerm( Log_Obj_t * pObj ) { return pObj->fTerm; } +static inline int Log_ObjIsCi( Log_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 0; } +static inline int Log_ObjIsCo( Log_Obj_t * pObj ) { return pObj->fTerm && pObj->nFanins == 1; } +static inline int Log_ObjIsNode( Log_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins > 0; } +static inline int Log_ObjIsConst0( Log_Obj_t * pObj ) { return!pObj->fTerm && pObj->nFanins == 0; } + +static inline int Log_ObjFaninNum( Log_Obj_t * pObj ) { return pObj->nFanins; } +static inline int Log_ObjFanoutNum( Log_Obj_t * pObj ) { return pObj->nFanouts; } +static inline int Log_ObjSize( Log_Obj_t * pObj ) { return sizeof(Log_Obj_t) / 4 + pObj->nFanins + pObj->nFanouts; } +static inline Log_Obj_t * Log_ObjFanin( Log_Obj_t * pObj, int i ) { return (Log_Obj_t *)(((int *)pObj) - pObj->Fanios[i]); } +static inline Log_Obj_t * Log_ObjFanout( Log_Obj_t * pObj, int i ) { return (Log_Obj_t *)(((int *)pObj) + pObj->Fanios[pObj->nFanins+i]); } + +static inline void Log_ManResetTravId( Log_Man_t * p ) { extern void Log_ManCleanTravId( Log_Man_t * p ); Log_ManCleanTravId( p ); p->nTravIds = 1; } +static inline void Log_ManIncrementTravId( Log_Man_t * p ) { p->nTravIds++; } +static inline void Log_ObjSetTravId( Log_Obj_t * pObj, int TravId ) { pObj->TravId = TravId; } +static inline void Log_ObjSetTravIdCurrent( Log_Man_t * p, Log_Obj_t * pObj ) { pObj->TravId = p->nTravIds; } +static inline void Log_ObjSetTravIdPrevious( Log_Man_t * p, Log_Obj_t * pObj ) { pObj->TravId = p->nTravIds - 1; } +static inline int Log_ObjIsTravIdCurrent( Log_Man_t * p, Log_Obj_t * pObj ) { return ((int)pObj->TravId == p->nTravIds); } +static inline int Log_ObjIsTravIdPrevious( Log_Man_t * p, Log_Obj_t * pObj ) { return ((int)pObj->TravId == p->nTravIds - 1); } + +#define Log_ManForEachObj( p, pObj, i ) \ + for ( i = 0; (i < p->nObjData) && (pObj = Log_ManObj(p,i)); i += Log_ObjSize(pObj) ) +#define Log_ManForEachNode( p, pObj, i ) \ + for ( i = 0; (i < p->nObjData) && (pObj = Log_ManObj(p,i)); i += Log_ObjSize(pObj) ) if ( Log_ObjIsTerm(pObj) ) {} else +#define Log_ManForEachObjVec( vVec, p, pObj, i ) \ + for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Log_ManObj(p, Vec_IntEntry(vVec,i))); i++ ) +#define Log_ObjForEachFanin( pObj, pNext, i ) \ + for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Log_ObjFanin(pObj,i)); i++ ) +#define Log_ObjForEachFanout( pObj, pNext, i ) \ + for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Log_ObjFanout(pObj,i)); i++ ) + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Collect the fanin IDs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManCollectSuper( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSuper ) +{ + if ( pObj->fMark0 ) + { + Vec_IntPushUnique( vSuper, Gia_ObjId(p, pObj) ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + Log_ManCollectSuper( p, Gia_ObjFanin0(pObj), vSuper ); + Log_ManCollectSuper( p, Gia_ObjFanin1(pObj), vSuper ); +} + +/**Function************************************************************* + + Synopsis [Assigns references while removing the MUX/XOR ones.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManCreateRefsSpecial( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj, * pFan0, * pFan1; + Gia_Obj_t * pObjC, * pObjD0, * pObjD1; + int i; + assert( p->pRefs == NULL ); + Gia_ManCleanMark0( p ); + Gia_ManCreateRefs( p ); + Gia_ManForEachAnd( p, pObj, i ) + { + assert( pObj->fMark0 == 0 ); + pFan0 = Gia_ObjFanin0(pObj); + pFan1 = Gia_ObjFanin1(pObj); + // skip nodes whose fanins are PIs or are already marked + if ( Gia_ObjIsCi(pFan0) || pFan0->fMark0 || + Gia_ObjIsCi(pFan1) || pFan1->fMark0 ) + continue; + // skip nodes that are not MUX type + if ( !Gia_ObjIsMuxType(pObj) ) + continue; + // the node is MUX type, mark it and its fanins + pObj->fMark0 = 1; + pFan0->fMark0 = 1; + pFan1->fMark0 = 1; + // deref the control + pObjC = Gia_ObjRecognizeMux( pObj, &pObjD1, &pObjD0 ); + Gia_ObjRefDec( p, Gia_Regular(pObjC) ); + if ( Gia_Regular(pObjD0) == Gia_Regular(pObjD1) ) + Gia_ObjRefDec( p, Gia_Regular(pObjD0) ); + } + Gia_ManForEachAnd( p, pObj, i ) + assert( Gia_ObjRefs(p, pObj) > 0 ); + Gia_ManCleanMark0( p ); +} + +/**Function************************************************************* + + Synopsis [Assigns references while removing the MUX/XOR ones.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManTransformRefs( Gia_Man_t * p, int * pnObjs, int * pnFanios ) +{ + Vec_Int_t * vSuper; + Gia_Obj_t * pObj, * pFanin; + int i, k, Counter; + assert( p->pRefs != NULL ); + + // mark nodes to be used in the logic network + Gia_ManCleanMark0( p ); + Gia_ManConst0(p)->fMark0 = 1; + // mark the inputs + Gia_ManForEachCi( p, pObj, i ) + pObj->fMark0 = 1; + // mark those nodes that have ref count more than 1 + Gia_ManForEachAnd( p, pObj, i ) + pObj->fMark0 = (Gia_ObjRefs(p, pObj) > 1); + // mark the output drivers + Gia_ManForEachCoDriver( p, pObj, i ) + pObj->fMark0 = 1; + + // count the number of nodes + Counter = 0; + Gia_ManForEachObj( p, pObj, i ) + Counter += pObj->fMark0; + *pnObjs = Counter + Gia_ManCoNum(p); + + // reset the references + ABC_FREE( p->pRefs ); + p->pRefs = ABC_CALLOC( int, Gia_ManObjNum(p) ); + // reference from internal nodes + Counter = 0; + vSuper = Vec_IntAlloc( 100 ); + Gia_ManForEachAnd( p, pObj, i ) + { + if ( pObj->fMark0 == 0 ) + continue; + Vec_IntClear( vSuper ); + pObj->fMark0 = 0; + Log_ManCollectSuper( p, pObj, vSuper ); + pObj->fMark0 = 1; + Gia_ManForEachObjVec( vSuper, p, pFanin, k ) + { + assert( pFanin->fMark0 ); + Gia_ObjRefInc( p, pFanin ); + } + Counter += Vec_IntSize( vSuper ); + } + Vec_IntFree( vSuper ); + // reference from outputs + Gia_ManForEachCoDriver( p, pObj, i ) + { + assert( pObj->fMark0 ); + Gia_ObjRefInc( p, pObj ); + } + *pnFanios = Counter + Gia_ManCoNum(p); +} + +/**Function************************************************************* + + Synopsis [Creates fanin/fanout pair.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ObjAddFanin( Log_Obj_t * pObj, Log_Obj_t * pFanin ) +{ + assert( pObj->iFanin < pObj->nFanins ); + assert( pFanin->iFanout < pFanin->nFanouts ); + pFanin->Fanios[pFanin->nFanins + pFanin->iFanout++] = + pObj->Fanios[pObj->iFanin++] = pObj->hHandle - pFanin->hHandle; +} + +/**Function************************************************************* + + Synopsis [Creates logic network isomorphic to the given AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Log_Man_t * Log_ManStart( Gia_Man_t * pGia ) +{ + Log_Man_t * p; + Log_Obj_t * pObjLog, * pFanLog; + Gia_Obj_t * pObj, * pFanin; + Vec_Int_t * vSuper; + int nObjs, nFanios; + int i, k, hHandle = 0; + // prepare the AIG +// Gia_ManCreateRefs( pGia ); + Log_ManCreateRefsSpecial( pGia ); + Log_ManTransformRefs( pGia, &nObjs, &nFanios ); + Gia_ManFillValue( pGia ); + // create logic network + p = ABC_CALLOC( Log_Man_t, 1 ); + p->pGia = pGia; + p->vCis = Vec_IntAlloc( Gia_ManCiNum(pGia) ); + p->vCos = Vec_IntAlloc( Gia_ManCoNum(pGia) ); + p->nObjData = (sizeof(Log_Obj_t) / 4) * nObjs + 2 * nFanios; + p->pObjData = ABC_CALLOC( int, p->nObjData ); + // create constant node + Gia_ManConst0(pGia)->Value = hHandle; + pObjLog = Log_ManObj( p, hHandle ); + pObjLog->hHandle = hHandle; + pObjLog->nFanins = 0; + pObjLog->nFanouts = Gia_ObjRefs( pGia, Gia_ManConst0(pGia) ); + // count objects + hHandle += Log_ObjSize( pObjLog ); + p->nNodes++; + p->nObjs++; + // create the PIs + Gia_ManForEachCi( pGia, pObj, i ) + { + // create PI object + pObj->Value = hHandle; + Vec_IntPush( p->vCis, hHandle ); + pObjLog = Log_ManObj( p, hHandle ); + pObjLog->hHandle = hHandle; + pObjLog->nFanins = 0; + pObjLog->nFanouts = Gia_ObjRefs( pGia, pObj ); + pObjLog->fTerm = 1; + // count objects + hHandle += Log_ObjSize( pObjLog ); + p->nObjs++; + } + // create internal nodes + vSuper = Vec_IntAlloc( 100 ); + Gia_ManForEachAnd( pGia, pObj, i ) + { + if ( pObj->fMark0 == 0 ) + { + assert( Gia_ObjRefs( pGia, pObj ) == 0 ); + continue; + } + assert( Gia_ObjRefs( pGia, pObj ) > 0 ); + // collect fanins + Vec_IntClear( vSuper ); + pObj->fMark0 = 0; + Log_ManCollectSuper( pGia, pObj, vSuper ); + pObj->fMark0 = 1; + // create node object + pObj->Value = hHandle; + pObjLog = Log_ManObj( p, hHandle ); + pObjLog->hHandle = hHandle; + pObjLog->nFanins = Vec_IntSize( vSuper ); + pObjLog->nFanouts = Gia_ObjRefs( pGia, pObj ); + // add fanins + Gia_ManForEachObjVec( vSuper, pGia, pFanin, k ) + { + pFanLog = Log_ManObj( p, Gia_ObjValue(pFanin) ); + Log_ObjAddFanin( pObjLog, pFanLog ); + } + // count objects + hHandle += Log_ObjSize( pObjLog ); + p->nNodes++; + p->nObjs++; + } + Vec_IntFree( vSuper ); + // create the POs + Gia_ManForEachCo( pGia, pObj, i ) + { + // create PO object + pObj->Value = hHandle; + Vec_IntPush( p->vCos, hHandle ); + pObjLog = Log_ManObj( p, hHandle ); + pObjLog->hHandle = hHandle; + pObjLog->nFanins = 1; + pObjLog->nFanouts = 0; + pObjLog->fTerm = 1; + // add fanins + pFanLog = Log_ManObj( p, Gia_ObjValue(Gia_ObjFanin0(pObj)) ); + Log_ObjAddFanin( pObjLog, pFanLog ); + // count objects + hHandle += Log_ObjSize( pObjLog ); + p->nObjs++; + } + Gia_ManCleanMark0( pGia ); + assert( nObjs == p->nObjs ); + assert( hHandle == p->nObjData ); + // make sure the fanin/fanout counters are correct + Gia_ManForEachObj( pGia, pObj, i ) + { + if ( !~Gia_ObjValue(pObj) ) + continue; + pObjLog = Log_ManObj( p, Gia_ObjValue(pObj) ); + assert( pObjLog->nFanins == pObjLog->iFanin ); + assert( pObjLog->nFanouts == pObjLog->iFanout ); + pObjLog->iFanin = pObjLog->iFanout = 0; + } + ABC_FREE( pGia->pRefs ); + return p; +} + +/**Function************************************************************* + + Synopsis [Creates logic network isomorphic to the given AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManPrintStats( Log_Man_t * p ) +{ +// if ( p->pName ) +// printf( "%8s : ", p->pName ); + printf( "i/o =%7d/%7d ", Log_ManCiNum(p), Log_ManCoNum(p) ); +// if ( Log_ManRegNum(p) ) +// printf( "ff =%7d ", Log_ManRegNum(p) ); + printf( "node =%8d ", Log_ManNodeNum(p) ); +// printf( "lev =%5d ", Log_ManLevelNum(p) ); +// printf( "cut =%5d ", Log_ManCrossCut(p) ); + printf( "mem =%5.2f Mb", 4.0*p->nObjData/(1<<20) ); +// printf( "obj =%5d ", Log_ManObjNum(p) ); + printf( "\n" ); + +// Log_ManSatExperiment( p ); +} + +/**Function************************************************************* + + Synopsis [Creates logic network isomorphic to the given AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManStop( Log_Man_t * p ) +{ + Vec_IntFree( p->vCis ); + Vec_IntFree( p->vCos ); + ABC_FREE( p->pObjData ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [Cleans the value.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManCleanTravId( Log_Man_t * p ) +{ + Log_Obj_t * pObj; + int i; + Log_ManForEachObj( p, pObj, i ) + pObj->TravId = 0; +} + +/**Function************************************************************* + + Synopsis [Cleans the value.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManCleanValue( Log_Man_t * p ) +{ + Log_Obj_t * pObj; + int i; + Log_ManForEachObj( p, pObj, i ) + pObj->Value = 0; +} + +/**Function************************************************************* + + Synopsis [Prints the distribution of fanins/fanouts in the network.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Log_ManPrintFanio( Log_Man_t * p ) +{ + char Buffer[100]; + Log_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; + Log_ManForEachNode( p, pNode, i ) + { + if ( i == 0 ) continue; // skip const 0 obj + nFanins = Log_ObjFaninNum(pNode); + nFanouts = Log_ObjFanoutNum(pNode); + nFaninsAll += nFanins; + nFanoutsAll += nFanouts; + nFaninsMax = ABC_MAX( nFaninsMax, nFanins ); + nFanoutsMax = ABC_MAX( nFanoutsMax, nFanouts ); + } + + // allocate storage for fanin/fanout numbers + nSizeMax = AIG_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 + Log_ManForEachNode( p, pNode, i ) + { + if ( i == 0 ) continue; // skip const 0 obj + nFanins = Log_ObjFaninNum(pNode); + nFanouts = Log_ObjFanoutNum(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/Log_ManNodeNum(p), + nFanoutsMax, 1.0*nFanoutsAll/Log_ManNodeNum(p) ); +} + +/**Function************************************************************* + + Synopsis [Computes the distance from the given object] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Log_ManComputeDistance( Log_Man_t * p, Log_Obj_t * pPivot ) +{ + Vec_Int_t * vThis, * vNext, * vTemp; + Log_Obj_t * pThis, * pNext; + int i, k, d, nVisited = 0; +// assert( Log_ObjIsTerm(pPivot) ); + vThis = Vec_IntAlloc( 1000 ); + vNext = Vec_IntAlloc( 1000 ); + Log_ManIncrementTravId( p ); + Log_ObjSetTravIdCurrent( p, pPivot ); + Vec_IntPush( vThis, pPivot->hHandle ); + for ( d = 0; Vec_IntSize(vThis) > 0; d++ ) + { + nVisited += Vec_IntSize(vThis); + Vec_IntClear( vNext ); + Log_ManForEachObjVec( vThis, p, pThis, i ) + { + Log_ObjForEachFanin( pThis, pNext, k ) + { + if ( Log_ObjIsTravIdCurrent(p, pNext) ) + continue; + Log_ObjSetTravIdCurrent(p, pNext); + Vec_IntPush( vNext, pNext->hHandle ); + nVisited += !Log_ObjIsTerm(pNext); + } + Log_ObjForEachFanout( pThis, pNext, k ) + { + if ( Log_ObjIsTravIdCurrent(p, pNext) ) + continue; + Log_ObjSetTravIdCurrent(p, pNext); + Vec_IntPush( vNext, pNext->hHandle ); + nVisited += !Log_ObjIsTerm(pNext); + } + } + vTemp = vThis; vThis = vNext; vNext = vTemp; + } + Vec_IntFree( vThis ); + Vec_IntFree( vNext ); + // check if there are several strongly connected components +// if ( nVisited < Log_ManNodeNum(p) ) +// printf( "Visited less nodes (%d) than present (%d).\n", nVisited, Log_ManNodeNum(p) ); + return d; +} + +/**Function************************************************************* + + Synopsis [Traverses from the given node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTestDistanceInternal( Log_Man_t * p ) +{ + int nAttempts = 20; + int i, iNode, Dist, clk; + Log_Obj_t * pPivot, * pNext; + Aig_ManRandom( 1 ); + Log_ManResetTravId( p ); + // compute distances from several randomly selected PIs + clk = clock(); + printf( "From inputs: " ); + for ( i = 0; i < nAttempts; i++ ) + { + iNode = Aig_ManRandom( 0 ) % Log_ManCiNum(p); + pPivot = Log_ManCi( p, iNode ); + if ( Log_ObjFanoutNum(pPivot) == 0 ) + { i--; continue; } + pNext = Log_ObjFanout( pPivot, 0 ); + if ( !Log_ObjIsNode(pNext) ) + { i--; continue; } + Dist = Log_ManComputeDistance( p, pPivot ); + printf( "%d ", Dist ); + } + ABC_PRT( "Time", clock() - clk ); + // compute distances from several randomly selected POs + clk = clock(); + printf( "From outputs: " ); + for ( i = 0; i < nAttempts; i++ ) + { + iNode = Aig_ManRandom( 0 ) % Log_ManCoNum(p); + pPivot = Log_ManCo( p, iNode ); + pNext = Log_ObjFanin( pPivot, 0 ); + if ( !Log_ObjIsNode(pNext) ) + { i--; continue; } + Dist = Log_ManComputeDistance( p, pPivot ); + printf( "%d ", Dist ); + } + ABC_PRT( "Time", clock() - clk ); + // compute distances from several randomly selected nodes + clk = clock(); + printf( "From nodes: " ); + for ( i = 0; i < nAttempts; i++ ) + { + iNode = Aig_ManRandom( 0 ) % Gia_ManObjNum(p->pGia); + if ( !~Gia_ManObj(p->pGia, iNode)->Value ) + { i--; continue; } + pPivot = Log_ManObj( p, Gia_ManObj(p->pGia, iNode)->Value ); + if ( !Log_ObjIsNode(pPivot) ) + { i--; continue; } + Dist = Log_ManComputeDistance( p, pPivot ); + printf( "%d ", Dist ); + } + ABC_PRT( "Time", clock() - clk ); +} + +/**Function************************************************************* + + Synopsis [Returns sorted array of node handles with largest fanout.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTestDistance( Gia_Man_t * pGia ) +{ + Log_Man_t * p; + int clk = clock(); + p = Log_ManStart( pGia ); +// Log_ManPrintFanio( p ); + Log_ManPrintStats( p ); +ABC_PRT( "Time", clock() - clk ); + Gia_ManTestDistanceInternal( p ); + Log_ManStop( p ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c new file mode 100644 index 00000000..e6e45cb5 --- /dev/null +++ b/src/aig/gia/giaMan.c @@ -0,0 +1,203 @@ +/**CFile**************************************************************** + + FileName [giaMan.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Package manager.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Creates AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManStart( int nObjsMax ) +{ + Gia_Man_t * p; + assert( nObjsMax > 0 ); + p = ABC_CALLOC( Gia_Man_t, 1 ); + p->nObjsAlloc = nObjsMax; + p->pObjs = ABC_CALLOC( Gia_Obj_t, nObjsMax ); + p->pObjs->iDiff0 = p->pObjs->iDiff1 = GIA_NONE; + p->nObjs = 1; + p->vCis = Vec_IntAlloc( nObjsMax / 10 ); + p->vCos = Vec_IntAlloc( nObjsMax / 10 ); + return p; +} + +/**Function************************************************************* + + Synopsis [Deletes AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManStop( Gia_Man_t * p ) +{ + Vec_IntFree( p->vCis ); + Vec_IntFree( p->vCos ); + ABC_FREE( p->pFanData ); + ABC_FREE( p->pReprs ); + ABC_FREE( p->pName ); + ABC_FREE( p->pRefs ); + ABC_FREE( p->pLevels ); + ABC_FREE( p->pHTable ); + ABC_FREE( p->pObjs ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [Prints stats for the AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPrintStats( Gia_Man_t * p ) +{ + if ( p->pName ) + printf( "%8s : ", p->pName ); + printf( "i/o =%7d/%7d ", Gia_ManPiNum(p), Gia_ManPoNum(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) ); +// printf( "obj =%5d ", Gia_ManObjNum(p) ); + printf( "\n" ); + +// Gia_ManSatExperiment( p ); +} + +/**Function************************************************************* + + Synopsis [Prints stats for the AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPrintStatsShort( Gia_Man_t * p ) +{ + printf( "i/o =%7d/%7d ", Gia_ManPiNum(p), Gia_ManPoNum(p) ); +// printf( "ff =%7d ", Gia_ManRegNum(p) ); + printf( "and =%8d ", Gia_ManAndNum(p) ); + printf( "lev =%5d ", Gia_ManLevelNum(p) ); + printf( "mem =%5.2f Mb", 12.0*Gia_ManObjNum(p)/(1<<20) ); + printf( "\n" ); +} + +/**Function************************************************************* + + Synopsis [Prints stats for the AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPrintMiterStatus( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj, * pChild; + int i, nSat = 0, nUnsat = 0, nUndec = 0, iOut = -1; + Gia_ManForEachPo( p, pObj, i ) + { + pChild = Gia_ObjChild0(pObj); + // check if the output is constant 0 + if ( pChild == Gia_ManConst0(p) ) + nUnsat++; + // check if the output is constant 1 + else if ( pChild == Gia_ManConst1(p) ) + { + nSat++; + if ( iOut == -1 ) + iOut = i; + } + // check if the output is a primary input + else if ( Gia_ObjIsPi(p, Gia_Regular(pChild)) ) + { + nSat++; + if ( iOut == -1 ) + iOut = i; + } +/* + // check if the output is 1 for the 0000 pattern + else if ( Gia_Regular(pChild)->fPhase != (unsigned)Gia_IsComplement(pChild) ) + { + nSat++; + if ( iOut == -1 ) + iOut = i; + } +*/ + else + nUndec++; + } + printf( "Outputs = %7d. Unsat = %7d. Sat = %7d. Undec = %7d.\n", + Gia_ManPoNum(p), nUnsat, nSat, nUndec ); +} + +/**Function************************************************************* + + Synopsis [Prints stats for the AIG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs ) +{ + assert( p->nRegs == 0 ); + p->nRegs = nRegs; +} + + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaProp.c b/src/aig/gia/giaProp.c new file mode 100644 index 00000000..1d9ed8cf --- /dev/null +++ b/src/aig/gia/giaProp.c @@ -0,0 +1,171 @@ +/**CFile**************************************************************** + + FileName [giaProp.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Constraint propagation on the AIG.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaProp.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +#define GIA_SAT_SHIFT 12 +#define GIA_ROOT_MASK +#define GIA_PATH00_MASK +#define GIA_PATH10_MASK +#define GIA_PATH20_MASK +#define GIA_PATH30_MASK +#define GIA_PATH00_MASK +#define GIA_PATH10_MASK +#define GIA_PATH20_MASK +#define GIA_PATH30_MASK + +static inline int Gia_SatObjIsRoot( Gia_Obj_t * p ) { return 0; } +static inline int Gia_SatObjXorRoot( Gia_Obj_t * p ) { return 0; } + + +static inline int Gia_SatObjIsAssigned( Gia_Obj_t * p ) { return 0; } +static inline int Gia_SatObjIsHeld( Gia_Obj_t * p ) { return 0; } +static inline int Gia_SatObjValue( Gia_Obj_t * p ) { return 0; } + + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Checks if the give cut is satisfied.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_SatPathCheckCutSat_rec( Gia_Obj_t * p, int fCompl ) +{ + if ( Gia_SatObjIsRoot(p) ) + return Gia_ObjIsAssigned(p) && Gia_SatObjValue(p) == fCompl; + if ( Gia_SatObjPath0(p) && !Gia_SatPathCheckCutSat_rec( Gia_ObjFanin0(p), fCompl ^ Gia_ObjFaninC0(p) ) ) + return 0; + if ( Gia_SatObjPath1(p) && !Gia_SatPathCheckCutSat_rec( Gia_ObjFanin1(p), fCompl ^ Gia_ObjFaninC1(p) ) ) + return 0; + return 1; +} + +/**Function************************************************************* + + Synopsis [Checks if the give cut is satisfied.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_SatPathCheckCutSat( Gia_Obj_t * p ) +{ + int RetValue; + assert( Gia_SatObjIsRoot(p) ); + Gia_SatObjXorRoot(p); + RetValue = Gia_SatPathCheckCutSat_rec( p ); + Gia_SatObjXorRoot(p); + return RetValue; +} + +/**Function************************************************************* + + Synopsis [Unbinds literals on the path.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_SatPathUnbind_rec( Gia_Obj_t * p ) +{ +} + +/**Function************************************************************* + + Synopsis [Creates a feasible path from the node to a terminal.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_SatPathStart_rec( Gia_Obj_t * p, int fDiffs, int fCompl ) +{ + if ( Gia_SatObjIsRoot(p) ) + return fDiffs && (!Gia_ObjIsAssigned(p) || Gia_SatObjValue(p) != fCompl); + if ( fCompl == 0 ) + { + if ( Gia_SatPathStart_rec( Gia_ObjFanin0(p), fDiffs + !Gia_SatObjPath0(p), fCompl ^ Gia_ObjFaninC0(p) ) && + Gia_SatPathStart_rec( Gia_ObjFanin1(p), fDiffs + !Gia_SatObjPath1(p), fCompl ^ Gia_ObjFaninC1(p) ) ) + return Gia_ObjSetDraftPath0(p) + Gia_ObjSetDraftPath1(p); + } + else + { + if ( Gia_SatPathStart_rec( Gia_ObjFanin0(p), fDiffs + !Gia_SatObjPath0(p), fCompl ^ Gia_ObjFaninC0(p) ) ) + { + Gia_ObjUnsetDraftPath1(p); + return Gia_ObjSetDraftPath0(p); + } + if ( Gia_SatPathStart_rec( Gia_ObjFanin1(p), fDiffs + !Gia_SatObjPath1(p), fCompl ^ Gia_ObjFaninC1(p) ) ) + { + Gia_ObjUnsetDraftPath0(p); + return Gia_ObjSetDraftPath1(p); + } + } + return 0; +} + +/**Function************************************************************* + + Synopsis [Creates a feasible path from the node to a terminal.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_SatPathStart( Gia_Obj_t * p ) +{ + int RetValue; + assert( Gia_SatObjIsRoot(p) ); + Gia_SatObjXorRoot(p); + RetValue = Gia_SatPathStart_rec( p, 0, 0 ); + Gia_SatObjXorRoot(p); + return RetValue; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaSat.c b/src/aig/gia/giaSat.c new file mode 100644 index 00000000..6d127223 --- /dev/null +++ b/src/aig/gia/giaSat.c @@ -0,0 +1,421 @@ +/**CFile**************************************************************** + + FileName [giaSat.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [New constraint-propagation procedures.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaSat.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +#define GIA_LIMIT 10 + + +typedef struct Gia_ManSat_t_ Gia_ManSat_t; +struct Gia_ManSat_t_ +{ + Aig_MmFlex_t * pMem; +}; + +typedef struct Gia_ObjSat1_t_ Gia_ObjSat1_t; +struct Gia_ObjSat1_t_ +{ + char nFans; + char nOffset; + char PathsH; + char PathsV; +}; + +typedef struct Gia_ObjSat2_t_ Gia_ObjSat2_t; +struct Gia_ObjSat2_t_ +{ + unsigned fTerm : 1; + unsigned iLit : 31; +}; + +typedef struct Gia_ObjSat_t_ Gia_ObjSat_t; +struct Gia_ObjSat_t_ +{ + union { + Gia_ObjSat1_t Obj1; + Gia_ObjSat2_t Obj2; + }; +}; + + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_ManSat_t * Gia_ManSatStart() +{ + Gia_ManSat_t * p; + p = ABC_CALLOC( Gia_ManSat_t, 1 ); + p->pMem = Aig_MmFlexStart(); + return p; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSatStop( Gia_ManSat_t * p ) +{ + Aig_MmFlexStop( p->pMem, 0 ); + ABC_FREE( p ); +} + + +/**Function************************************************************* + + Synopsis [Collects the supergate rooted at this ] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSatPartCollectSuper( Gia_Man_t * p, Gia_Obj_t * pObj, int * pLits, int * pnLits ) +{ + Gia_Obj_t * pFanin; + assert( Gia_ObjIsAnd(pObj) ); + assert( pObj->fMark0 == 0 ); + pFanin = Gia_ObjFanin0(pObj); + if ( pFanin->fMark0 || Gia_ObjFaninC0(pObj) ) + pLits[(*pnLits)++] = Gia_Var2Lit(Gia_ObjId(p, pFanin), Gia_ObjFaninC0(pObj)); + else + Gia_ManSatPartCollectSuper(p, pFanin, pLits, pnLits); + pFanin = Gia_ObjFanin1(pObj); + if ( pFanin->fMark0 || Gia_ObjFaninC1(pObj) ) + pLits[(*pnLits)++] = Gia_Var2Lit(Gia_ObjId(p, pFanin), Gia_ObjFaninC1(pObj)); + else + Gia_ManSatPartCollectSuper(p, pFanin, pLits, pnLits); +} + +/**Function************************************************************* + + Synopsis [Returns the number of words used.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSatPartCreate_rec( Gia_Man_t * p, Gia_Obj_t * pObj, int * pObjPlace, int * pStore ) +{ + Gia_Obj_t * pFanin; + int i, nWordsUsed, nSuperSize = 0, Super[2*GIA_LIMIT]; + // make sure this is a valid node + assert( Gia_ObjIsAnd(pObj) ); + assert( pObj->fMark0 == 0 ); + // collect inputs to the supergate + Gia_ManSatPartCollectSuper( p, pObj, Super, &nSuperSize ); + assert( nSuperSize <= 2*GIA_LIMIT ); + // create the root entry + *pObjPlace = 0; + ((Gia_ObjSat1_t *)pObjPlace)->nFans = Gia_Var2Lit( nSuperSize, 0 ); + ((Gia_ObjSat1_t *)pObjPlace)->nOffset = pStore - pObjPlace; + nWordsUsed = nSuperSize; + for ( i = 0; i < nSuperSize; i++ ) + { + pFanin = Gia_ManObj( p, Gia_Lit2Var(Super[i]) ); + if ( pFanin->fMark0 ) + { + ((Gia_ObjSat2_t *)(pStore + i))->fTerm = 1; + ((Gia_ObjSat2_t *)(pStore + i))->iLit = Super[i]; + } + else + { + assert( Gia_LitIsCompl(Super[i]) ); + nWordsUsed += Gia_ManSatPartCreate_rec( p, pFanin, pStore + i, pStore + nWordsUsed ); + } + } + return nWordsUsed; +} + +/**Function************************************************************* + + Synopsis [Creates part and returns the number of words used.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSatPartCreate( Gia_Man_t * p, Gia_Obj_t * pObj, int * pStore ) +{ + return 1 + Gia_ManSatPartCreate_rec( p, pObj, pStore, pStore + 1 ); +} + + +/**Function************************************************************* + + Synopsis [Count the number of internal nodes in the leaf-DAG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSatPartCountClauses( Gia_Man_t * p, Gia_Obj_t * pObj, int * pnOnset, int * pnOffset ) +{ + Gia_Obj_t * pFanin; + int nOnset0, nOnset1, nOffset0, nOffset1; + assert( Gia_ObjIsAnd(pObj) ); + pFanin = Gia_ObjFanin0(pObj); + if ( pFanin->fMark0 ) + nOnset0 = 1, nOffset0 = 1; + else + { + Gia_ManSatPartCountClauses(p, pFanin, &nOnset0, &nOffset0); + if ( Gia_ObjFaninC0(pObj) ) + { + int Temp = nOnset0; + nOnset0 = nOffset0; + nOffset0 = Temp; + } + } + pFanin = Gia_ObjFanin1(pObj); + if ( pFanin->fMark0 ) + nOnset1 = 1, nOffset1 = 1; + else + { + Gia_ManSatPartCountClauses(p, pFanin, &nOnset1, &nOffset1); + if ( Gia_ObjFaninC1(pObj) ) + { + int Temp = nOnset1; + nOnset1 = nOffset1; + nOffset1 = Temp; + } + } + *pnOnset = nOnset0 * nOnset1; + *pnOffset = nOffset0 + nOffset1; +} + +/**Function************************************************************* + + Synopsis [Count the number of internal nodes in the leaf-DAG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSatPartCount( Gia_Man_t * p, Gia_Obj_t * pObj, int * pnLeaves, int * pnNodes ) +{ + Gia_Obj_t * pFanin; + int Level0 = 0, Level1 = 0; + assert( Gia_ObjIsAnd(pObj) ); + assert( pObj->fMark0 == 0 ); + (*pnNodes)++; + pFanin = Gia_ObjFanin0(pObj); + if ( pFanin->fMark0 ) + (*pnLeaves)++; + else + Level0 = Gia_ManSatPartCount(p, pFanin, pnLeaves, pnNodes) + Gia_ObjFaninC0(pObj); + pFanin = Gia_ObjFanin1(pObj); + if ( pFanin->fMark0 ) + (*pnLeaves)++; + else + Level1 = Gia_ManSatPartCount(p, pFanin, pnLeaves, pnNodes) + Gia_ObjFaninC1(pObj); + return AIG_MAX( Level0, Level1 ); +} + +/**Function************************************************************* + + Synopsis [Count the number of internal nodes in the leaf-DAG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSatPartCountNodes( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + Gia_Obj_t * pFanin; + int nNodes0 = 0, nNodes1 = 0; + assert( Gia_ObjIsAnd(pObj) ); + assert( pObj->fMark0 == 0 ); + pFanin = Gia_ObjFanin0(pObj); + if ( !(pFanin->fMark0) ) + nNodes0 = Gia_ManSatPartCountNodes(p, pFanin); + pFanin = Gia_ObjFanin1(pObj); + if ( !(pFanin->fMark0) ) + nNodes1 = Gia_ManSatPartCountNodes(p, pFanin); + return nNodes0 + nNodes1 + 1; +} + +/**Function************************************************************* + + Synopsis [Count the number of internal nodes in the leaf-DAG.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSatPartPrint( Gia_Man_t * p, Gia_Obj_t * pObj, int Step ) +{ + Gia_Obj_t * pFanin; + assert( Gia_ObjIsAnd(pObj) ); + assert( pObj->fMark0 == 0 ); + pFanin = Gia_ObjFanin0(pObj); + if ( pFanin->fMark0 ) + printf( "%s%d", Gia_ObjFaninC0(pObj)?"!":"", Gia_ObjId(p,pFanin) ); + else + { + if ( Gia_ObjFaninC0(pObj) ) + printf( "(" ); + Gia_ManSatPartPrint(p, pFanin, Step + Gia_ObjFaninC0(pObj)); + if ( Gia_ObjFaninC0(pObj) ) + printf( ")" ); + } + printf( "%s", (Step & 1)? " + " : "*" ); + pFanin = Gia_ObjFanin1(pObj); + if ( pFanin->fMark0 ) + printf( "%s%d", Gia_ObjFaninC1(pObj)?"!":"", Gia_ObjId(p,pFanin) ); + else + { + if ( Gia_ObjFaninC1(pObj) ) + printf( "(" ); + Gia_ManSatPartPrint(p, pFanin, Step + Gia_ObjFaninC1(pObj)); + if ( Gia_ObjFaninC1(pObj) ) + printf( ")" ); + } +} + + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSatExperiment( Gia_Man_t * p ) +{ + int nStored, Storage[1000], * pStart; + Gia_ManSat_t * pMan; + Gia_Obj_t * pObj; + int i, nLevels, nLeaves, nNodes, nCount[2*GIA_LIMIT+2] = {0}, nCountAll = 0; + int Num0 = 0, Num1 = 0; + int clk = clock(), nWords = 0, nWords2 = 0; + pMan = Gia_ManSatStart(); + // mark the nodes to become roots of leaf-DAGs + Gia_ManSetRefs( p ); + Gia_ManForEachObj( p, pObj, i ) + { + pObj->fMark0 = 0; + if ( Gia_ObjIsCo(pObj) ) + Gia_ObjFanin0(pObj)->fMark0 = 1; + else if ( Gia_ObjIsCi(pObj) ) + pObj->fMark0 = 1; + else if ( Gia_ObjIsAnd(pObj) ) + { + if ( pObj->Value > 1 || Gia_ManSatPartCountNodes(p,pObj) >= GIA_LIMIT ) + pObj->fMark0 = 1; + } + pObj->Value = 0; + } + // compute the sizes of leaf-DAGs + Gia_ManForEachAnd( p, pObj, i ) + { + if ( pObj->fMark0 == 0 ) + continue; + pObj->fMark0 = 0; + + nCountAll++; + nStored = Gia_ManSatPartCreate( p, pObj, Storage ); + nWords2 += nStored; + assert( nStored < 500 ); + pStart = (int *)Aig_MmFlexEntryFetch( pMan->pMem, sizeof(int) * nStored ); + memcpy( pStart, Storage, sizeof(int) * nStored ); + + nLeaves = nNodes = 0; + nLevels = 1+Gia_ManSatPartCount( p, pObj, &nLeaves, &nNodes ); + nWords += nLeaves + nNodes; + if ( nNodes <= 2*GIA_LIMIT ) + nCount[nNodes]++; + else + nCount[2*GIA_LIMIT+1]++; +// if ( nNodes > 10 && i % 100 == 0 ) +// if ( nNodes > 5 ) + if ( 0 ) + { + Gia_ManSatPartCountClauses( p, pObj, &Num0, &Num1 ); + printf( "%8d : And = %3d. Lev = %2d. Clauses = %3d. (%3d + %3d).\n", i, nNodes, nLevels, Num0+Num1, Num0, Num1 ); + Gia_ManSatPartPrint( p, pObj, 0 ); + printf( "\n" ); + } + + pObj->fMark0 = 1; + } + printf( "\n" ); + Gia_ManForEachObj( p, pObj, i ) + pObj->fMark0 = 0; + Gia_ManSatStop( pMan ); + for ( i = 0; i < 2*GIA_LIMIT+2; i++ ) + printf( "%2d=%6d %7.2f %% %7.2f %%\n", i, nCount[i], 100.0*nCount[i]/nCountAll, 100.0*i*nCount[i]/Gia_ManAndNum(p) ); + ABC_PRM( "MemoryEst", 4*nWords ); + ABC_PRM( "MemoryReal", 4*nWords2 ); + printf( "%5.2f bpn ", 4.0*nWords2/Gia_ManObjNum(p) ); + ABC_PRT( "Time", clock() - clk ); +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaScl.c b/src/aig/gia/giaScl.c new file mode 100644 index 00000000..3f72b0b9 --- /dev/null +++ b/src/aig/gia/giaScl.c @@ -0,0 +1,240 @@ +/**CFile**************************************************************** + + FileName [giaScl.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Sequential cleanup.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaScl.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Returns the number of unmarked nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManCombMarkUsed_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +{ + if ( !pObj->fMark0 ) + return 0; + pObj->fMark0 = 0; + assert( Gia_ObjIsAnd(pObj) ); + return Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) ) + + Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin1(pObj) ) + 1; +} + +/**Function************************************************************* + + Synopsis [Returns the number of unused nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManCombMarkUsed( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i, nNodes = 0; + Gia_ManForEachObj( p, pObj, i ) + pObj->fMark0 = Gia_ObjIsAnd(pObj); + Gia_ManForEachCo( p, pObj, i ) + nNodes += Gia_ManCombMarkUsed_rec( p, Gia_ObjFanin0(pObj) ); + return nNodes; +} + +/**Function************************************************************* + + Synopsis [Performs combinational cleanup.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManCleanup( Gia_Man_t * p ) +{ + Gia_ManCombMarkUsed( p ); + return Gia_ManDupMarked( p ); +} + +/**Function************************************************************* + + Synopsis [Marks CIs/COs reachable from POs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSeqMarkUsed_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vRoots ) +{ + if ( !pObj->fMark0 ) + return; + pObj->fMark0 = 0; + if ( Gia_ObjIsCo(pObj) ) + { + Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin0(pObj), vRoots ); + return; + } + if ( Gia_ObjIsRo(p, pObj) ) + { + Vec_IntPush( vRoots, Gia_ObjId(p, Gia_ObjRoToRi(p, pObj)) ); + return; + } + assert( Gia_ObjIsAnd(pObj) ); + Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin0(pObj), vRoots ); + Gia_ManSeqMarkUsed_rec( p, Gia_ObjFanin1(pObj), vRoots ); +} + +/**Function************************************************************* + + Synopsis [Performs sequential cleanup.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManSeqCleanup( Gia_Man_t * p ) +{ + Vec_Int_t * vRoots; + Gia_Obj_t * pObj; + int i; + Gia_ManSetMark0( p ); + Gia_ManConst0(p)->fMark0 = 0; + Gia_ManForEachPi( p, pObj, i ) + pObj->fMark0 = 0; + vRoots = Gia_ManCollectPoIds( p ); + Gia_ManForEachObjVec( vRoots, p, pObj, i ) + Gia_ManSeqMarkUsed_rec( p, pObj, vRoots ); + Vec_IntFree( vRoots ); + return Gia_ManDupMarked( p ); +} + +/**Function************************************************************* + + Synopsis [Find representatives due to identical fanins.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManReduceEquiv( Gia_Man_t * p, int fVerbose ) +{ + Gia_Man_t * pNew; + Gia_Obj_t * pObjRi, * pObjRo; + unsigned * pCi2Lit, * pMaps; + int i, iLit, nFanins = 1, Counter0 = 0, Counter = 0; + Gia_ManForEachRi( p, pObjRi, i ) + Gia_ObjFanin0(pObjRi)->Value = 0; + Gia_ManForEachRi( p, pObjRi, i ) + 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 ); + Gia_ManForEachRiRo( p, pObjRi, pObjRo, i ) + { + iLit = Gia_ObjFanin0Copy( pObjRi ); + if ( Gia_ObjFaninId0p(p, pObjRi) == 0 ) + pCi2Lit[Gia_ManPiNum(p)+i] = 0, Counter0++; + else if ( ~pMaps[iLit] ) // in this case, ID(pObj) > ID(pRepr) + pCi2Lit[Gia_ManPiNum(p)+i] = pMaps[iLit], Counter++; + else + pMaps[iLit] = Gia_Var2Lit( Gia_ObjId(p, pObjRo), 0 ); + } +/* + Gia_ManForEachCi( p, pObjRo, i ) + { + if ( ~pCi2Lit[i] ) + { + Gia_Obj_t * pObj0 = Gia_ObjRoToRi(p, pObjRo); + Gia_Obj_t * pObj1 = Gia_ObjRoToRi(p, Gia_ManObj(p, pCi2Lit[i])); + Gia_Obj_t * pFan0 = Gia_ObjChild0( p, Gia_ObjRoToRi(p, pObjRo) ); + Gia_Obj_t * pFan1 = Gia_ObjChild0( p, Gia_ObjRoToRi(p, Gia_ManObj(p, pCi2Lit[i])) ); + assert( pFan0 == pFan1 ); + } + } +*/ + if ( fVerbose ) + printf( "ReduceEquiv detected %d constant regs and %d equivalent regs.\n", Counter0, Counter ); + ABC_FREE( pMaps ); + pNew = Gia_ManDupDfsCiMap( p, pCi2Lit, NULL ); + ABC_FREE( pCi2Lit ); + return pNew; +} + +/**Function************************************************************* + + Synopsis [Performs sequential cleanup.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManSeqStructSweep( Gia_Man_t * p, int fConst, int fEquiv, int fVerbose ) +{ + Gia_Man_t * pTemp; + if ( Gia_ManRegNum(p) == 0 ) + return Gia_ManDup( p ); + p = Gia_ManSeqCleanup( p ); + if ( fConst && Gia_ManRegNum(p) ) + { + p = Gia_ManReduceConst( pTemp = p, fVerbose ); + Gia_ManStop( pTemp ); + } + if ( fEquiv && Gia_ManRegNum(p) ) + { + p = Gia_ManReduceEquiv( pTemp = p, fVerbose ); + Gia_ManStop( pTemp ); + } + p = Gia_ManSeqCleanup( pTemp = p ); + Gia_ManStop( pTemp ); + return p; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaSim.c b/src/aig/gia/giaSim.c new file mode 100644 index 00000000..7ee0ddc4 --- /dev/null +++ b/src/aig/gia/giaSim.c @@ -0,0 +1,437 @@ +/**CFile**************************************************************** + + FileName [giaSim.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Fast sequential simulator.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaSim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Gia_ManSim_t_ Gia_ManSim_t; +struct Gia_ManSim_t_ +{ + Gia_Man_t * pAig; + Gia_ParSim_t * pPars; + int nWords; + Vec_Int_t * vCis2Ids; + // simulation information + unsigned * pDataSim; // simulation data + unsigned * pDataSimCis; // simulation data for CIs + unsigned * pDataSimCos; // simulation data for COs +}; + +static inline unsigned * Gia_SimData( Gia_ManSim_t * p, int i ) { return p->pDataSim + i * p->nWords; } +static inline unsigned * Gia_SimDataCi( Gia_ManSim_t * p, int i ) { return p->pDataSimCis + i * p->nWords; } +static inline unsigned * Gia_SimDataCo( Gia_ManSim_t * p, int i ) { return p->pDataSimCos + i * p->nWords; } + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [This procedure sets default parameters.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSimSetDefaultParams( Gia_ParSim_t * p ) +{ + memset( p, 0, sizeof(Gia_ParSim_t) ); + // user-controlled parameters + p->nWords = 8; // the number of machine words + p->nIters = 32; // the number of timeframes + p->TimeLimit = 60; // time limit in seconds + p->fCheckMiter = 0; // check if miter outputs are non-zero + p->fVerbose = 1; // enables verbose output +} + +/**Function************************************************************* + + Synopsis [Creates fast simulation manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_ManSim_t * Gia_ManSimCreate( Gia_Man_t * pAig, Gia_ParSim_t * pPars ) +{ + Gia_ManSim_t * p; + int Entry, i; + p = ABC_ALLOC( Gia_ManSim_t, 1 ); + memset( p, 0, sizeof(Gia_ManSim_t) ); + p->pAig = Gia_ManFront( pAig ); + p->pPars = pPars; + p->nWords = pPars->nWords; + 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) ); + p->vCis2Ids = Vec_IntAlloc( Gia_ManCiNum(p->pAig) ); + Vec_IntForEachEntry( pAig->vCis, Entry, i ) + Vec_IntPush( p->vCis2Ids, Entry ); + printf( "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) ); + return p; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + 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; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = Aig_ManRandom( 0 ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimInfoZero( Gia_ManSim_t * p, unsigned * pInfo ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = 0; +} + +/**Function************************************************************* + + Synopsis [Returns index of the first pattern that failed.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Gia_ManSimInfoIsZero( Gia_ManSim_t * p, unsigned * pInfo ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + if ( pInfo[w] ) + return 32*(w-1) + Aig_WordFindFirstBit( pInfo[w] ); + return -1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimInfoOne( Gia_ManSim_t * p, unsigned * pInfo ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~0; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimInfoCopy( Gia_ManSim_t * p, unsigned * pInfo, unsigned * pInfo0 ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w]; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimulateCi( Gia_ManSim_t * p, Gia_Obj_t * pObj, int iCi ) +{ + unsigned * pInfo = Gia_SimData( p, Gia_ObjValue(pObj) ); + unsigned * pInfo0 = Gia_SimDataCi( p, iCi ); + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w]; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimulateCo( Gia_ManSim_t * p, int iCo, Gia_Obj_t * pObj ) +{ + unsigned * pInfo = Gia_SimDataCo( p, iCo ); + unsigned * pInfo0 = Gia_SimData( p, Gia_ObjDiff0(pObj) ); + int w; + if ( Gia_ObjFaninC0(pObj) ) + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~pInfo0[w]; + else + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w]; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimulateNode( Gia_ManSim_t * p, Gia_Obj_t * pObj ) +{ + unsigned * pInfo = Gia_SimData( p, Gia_ObjValue(pObj) ); + unsigned * pInfo0 = Gia_SimData( p, Gia_ObjDiff0(pObj) ); + unsigned * pInfo1 = Gia_SimData( p, Gia_ObjDiff1(pObj) ); + int w; + if ( Gia_ObjFaninC0(pObj) ) + { + if ( Gia_ObjFaninC1(pObj) ) + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~(pInfo0[w] | pInfo1[w]); + else + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~pInfo0[w] & pInfo1[w]; + } + else + { + if ( Gia_ObjFaninC1(pObj) ) + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w] & ~pInfo1[w]; + else + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w] & pInfo1[w]; + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimInfoInit( Gia_ManSim_t * p ) +{ + int iPioNum, i; + Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i ) + { + if ( iPioNum < Gia_ManPiNum(p->pAig) ) + Gia_ManSimInfoRandom( p, Gia_SimDataCi(p, i) ); + else + Gia_ManSimInfoZero( p, Gia_SimDataCi(p, i) ); + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimInfoTransfer( Gia_ManSim_t * p ) +{ + int iPioNum, i; + Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i ) + { + if ( iPioNum < Gia_ManPiNum(p->pAig) ) + Gia_ManSimInfoRandom( p, Gia_SimDataCi(p, i) ); + else + Gia_ManSimInfoCopy( p, Gia_SimDataCi(p, i), Gia_SimDataCo(p, Gia_ManPoNum(p->pAig)+iPioNum-Gia_ManPiNum(p->pAig)) ); + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSimulateRound( Gia_ManSim_t * p ) +{ + Gia_Obj_t * pObj; + int i, iCis = 0, iCos = 0; + assert( p->pAig->nFront > 0 ); + assert( Gia_ManConst0(p->pAig)->Value == 0 ); + Gia_ManSimInfoZero( p, Gia_SimData(p, 0) ); + Gia_ManForEachObj1( p->pAig, pObj, i ) + { + if ( Gia_ObjIsAndOrConst0(pObj) ) + { + assert( Gia_ObjValue(pObj) < p->pAig->nFront ); + Gia_ManSimulateNode( p, pObj ); + } + else if ( Gia_ObjIsCo(pObj) ) + { + assert( Gia_ObjValue(pObj) == GIA_NONE ); + Gia_ManSimulateCo( p, iCos++, pObj ); + } + else // if ( Gia_ObjIsCi(pObj) ) + { + assert( Gia_ObjValue(pObj) < p->pAig->nFront ); + Gia_ManSimulateCi( p, pObj, iCis++ ); + } + } + assert( Gia_ManCiNum(p->pAig) == iCis ); + assert( Gia_ManCoNum(p->pAig) == iCos ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSimSimulate( Gia_Man_t * pAig, Gia_ParSim_t * pPars ) +{ + Gia_ManSim_t * p; + int i, clk = clock(); + p = Gia_ManSimCreate( pAig, pPars ); + Aig_ManRandom( 1 ); + Gia_ManSimInfoInit( p ); + 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 ); + } + if ( pPars->fCheckMiter && Gia_ManCheckPos( p, &iOut, &iPat ) ) + { + assert( pAig->pSeqModel == NULL ); + pAig->pSeqModel = Gia_ManGenerateCounter( pAig, i, iOut, p->nWords, iPat, p->vCis2Ids ); + if ( pPars->fVerbose ) + printf( "Miter is satisfiable after simulation (output %d).\n", iOut ); + 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; + } +*/ + if ( i < pPars->nIters - 1 ) + Gia_ManSimInfoTransfer( p ); + } + Gia_ManSimDelete( p ); + printf( "Simulated %d frames with %d words. ", pPars->nIters, pPars->nWords ); + ABC_PRT( "Time", clock() - clk ); + return 0; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaSolver.c b/src/aig/gia/giaSolver.c new file mode 100644 index 00000000..e1f68c6f --- /dev/null +++ b/src/aig/gia/giaSolver.c @@ -0,0 +1,490 @@ +/**CFile**************************************************************** + + FileName [giaSolver.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: giaSolver.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Sat_Man_t_ Sat_Man_t; +struct Sat_Man_t_ +{ + Gia_Man_t * pGia; // the original AIG manager + Vec_Int_t * vModel; // satisfying PI assignment + int nConfs; // cur number of conflicts + int nConfsMax; // max number of conflicts + int iHead; // variable queue + int iTail; // variable queue + int iJust; // head of justification + int nTrail; // variable queue size + int pTrail[0]; // variable queue data +}; + +static inline int Sat_VarIsAssigned( Gia_Obj_t * pVar ) { return pVar->fMark0; } +static inline void Sat_VarAssign( Gia_Obj_t * pVar ) { assert(!pVar->fMark0); pVar->fMark0 = 1; } +static inline void Sat_VarUnassign( Gia_Obj_t * pVar ) { assert(pVar->fMark0); pVar->fMark0 = 0; } +static inline int Sat_VarValue( Gia_Obj_t * pVar ) { assert(pVar->fMark0); return pVar->fMark1; } +static inline void Sat_VarSetValue( Gia_Obj_t * pVar, int v ) { assert(pVar->fMark0); pVar->fMark1 = v; } + +extern void Cec_ManPatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vPat ); +extern void Cec_ManPatCleanMark0( Gia_Man_t * p, Gia_Obj_t * pObj ); + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Sat_Man_t * Sat_ManCreate( Gia_Man_t * pGia ) +{ + Sat_Man_t * p; + p = (Sat_Man_t *)ABC_ALLOC( char, sizeof(Sat_Man_t) + sizeof(int)*Gia_ManObjNum(pGia) ); + memset( p, 0, sizeof(Sat_Man_t) ); + p->pGia = pGia; + p->nTrail = Gia_ManObjNum(pGia); + p->vModel = Vec_IntAlloc( 1000 ); + return p; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Sat_ManDelete( Sat_Man_t * p ) +{ + Vec_IntFree( p->vModel ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Sat_ManCancelUntil( Sat_Man_t * p, int iBound ) +{ + Gia_Obj_t * pVar; + int i; + for ( i = p->iTail-1; i >= iBound; i-- ) + { + pVar = Gia_ManObj( p->pGia, p->pTrail[i] ); + Sat_VarUnassign( pVar ); + } + p->iTail = p->iTail = iBound; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Sat_ManDeriveModel( Sat_Man_t * p ) +{ + Gia_Obj_t * pVar; + int i; + Vec_IntClear( p->vModel ); + for ( i = 0; i < p->iTail; i++ ) + { + pVar = Gia_ManObj( p->pGia, p->pTrail[i] ); + if ( Gia_ObjIsCi(pVar) ) + Vec_IntPush( p->vModel, Gia_ObjCioId(pVar) ); + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Sat_ManEnqueue( Sat_Man_t * p, Gia_Obj_t * pVar, int Value ) +{ + assert( p->iTail < p->nTrail ); + Sat_VarAssign( pVar ); + Sat_VarSetValue( pVar, Value ); + p->pTrail[p->iTail++] = Gia_ObjId(p->pGia, pVar); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Sat_ManAssume( Sat_Man_t * p, Gia_Obj_t * pVar, int Value ) +{ + assert( p->iHead == p->iTail ); + Sat_ManEnqueue( p, pVar, Value ); +} + +/**Function************************************************************* + + Synopsis [Propagates one assignment.] + + Description [Returns 1 if there is no conflict, 0 otherwise.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Sat_ManPropagateOne( Sat_Man_t * p, int iPos ) +{ + Gia_Obj_t * pVar, * pFan0, * pFan1; + pVar = Gia_ManObj( p->pGia, p->pTrail[iPos] ); + if ( Gia_ObjIsCi(pVar) ) + return 1; + pFan0 = Gia_ObjFanin0(pVar); + pFan1 = Gia_ObjFanin1(pVar); + if ( Sat_VarValue(pVar) ) // positive + { + if ( Sat_VarIsAssigned(pFan0) ) + { + if ( Sat_VarValue(pFan0) == Gia_ObjFaninC0(pVar) ) // negative -> conflict + return 0; + // check second var + if ( Sat_VarIsAssigned(pFan1) ) + { + if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> conflict + return 0; + // positive + positive -> nothing to do + return 1; + } + } + else + { + // pFan0 unassigned -> enqueue first var + Sat_ManEnqueue( p, pFan0, !Gia_ObjFaninC0(pVar) ); + // check second var + if ( Sat_VarIsAssigned(pFan1) ) + { + if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> conflict + return 0; + // positive + positive -> nothing to do + return 1; + } + } + // unassigned -> enqueue second var + Sat_ManEnqueue( p, pFan1, !Gia_ObjFaninC1(pVar) ); + } + else // negative + { + if ( Sat_VarIsAssigned(pFan0) ) + { + if ( Sat_VarValue(pFan0) == Gia_ObjFaninC0(pVar) ) // negative -> nothing to do + return 1; + if ( Sat_VarIsAssigned(pFan1) ) + { + if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> nothing to do + return 1; + // positive + positive -> conflict + return 0; + } + // positive + unassigned -> enqueue second var + Sat_ManEnqueue( p, pFan1, Gia_ObjFaninC1(pVar) ); + } + else + { + if ( Sat_VarIsAssigned(pFan1) ) + { + if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> nothing to do + return 1; + // unassigned + positive -> enqueue first var + Sat_ManEnqueue( p, pFan0, Gia_ObjFaninC0(pVar) ); + } + } + } + return 1; +} + +/**Function************************************************************* + + Synopsis [Propagates assignments.] + + Description [Returns 1 if there is no conflict.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Sat_ManPropagate( Sat_Man_t * p ) +{ + assert( p->iHead <= p->iTail ); + for ( ; p->iHead < p->iTail; p->iHead++ ) + if ( !Sat_ManPropagateOne( p, p->pTrail[p->iHead] ) ) + return 0; + return 1; +} + +/**Function************************************************************* + + Synopsis [Propagates one assignment.] + + Description [Returns 1 if justified, 0 if conflict, -1 if needs justification.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Sat_ManJustifyNextOne( Sat_Man_t * p, int iPos ) +{ + Gia_Obj_t * pVar, * pFan0, * pFan1; + pVar = Gia_ManObj( p->pGia, p->pTrail[iPos] ); + if ( Gia_ObjIsCi(pVar) ) + return 1; + pFan0 = Gia_ObjFanin0(pVar); + pFan1 = Gia_ObjFanin1(pVar); + if ( Sat_VarValue(pVar) ) // positive + return 1; + // nevative + if ( Sat_VarIsAssigned(pFan0) ) + { + if ( Sat_VarValue(pFan0) == Gia_ObjFaninC0(pVar) ) // negative -> already justified + return 1; + // positive + if ( Sat_VarIsAssigned(pFan1) ) + { + if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> already justified + return 1; + // positive -> conflict + return 0; + } + // unasigned -> propagate + Sat_ManAssume( p, pFan1, Gia_ObjFaninC1(pVar) ); + return Sat_ManPropagate(p); + } + if ( Sat_VarIsAssigned(pFan1) ) + { + if ( Sat_VarValue(pFan1) == Gia_ObjFaninC1(pVar) ) // negative -> already justified + return 1; + // positive + assert( !Sat_VarIsAssigned(pFan0) ); + // unasigned -> propagate + Sat_ManAssume( p, pFan0, Gia_ObjFaninC0(pVar) ); + return Sat_ManPropagate(p); + } + return -1; +} + +/**Function************************************************************* + + Synopsis [Justifies assignments.] + + Description [Returns 1 for UNSAT, 0 for SAT, -1 for UNDECIDED.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Sat_ManJustify( Sat_Man_t * p ) +{ + Gia_Obj_t * pVar, * pFan0, * pFan1; + int RetValue, iState, iJustState; + if ( p->nConfs && p->nConfs >= p->nConfsMax ) + return -1; + // get the next variable to justify + assert( p->iJust <= p->iTail ); + iJustState = p->iJust; + for ( ; p->iJust < p->iTail; p->iJust++ ) + { + RetValue = Sat_ManJustifyNextOne( p, p->pTrail[p->iJust] ); + if ( RetValue == 0 ) + return 1; + if ( RetValue == -1 ) + break; + } + if ( p->iJust == p->iTail ) // could not find + return 0; + // found variable to justify + pVar = Gia_ManObj( p->pGia, p->pTrail[p->iJust] ); + pFan0 = Gia_ObjFanin0(pVar); + pFan1 = Gia_ObjFanin1(pVar); + assert( !Sat_VarValue(pVar) && !Sat_VarIsAssigned(pFan0) && !Sat_VarIsAssigned(pFan1) ); + // remember the state of the stack + iState = p->iHead; + // try to justify by setting first fanin to 0 + Sat_ManAssume( p, pFan0, Gia_ObjFaninC0(pVar) ); + if ( Sat_ManPropagate(p) ) + { + RetValue = Sat_ManJustify(p); + if ( RetValue != 1 ) + return RetValue; + } + Sat_ManCancelUntil( p, iState ); + // try to justify by setting second fanin to 0 + Sat_ManAssume( p, pFan1, Gia_ObjFaninC1(pVar) ); + if ( Sat_ManPropagate(p) ) + { + RetValue = Sat_ManJustify(p); + if ( RetValue != 1 ) + return RetValue; + } + Sat_ManCancelUntil( p, iState ); + p->iJust = iJustState; + p->nConfs++; + return 1; +} + +/**Function************************************************************* + + Synopsis [Runs one call to the SAT solver.] + + Description [Returns 1 for UNSAT, 0 for SAT, -1 for UNDECIDED.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Sat_ManPrepare( Sat_Man_t * p, int * pLits, int nLits, int nConfsMax ) +{ + Gia_Obj_t * pVar; + int i; + // double check that vars are unassigned + Gia_ManForEachObj( p->pGia, pVar, i ) + assert( !Sat_VarIsAssigned(pVar) ); + // prepare + p->iHead = p->iTail = p->iJust = 0; + p->nConfsMax = nConfsMax; + // assign literals + for ( i = 0; i < nLits; i++ ) + { + pVar = Gia_ManObj( p->pGia, Gia_Lit2Var(pLits[i]) ); + if ( Sat_VarIsAssigned(pVar) ) // assigned + { + if ( Sat_VarValue(pVar) != Gia_LitIsCompl(pLits[i]) ) // compatible assignment + continue; + } + else // unassigned + { + Sat_ManAssume( p, pVar, !Gia_LitIsCompl(pLits[i]) ); + if ( Sat_ManPropagate(p) ) + continue; + } + // conflict + Sat_ManCancelUntil( p, 0 ); + return 1; + } + assert( p->iHead == p->iTail ); + return 0; +} + + +/**Function************************************************************* + + Synopsis [Runs one call to the SAT solver.] + + Description [Returns 1 for UNSAT, 0 for SAT, -1 for UNDECIDED.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Sat_ManSolve( Sat_Man_t * p, int * pLits, int nLits, int nConfsMax ) +{ + int RetValue; + // propagate the assignments + if ( Sat_ManPrepare( p, pLits, nLits, nConfsMax ) ) + return 1; + // justify the assignments + RetValue = Sat_ManJustify( p ); + if ( RetValue == 0 ) // SAT + Sat_ManDeriveModel( p ); + // return the solver to the initial state + Sat_ManCancelUntil( p, 0 ); + return RetValue; +} + +/**Function************************************************************* + + Synopsis [Testing the SAT solver.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Sat_ManTest( Gia_Man_t * pGia, Gia_Obj_t * pObj, int nConfsMax ) +{ + Sat_Man_t * p; + int RetValue, iLit; + assert( Gia_ObjIsCo(pObj) ); + p = Sat_ManCreate( pGia ); + iLit = Gia_LitNot( Gia_ObjFaninLit0p(pGia, pObj) ); + RetValue = Sat_ManSolve( p, &iLit, 1, nConfsMax ); + if ( RetValue == 0 ) + { + Cec_ManPatVerifyPattern( pGia, pObj, p->vModel ); + Cec_ManPatCleanMark0( pGia, pObj ); + } + Sat_ManDelete( p ); + return RetValue; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaSolver_cnf.c b/src/aig/gia/giaSolver_cnf.c new file mode 100644 index 00000000..12f6895a --- /dev/null +++ b/src/aig/gia/giaSolver_cnf.c @@ -0,0 +1,103 @@ +/**CFile**************************************************************** + + FileName [giaSolver.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: giaSolver.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Sat_Cla_t_ Sat_Cla_t; +struct Sat_Cla_t_ +{ + unsigned hWatch0; // watched list for 0 literal + unsigned hWatch1; // watched list for 1 literal + int Activity; // activity of the clause + int nLits; // the number of literals + int pLits[0]; // the array of literals +}; + +typedef struct Sat_Fan_t_ Sat_Fan_t; +struct Sat_Fan_t_ +{ + unsigned iFan : 31; // ID of the fanin/fanout + unsigned fCompl : 1; // complemented attribute +}; + +typedef struct Sat_Obj_t_ Sat_Obj_t; +struct Sat_Obj_t_ +{ + unsigned hHandle; // node handle + unsigned fAssign : 1; // terminal node (CI/CO) + unsigned fValue : 1; // value under 000 pattern + unsigned fMark0 : 1; // first user-controlled mark + unsigned fMark1 : 1; // second user-controlled mark + unsigned nFanouuts : 28; // the number of fanouts + unsigned nFanins : 8; // the number of fanins + unsigned Level : 24; // logic level + unsigned hNext; // next one on this level + unsigned hWatch0; // watched list for 0 literal + unsigned hWatch1; // watched list for 1 literal + unsigned hReason; // reason for this variable + unsigned Depth; // decision depth + Sat_Fan_t Fanios[0]; // the array of fanins/fanouts +}; + +typedef struct Sat_Man_t_ Sat_Man_t; +struct Sat_Man_t_ +{ + Gia_Man_t * pGia; // the original AIG manager + // circuit + Vec_Int_t vCis; // the vector of CIs (PIs + LOs) + Vec_Int_t vObjs; // the vector of objects + // learned clauses + Vec_Int_t vClauses; // the vector of clauses + // solver data + Vec_Int_t vTrail; // variable queue + Vec_Int_t vTrailLim; // pointer into the trail + int iHead; // variable queue + int iTail; // variable queue + int iRootLevel; // first decision + // levelized order + int iLevelTop; // the largest unassigned level + Vec_Int_t vLevels; // the linked lists of levels +}; + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaSwitch.c b/src/aig/gia/giaSwitch.c new file mode 100644 index 00000000..71aefec3 --- /dev/null +++ b/src/aig/gia/giaSwitch.c @@ -0,0 +1,673 @@ +/**CFile**************************************************************** + + FileName [giaSwitch.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Computing switching activity.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaSwitch.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +// switching estimation parameters +typedef struct Gia_ParSwi_t_ Gia_ParSwi_t; +struct Gia_ParSwi_t_ +{ + // user-controlled parameters + int nWords; // the number of machine words + int nIters; // the number of timeframes + int nPref; // the number of first timeframes to skip + int nRandPiFactor; // PI trans prob (-1=3/8; 0=1/2; 1=1/4; 2=1/8, etc) + int fProbOne; // collect probability of one + int fProbTrans; // collect probatility of Swiing + int fVerbose; // enables verbose output +}; + +typedef struct Gia_ManSwi_t_ Gia_ManSwi_t; +struct Gia_ManSwi_t_ +{ + Gia_Man_t * pAig; + Gia_ParSwi_t * pPars; + int nWords; + // simulation information + unsigned * pDataSim; // simulation data + unsigned * pDataSimCis; // simulation data for CIs + unsigned * pDataSimCos; // simulation data for COs + int * pData1; // switching data +}; + +static inline unsigned * Gia_SwiData( Gia_ManSwi_t * p, int i ) { return p->pDataSim + i * p->nWords; } +static inline unsigned * Gia_SwiDataCi( Gia_ManSwi_t * p, int i ) { return p->pDataSimCis + i * p->nWords; } +static inline unsigned * Gia_SwiDataCo( Gia_ManSwi_t * p, int i ) { return p->pDataSimCos + i * p->nWords; } + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [This procedure sets default parameters.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSetDefaultParamsSwi( Gia_ParSwi_t * p ) +{ + memset( p, 0, sizeof(Gia_ParSwi_t) ); + p->nWords = 1; // the number of machine words of simulatation data + p->nIters = 48; // the number of all timeframes to simulate + p->nPref = 16; // the number of first timeframes to skip when computing switching + p->nRandPiFactor = 2; // primary input transition probability (-1=3/8; 0=1/2; 1=1/4; 2=1/8, etc) + p->fProbOne = 0; // compute probability of signal being one (if 0, compute probability of switching) + p->fProbTrans = 1; // compute signal transition probability (if 0, compute transition probability using probability of being one) + p->fVerbose = 1; // enables verbose output +} + +/**Function************************************************************* + + Synopsis [Creates fast simulation manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_ManSwi_t * Gia_ManSwiCreate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars ) +{ + Gia_ManSwi_t * p; + p = ABC_ALLOC( Gia_ManSwi_t, 1 ); + memset( p, 0, sizeof(Gia_ManSwi_t) ); + p->pAig = Gia_ManFront( pAig ); + p->pPars = pPars; + p->nWords = pPars->nWords; + 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) ); + p->pData1 = ABC_CALLOC( int, Gia_ManObjNum(pAig) ); + return p; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSwiDelete( Gia_ManSwi_t * p ) +{ + Gia_ManStop( p->pAig ); + ABC_FREE( p->pData1 ); + ABC_FREE( p->pDataSim ); + ABC_FREE( p->pDataSimCis ); + ABC_FREE( p->pDataSimCos ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoRandom( Gia_ManSwi_t * p, unsigned * pInfo, int nProbNum ) +{ + unsigned Mask; + int w, i; + if ( nProbNum == -1 ) + { // 3/8 = 1/4 + 1/8 + Mask = (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 )) | + (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 ) & Aig_ManRandom( 0 )); + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] ^= Mask; + } + else if ( nProbNum > 0 ) + { + Mask = Aig_ManRandom( 0 ); + for ( i = 0; i < nProbNum; i++ ) + Mask &= Aig_ManRandom( 0 ); + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] ^= Mask; + } + else if ( nProbNum == 0 ) + { + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = Aig_ManRandom( 0 ); + } + else + assert( 0 ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoRandomShift( Gia_ManSwi_t * p, unsigned * pInfo, int nProbNum ) +{ + unsigned Mask; + int w, i; + if ( nProbNum == -1 ) + { // 3/8 = 1/4 + 1/8 + Mask = (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 )) | + (Aig_ManRandom( 0 ) & Aig_ManRandom( 0 ) & Aig_ManRandom( 0 )); + } + else if ( nProbNum >= 0 ) + { + Mask = Aig_ManRandom( 0 ); + for ( i = 0; i < nProbNum; i++ ) + Mask &= Aig_ManRandom( 0 ); + } + else + assert( 0 ); + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = (pInfo[w] << 16) | ((pInfo[w] ^ Mask) & 0xffff); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoZero( Gia_ManSwi_t * p, unsigned * pInfo ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = 0; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoOne( Gia_ManSwi_t * p, unsigned * pInfo ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~0; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoCopy( Gia_ManSwi_t * p, unsigned * pInfo, unsigned * pInfo0 ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w]; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoCopyShift( Gia_ManSwi_t * p, unsigned * pInfo, unsigned * pInfo0 ) +{ + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = (pInfo[w] << 16) | (pInfo0[w] & 0xffff); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimulateCi( Gia_ManSwi_t * p, Gia_Obj_t * pObj, int iCi ) +{ + unsigned * pInfo = Gia_SwiData( p, Gia_ObjValue(pObj) ); + unsigned * pInfo0 = Gia_SwiDataCi( p, iCi ); + int w; + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w]; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimulateCo( Gia_ManSwi_t * p, int iCo, Gia_Obj_t * pObj ) +{ + unsigned * pInfo = Gia_SwiDataCo( p, iCo ); + unsigned * pInfo0 = Gia_SwiData( p, Gia_ObjDiff0(pObj) ); + int w; + if ( Gia_ObjFaninC0(pObj) ) + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~pInfo0[w]; + else + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w]; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimulateNode( Gia_ManSwi_t * p, Gia_Obj_t * pObj ) +{ + unsigned * pInfo = Gia_SwiData( p, Gia_ObjValue(pObj) ); + unsigned * pInfo0 = Gia_SwiData( p, Gia_ObjDiff0(pObj) ); + unsigned * pInfo1 = Gia_SwiData( p, Gia_ObjDiff1(pObj) ); + int w; + if ( Gia_ObjFaninC0(pObj) ) + { + if ( Gia_ObjFaninC1(pObj) ) + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~(pInfo0[w] | pInfo1[w]); + else + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = ~pInfo0[w] & pInfo1[w]; + } + else + { + if ( Gia_ObjFaninC1(pObj) ) + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w] & ~pInfo1[w]; + else + for ( w = p->nWords-1; w >= 0; w-- ) + pInfo[w] = pInfo0[w] & pInfo1[w]; + } +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoInit( Gia_ManSwi_t * p ) +{ + int i = 0; + for ( ; i < Gia_ManPiNum(p->pAig); i++ ) + Gia_ManSwiSimInfoRandom( p, Gia_SwiDataCi(p, i), 0 ); + for ( ; i < Gia_ManCiNum(p->pAig); i++ ) + Gia_ManSwiSimInfoZero( p, Gia_SwiDataCi(p, i) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoTransfer( Gia_ManSwi_t * p, int nProbNum ) +{ + int i = 0, nShift = Gia_ManPoNum(p->pAig)-Gia_ManPiNum(p->pAig); + for ( ; i < Gia_ManPiNum(p->pAig); i++ ) + Gia_ManSwiSimInfoRandom( p, Gia_SwiDataCi(p, i), nProbNum ); + for ( ; i < Gia_ManCiNum(p->pAig); i++ ) + Gia_ManSwiSimInfoCopy( p, Gia_SwiDataCi(p, i), Gia_SwiDataCo(p, nShift+i) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimInfoTransferShift( Gia_ManSwi_t * p, int nProbNum ) +{ + int i = 0, nShift = Gia_ManPoNum(p->pAig)-Gia_ManPiNum(p->pAig); + for ( ; i < Gia_ManPiNum(p->pAig); i++ ) + Gia_ManSwiSimInfoRandomShift( p, Gia_SwiDataCi(p, i), nProbNum ); + for ( ; i < Gia_ManCiNum(p->pAig); i++ ) + Gia_ManSwiSimInfoCopyShift( p, Gia_SwiDataCi(p, i), Gia_SwiDataCo(p, nShift+i) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Gia_ManSwiSimInfoCountOnes( Gia_ManSwi_t * p, int iPlace ) +{ + unsigned * pInfo; + int w, Counter = 0; + pInfo = Gia_SwiData( p, iPlace ); + for ( w = p->nWords-1; w >= 0; w-- ) + Counter += Aig_WordCountOnes( pInfo[w] ); + return Counter; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Gia_ManSwiSimInfoCountTrans( Gia_ManSwi_t * p, int iPlace ) +{ + unsigned * pInfo; + int w, Counter = 0; + pInfo = Gia_SwiData( p, iPlace ); + for ( w = p->nWords-1; w >= 0; w-- ) + Counter += 2*Aig_WordCountOnes( (pInfo[w] ^ (pInfo[w] >> 16)) & 0xffff ); + return Counter; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManSwiSimulateRound( Gia_ManSwi_t * p, int fCount ) +{ + Gia_Obj_t * pObj; + int i, iCis = 0, iCos = 0; + assert( p->pAig->nFront > 0 ); + assert( Gia_ManConst0(p->pAig)->Value == 0 ); + Gia_ManSwiSimInfoZero( p, Gia_SwiData(p, 0) ); + Gia_ManForEachObj1( p->pAig, pObj, i ) + { + if ( Gia_ObjIsAndOrConst0(pObj) ) + { + assert( Gia_ObjValue(pObj) < p->pAig->nFront ); + Gia_ManSwiSimulateNode( p, pObj ); + } + else if ( Gia_ObjIsCo(pObj) ) + { + assert( Gia_ObjValue(pObj) == GIA_NONE ); + Gia_ManSwiSimulateCo( p, iCos++, pObj ); + } + else // if ( Gia_ObjIsCi(pObj) ) + { + assert( Gia_ObjValue(pObj) < p->pAig->nFront ); + Gia_ManSwiSimulateCi( p, pObj, iCis++ ); + } + if ( fCount && !Gia_ObjIsCo(pObj) ) + { + if ( p->pPars->fProbTrans ) + p->pData1[i] += Gia_ManSwiSimInfoCountTrans( p, Gia_ObjValue(pObj) ); + else + p->pData1[i] += Gia_ManSwiSimInfoCountOnes( p, Gia_ObjValue(pObj) ); + } + } + assert( Gia_ManCiNum(p->pAig) == iCis ); + assert( Gia_ManCoNum(p->pAig) == iCos ); +} + +/**Function************************************************************* + + Synopsis [Computes switching activity of one node.] + + Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float Gia_ManSwiComputeSwitching( int nOnes, int nSimWords ) +{ + int nTotal = 32 * nSimWords; + return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal; +} + +/**Function************************************************************* + + Synopsis [Computes switching activity of one node.] + + Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float Gia_ManSwiComputeProbOne( int nOnes, int nSimWords ) +{ + int nTotal = 32 * nSimWords; + return (float)nOnes / nTotal; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Gia_ManSwiSimulate( Gia_Man_t * pAig, Gia_ParSwi_t * pPars ) +{ + Gia_ManSwi_t * p; + Gia_Obj_t * pObj; + Vec_Int_t * vSwitching; + float * pSwitching; + int i, clk, clkTotal = clock(); + if ( pPars->fProbOne && pPars->fProbTrans ) + printf( "Conflict of options: Can either compute probability of 1, or probability of switching by observing transitions.\n" ); + // create manager + clk = clock(); + p = Gia_ManSwiCreate( pAig, pPars ); + if ( pPars->fVerbose ) + { + printf( "Obj = %8d (%8d). F = %6d. ", + pAig->nObjs, Gia_ManCiNum(pAig) + Gia_ManAndNum(pAig), p->pAig->nFront, + 4.0*Aig_BitWordNum(2 * p->pAig->nFront)/(1<<20) ); + printf( "AIG = %7.2f Mb. F-mem = %7.2f Mb. Other = %7.2f Mb. ", + 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) ); + ABC_PRT( "Time", clock() - clk ); + } + // perform simulation + Aig_ManRandom( 1 ); + Gia_ManSwiSimInfoInit( p ); + for ( i = 0; i < pPars->nIters; i++ ) + { + Gia_ManSwiSimulateRound( p, i >= pPars->nPref ); + if ( i == pPars->nIters - 1 ) + break; + if ( pPars->fProbTrans ) + Gia_ManSwiSimInfoTransferShift( p, pPars->nRandPiFactor ); + else + Gia_ManSwiSimInfoTransfer( p, pPars->nRandPiFactor ); + } + if ( pPars->fVerbose ) + { + printf( "Simulated %d frames with %d words. ", pPars->nIters, pPars->nWords ); + ABC_PRT( "Simulation time", clock() - clkTotal ); + } + // derive the result + vSwitching = Vec_IntStart( Gia_ManObjNum(pAig) ); + pSwitching = (float *)vSwitching->pArray; + if ( pPars->fProbOne ) + { + Gia_ManForEachObj( pAig, pObj, i ) + pSwitching[i] = Gia_ManSwiComputeProbOne( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) ); + } + else if ( pPars->fProbTrans ) + { + Gia_ManForEachObj( pAig, pObj, i ) + pSwitching[i] = Gia_ManSwiComputeProbOne( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) ); + } + else + { + Gia_ManForEachObj( pAig, pObj, i ) + pSwitching[i] = Gia_ManSwiComputeSwitching( p->pData1[i], pPars->nWords*(pPars->nIters-pPars->nPref) ); + } + Gia_ManSwiDelete( p ); + return vSwitching; + +} + +/**Function************************************************************* + + Synopsis [Computes probability of switching (or of being 1).] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +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; + Aig_Obj_t * pObj; + int i; + // set the default parameters + Gia_ManSetDefaultParamsSwi( pPars ); + // override some of the defaults + pPars->nWords = 10; // set number machine words to simulate + pPars->nIters = nFrames; // set number of total timeframes + if ( Abc_FrameReadFlag("seqsimframes") ) + pPars->nIters = atoi( Abc_FrameReadFlag("seqsimframes") ); + pPars->nPref = nPref; // set number of first timeframes to skip + pPars->fVerbose = 0; // disable verbose output + // decide what should be computed + if ( fProbOne ) + { + // if the user asked to compute propability of 1, we do not need transition information + pPars->fProbOne = 1; // enable computing probabiblity of being one + pPars->fProbTrans = 0; // disable computing transition probability + } + else + { + // if the user asked for transition propabability, we do not need to compute probability of 1 + pPars->fProbOne = 0; // disable computing probabiblity of being one + pPars->fProbTrans = 1; // enable computing transition probability + } + // translate AIG into the intermediate form (takes care of choices if present!) + p = Gia_ManFromAigSwitch( pAig ); + // perform the computation of switching activity + vSwitching = Gia_ManSwiSimulate( p, pPars ); + // transfer the computed result to the original AIG + vResult = Vec_IntStart( Aig_ManObjNumMax(pAig) ); + Aig_ManForEachObj( pAig, pObj, i ) + Vec_IntWriteEntry( vResult, i, Vec_IntEntry(vSwitching, Gia_Lit2Var(pObj->iData)) ); + // delete intermediate results + Vec_IntFree( vSwitching ); + Gia_ManStop( p ); + return vResult; +} + + //////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaTsim.c b/src/aig/gia/giaTsim.c new file mode 100644 index 00000000..c7aac864 --- /dev/null +++ b/src/aig/gia/giaTsim.c @@ -0,0 +1,708 @@ +/**CFile**************************************************************** + + FileName [giaTsim.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Ternary simulation.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaTsim.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +static inline int Gia_ManTerSimInfoGet( unsigned * pInfo, int i ) +{ + return 3 & (pInfo[i >> 4] >> ((i & 15) << 1)); +} +static inline void Gia_ManTerSimInfoSet( unsigned * pInfo, int i, int Value ) +{ + assert( Value >= GIA_ZER && Value <= GIA_UND ); + Value ^= Gia_ManTerSimInfoGet( pInfo, i ); + pInfo[i >> 4] ^= (Value << ((i & 15) << 1)); +} + +static inline unsigned * Gia_ManTerStateNext( unsigned * pState, int nWords ) { return *((unsigned **)(pState + nWords)); } +static inline void Gia_ManTerStateSetNext( unsigned * pState, int nWords, unsigned * pNext ) { *((unsigned **)(pState + nWords)) = pNext; } + +// ternary simulation manager +typedef struct Gia_ManTer_t_ Gia_ManTer_t; +struct Gia_ManTer_t_ +{ + Gia_Man_t * pAig; + int nIters; + int nStateWords; + Vec_Ptr_t * vStates; + Vec_Ptr_t * vFlops; + int * pCount0; + int * pCountX; + // hash table for states + int nBins; + unsigned ** pBins; + // simulation information + unsigned * pDataSim; // simulation data + unsigned * pDataSimCis; // simulation data for CIs + unsigned * pDataSimCos; // simulation data for COs +}; + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Creates fast simulation manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_ManTer_t * Gia_ManTerCreate( Gia_Man_t * pAig ) +{ + Gia_ManTer_t * p; + p = ABC_CALLOC( Gia_ManTer_t, 1 ); + p->pAig = Gia_ManFront( pAig ); + p->nIters = 300; + p->pDataSim = ABC_ALLOC( unsigned, Aig_BitWordNum(2*p->pAig->nFront) ); + p->pDataSimCis = ABC_ALLOC( unsigned, Aig_BitWordNum(2*Gia_ManCiNum(p->pAig)) ); + p->pDataSimCos = ABC_ALLOC( unsigned, Aig_BitWordNum(2*Gia_ManCoNum(p->pAig)) ); + // allocate storage for terminary states + p->nStateWords = Aig_BitWordNum( 2*Gia_ManRegNum(pAig) ); + p->vStates = Vec_PtrAlloc( 1000 ); + p->pCount0 = ABC_CALLOC( int, Gia_ManRegNum(pAig) ); + p->pCountX = ABC_CALLOC( int, Gia_ManRegNum(pAig) ); + p->nBins = Aig_PrimeCudd( 500 ); + p->pBins = ABC_CALLOC( unsigned *, p->nBins ); + return p; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTerStatesFree( Vec_Ptr_t * vStates ) +{ + unsigned * pTemp; + int i; + Vec_PtrForEachEntry( vStates, pTemp, i ) + ABC_FREE( pTemp ); + Vec_PtrFree( vStates ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTerDelete( Gia_ManTer_t * p ) +{ + if ( p->vStates ) + Gia_ManTerStatesFree( p->vStates ); + if ( p->vFlops ) + Gia_ManTerStatesFree( p->vFlops ); + Gia_ManStop( p->pAig ); + ABC_FREE( p->pCount0 ); + ABC_FREE( p->pCountX ); + ABC_FREE( p->pBins ); + ABC_FREE( p->pDataSim ); + ABC_FREE( p->pDataSimCis ); + ABC_FREE( p->pDataSimCos ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManTerSimulateCi( Gia_ManTer_t * p, Gia_Obj_t * pObj, int iCi ) +{ + Gia_ManTerSimInfoSet( p->pDataSim, Gia_ObjValue(pObj), Gia_ManTerSimInfoGet(p->pDataSimCis, iCi) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManTerSimulateCo( Gia_ManTer_t * p, int iCo, Gia_Obj_t * pObj ) +{ + int Value = Gia_ManTerSimInfoGet( p->pDataSim, Gia_ObjDiff0(pObj) ); + Gia_ManTerSimInfoSet( p->pDataSimCos, iCo, Gia_XsimNotCond( Value, Gia_ObjFaninC0(pObj) ) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManTerSimulateNode( Gia_ManTer_t * p, Gia_Obj_t * pObj ) +{ + int Value0 = Gia_ManTerSimInfoGet( p->pDataSim, Gia_ObjDiff0(pObj) ); + int Value1 = Gia_ManTerSimInfoGet( p->pDataSim, Gia_ObjDiff1(pObj) ); + Gia_ManTerSimInfoSet( p->pDataSim, Gia_ObjValue(pObj), Gia_XsimAndCond( Value0, Gia_ObjFaninC0(pObj), Value1, Gia_ObjFaninC1(pObj) ) ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManTerSimInfoInit( Gia_ManTer_t * p ) +{ + int i = 0; + for ( ; i < Gia_ManPiNum(p->pAig); i++ ) + Gia_ManTerSimInfoSet( p->pDataSimCis, i, GIA_UND ); + for ( ; i < Gia_ManCiNum(p->pAig); i++ ) + Gia_ManTerSimInfoSet( p->pDataSimCis, i, GIA_ZER ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManTerSimInfoTransfer( Gia_ManTer_t * p ) +{ + int i = 0; + for ( ; i < Gia_ManPiNum(p->pAig); i++ ) + Gia_ManTerSimInfoSet( p->pDataSimCis, i, GIA_UND ); + for ( ; i < Gia_ManCiNum(p->pAig); i++ ) + Gia_ManTerSimInfoSet( p->pDataSimCis, i, Gia_ManTerSimInfoGet( p->pDataSimCos, Gia_ManCoNum(p->pAig)-Gia_ManCiNum(p->pAig)+i ) ); +} + + +/**Function************************************************************* + + Synopsis [Computes hash value of the node using its simulation info.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManTerStateHash( unsigned * pState, int nWords, 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 < nWords; i++ ) + uHash ^= pState[i] * s_FPrimes[i & 0x7F]; + return uHash % nTableSize; +} + +/**Function************************************************************* + + Synopsis [Inserts value into the table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned * Gia_ManTerStateLookup( unsigned * pState, int nWords, unsigned ** pBins, int nBins ) +{ + unsigned * pEntry; + int Hash = Gia_ManTerStateHash( pState, nWords, nBins ); + for ( pEntry = pBins[Hash]; pEntry; pEntry = Gia_ManTerStateNext(pEntry, nWords) ) + if ( !memcmp( pEntry, pState, sizeof(unsigned) * nWords ) ) + return pEntry; + return NULL; +} + +/**Function************************************************************* + + Synopsis [Inserts value into the table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTerStateInsert( unsigned * pState, int nWords, unsigned ** pBins, int nBins ) +{ + int Hash = Gia_ManTerStateHash( pState, nWords, nBins ); + assert( !Gia_ManTerStateLookup( pState, nWords, pBins, nBins ) ); + Gia_ManTerStateSetNext( pState, nWords, pBins[Hash] ); + pBins[Hash] = pState; +} + +/**Function************************************************************* + + Synopsis [Allocs new ternary state.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned * Gia_ManTerStateAlloc( int nWords ) +{ + return (unsigned *)ABC_CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) ); +} + +/**Function************************************************************* + + Synopsis [Creates new ternary state.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +unsigned * Gia_ManTerStateCreate( Gia_ManTer_t * p ) +{ + int i, Value, nPis = Gia_ManPiNum(p->pAig); + unsigned * pRes = Gia_ManTerStateAlloc( p->nStateWords ); + for ( i = nPis; i < Gia_ManCiNum(p->pAig); i++ ) + { + Value = Gia_ManTerSimInfoGet( p->pDataSimCis, i ); + Gia_ManTerSimInfoSet( pRes, i-nPis, Value ); + if ( Value == GIA_ZER ) + p->pCount0[i-nPis]++; + if ( Value == GIA_UND ) + p->pCountX[i-nPis]++; + } + Vec_PtrPush( p->vStates, pRes ); + return pRes; +} + +/**Function************************************************************* + + Synopsis [Performs one round of ternary simulation.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline void Gia_ManTerSimulateRound( Gia_ManTer_t * p ) +{ + Gia_Obj_t * pObj; + int i, iCis = 0, iCos = 0; + assert( p->pAig->nFront > 0 ); + assert( Gia_ManConst0(p->pAig)->Value == 0 ); + Gia_ManTerSimInfoSet( p->pDataSim, 0, GIA_ONE ); + Gia_ManForEachObj1( p->pAig, pObj, i ) + { + if ( Gia_ObjIsAndOrConst0(pObj) ) + { + assert( Gia_ObjValue(pObj) < p->pAig->nFront ); + Gia_ManTerSimulateNode( p, pObj ); + } + else if ( Gia_ObjIsCi(pObj) ) + { + assert( Gia_ObjValue(pObj) < p->pAig->nFront ); + Gia_ManTerSimulateCi( p, pObj, iCis++ ); + } + else // if ( Gia_ObjIsCo(pObj) ) + { + assert( Gia_ObjValue(pObj) == GIA_NONE ); + Gia_ManTerSimulateCo( p, iCos++, pObj ); + } + } + assert( Gia_ManCiNum(p->pAig) == iCis ); + assert( Gia_ManCoNum(p->pAig) == iCos ); +} + +/**Function************************************************************* + + Synopsis [Retires a set of registers to speed up convergence.] + + Description [Retire all non-ternary registers which has max number + of ternary values so far.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManTerRetire( Gia_ManTer_t * p, unsigned * pState ) +{ + int i, iMaxTerValue = 0, Counter = 0; + for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ ) + if ( Gia_ManTerSimInfoGet( pState, i ) != GIA_UND && iMaxTerValue < p->pCountX[i] ) + iMaxTerValue = p->pCountX[i]; + // retire all registers with this value + for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ ) + if ( Gia_ManTerSimInfoGet( pState, i ) != GIA_UND && iMaxTerValue == p->pCountX[i] ) + { + Gia_ManTerSimInfoSet( p->pDataSimCis, Gia_ManPiNum(p->pAig)+i, GIA_UND ); + Counter++; + } + return Counter; +} + +/**Function************************************************************* + + Synopsis [Inserts value into the table.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTerStatePrint( unsigned * pState, int nRegs, int iNum ) +{ + int i, nZeros = 0, nOnes = 0, nDcs = 0; + printf( " %4d : ", iNum ); + for ( i = 0; i < nRegs; i++ ) + { + if ( Gia_ManTerSimInfoGet(pState, i) == GIA_ZER ) + printf( "0" ), nZeros++; + else if ( Gia_ManTerSimInfoGet(pState, i) == GIA_ONE ) + printf( "1" ), nOnes++; + else if ( Gia_ManTerSimInfoGet(pState, i) == GIA_UND ) + printf( "x" ), nDcs++; + else + assert( 0 ); + } + printf( " (0=%4d, 1=%4d, x=%4d)\n", nZeros, nOnes, nDcs ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTerAnalyze2( Vec_Ptr_t * vStates, int nRegs ) +{ + unsigned * pTemp, * pStates = Vec_PtrPop( vStates ); + int i, w, nZeros, nConsts, nStateWords; + // detect constant zero registers + nStateWords = Aig_BitWordNum( 2*nRegs ); + memset( pStates, 0, sizeof(int) * nStateWords ); + Vec_PtrForEachEntry( vStates, pTemp, i ) + for ( w = 0; w < nStateWords; w++ ) + pStates[w] |= pTemp[w]; + // count the number of zeros + nZeros = 0; + for ( i = 0; i < nRegs; i++ ) + if ( Gia_ManTerSimInfoGet(pStates, i) == GIA_ZER ) + nZeros++; + printf( "Found %d constant registers.\n", nZeros ); + // detect non-ternary registers + memset( pStates, 0, sizeof(int) * nStateWords ); + Vec_PtrForEachEntry( vStates, pTemp, i ) + for ( w = 0; w < nStateWords; w++ ) + pStates[w] |= (~(pTemp[w] ^ (pTemp[w] >> 1)) & 0x55555555); + // count the nonternary registers + nConsts = 0; + for ( i = 0; i < nRegs; i++ ) + if ( Gia_ManTerSimInfoGet(pStates, i) == 0 ) + nConsts++; + printf( "Found %d non-ternary registers.\n", nConsts ); + // return the state back + Vec_PtrPush( vStates, pStates ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManTerAnalyze( Gia_ManTer_t * p ) +{ + int i, nZeros = 0, nConsts = 0; + for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ ) + if ( p->pCount0[i] == Vec_PtrSize(p->vStates) ) + nZeros++; + else if ( p->pCountX[i] == 0 ) + nConsts++; + printf( "Found %d constant registers.\n", nZeros ); + printf( "Found %d non-ternary registers.\n", nConsts ); +} + + + +/**Function************************************************************* + + Synopsis [Transposes state vector for non-ternary registers.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Ptr_t * Gia_ManTerTranspose( Gia_ManTer_t * p ) +{ + Vec_Ptr_t * vFlops; + unsigned * pState, * pFlop; + int i, k, nFlopWords; + vFlops = Vec_PtrAlloc( 100 ); + nFlopWords = Aig_BitWordNum( 2*Vec_PtrSize(p->vStates) ); + for ( i = 0; i < Gia_ManRegNum(p->pAig); i++ ) + { + if ( p->pCount0[i] == Vec_PtrSize(p->vStates) ) + continue; + if ( p->pCountX[i] > 0 ) + continue; + pFlop = Gia_ManTerStateAlloc( nFlopWords ); + Vec_PtrPush( vFlops, pFlop ); + Vec_PtrForEachEntry( p->vStates, pState, k ) + Gia_ManTerSimInfoSet( pFlop, k, Gia_ManTerSimInfoGet(pState, i) ); +//Gia_ManTerStatePrint( pFlop, Vec_PtrSize(p->vStates), i ); + } + return vFlops; +} + +/**Function************************************************************* + + Synopsis [Transposes state vector for non-ternary registers.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +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 ) + if ( !memcmp( pTemp, pFlop, sizeof(unsigned) * nFlopWords ) ) + return i; + return -1; +} + +/**Function************************************************************* + + Synopsis [Creates map of registers to replace.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int * Gia_ManTerCreateMap( Gia_ManTer_t * p ) +{ + int * pCi2Lit; + Gia_Obj_t * pObj; + Vec_Int_t * vMapKtoI; + int i, iRepr, nFlopWords, Counter0 = 0, CounterE = 0; + nFlopWords = Aig_BitWordNum( 2*Vec_PtrSize(p->vStates) ); + p->vFlops = Gia_ManTerTranspose( p ); + pCi2Lit = ABC_FALLOC( unsigned, 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) ) + pCi2Lit[Gia_ManPiNum(p->pAig)+i] = 0, Counter0++; + else if ( p->pCountX[i] == 0 ) + { + iRepr = Gia_ManFindEqualFlop( p->vFlops, Vec_IntSize(vMapKtoI), nFlopWords ); + Vec_IntPush( vMapKtoI, i ); + if ( iRepr < 0 ) + continue; + pObj = Gia_ManCi( p->pAig, Gia_ManPiNum(p->pAig)+Vec_IntEntry(vMapKtoI, iRepr) ); + pCi2Lit[Gia_ManPiNum(p->pAig)+i] = Gia_Var2Lit( Gia_ObjId( p->pAig, pObj ), 0 ); + CounterE++; + } + Vec_IntFree( vMapKtoI ); + printf( "Transformed %d const registers and %d equiv registers.\n", Counter0, CounterE ); + return pCi2Lit; +} + + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_ManTer_t * Gia_ManTerSimulate( Gia_Man_t * pAig, int fVerbose ) +{ + Gia_ManTer_t * p; + unsigned * pState, * pLoop; + int i, Counter, clk, clkTotal = clock(); + assert( Gia_ManRegNum(pAig) > 0 ); + // create manager + clk = clock(); + p = Gia_ManTerCreate( pAig ); + if ( fVerbose ) + { + printf( "Obj = %8d (%8d). F = %6d. ", + pAig->nObjs, Gia_ManCiNum(pAig) + Gia_ManAndNum(pAig), p->pAig->nFront, + 4.0*Aig_BitWordNum(2 * p->pAig->nFront)/(1<<20) ); + printf( "AIG = %7.2f Mb. F-mem = %7.2f Mb. Other = %7.2f Mb. ", + 12.0*Gia_ManObjNum(p->pAig)/(1<<20), + 4.0*Aig_BitWordNum(2 * p->pAig->nFront)/(1<<20), + 4.0*Aig_BitWordNum(2 * (Gia_ManCiNum(pAig) + Gia_ManCoNum(pAig)))/(1<<20) ); + ABC_PRT( "Time", clock() - clk ); + } + // perform simulation + Gia_ManTerSimInfoInit( p ); + // hash the first state + pState = Gia_ManTerStateCreate( p ); + Gia_ManTerStateInsert( pState, p->nStateWords, p->pBins, p->nBins ); +//Gia_ManTerStatePrint( pState, Gia_ManRegNum(pAig), 0 ); + // perform simuluation till convergence + for ( i = 0; ; i++ ) + { + Gia_ManTerSimulateRound( p ); + Gia_ManTerSimInfoTransfer( p ); + pState = Gia_ManTerStateCreate( p ); +//Gia_ManTerStatePrint( pState, Gia_ManRegNum(pAig), i+1 ); + if ( (pLoop = Gia_ManTerStateLookup(pState, p->nStateWords, p->pBins, p->nBins)) ) + { + pAig->nTerStates = Vec_PtrSize( p->vStates ); + pAig->nTerLoop = Vec_PtrFind( p->vStates, pLoop ); + break; + } + Gia_ManTerStateInsert( pState, p->nStateWords, p->pBins, p->nBins ); + if ( i >= p->nIters && i % 10 == 0 ) + { + Counter = Gia_ManTerRetire( p, pState ); + if ( fVerbose ) + printf( "Retired %d registers.\n", Counter ); + } + } + if ( fVerbose ) + { + printf( "Saturated after %d iterations. ", i+1 ); + ABC_PRT( "Total time", clock() - clkTotal ); + } + return p; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManReduceConst( Gia_Man_t * pAig, int fVerbose ) +{ + Gia_ManTer_t * p; + Gia_Man_t * pNew = NULL; + int * pCi2Lit; + p = Gia_ManTerSimulate( pAig, fVerbose ); + Gia_ManTerAnalyze( p ); + pCi2Lit = Gia_ManTerCreateMap( p ); + Gia_ManTerDelete( p ); + pNew = Gia_ManDupDfsCiMap( pAig, pCi2Lit, NULL ); + ABC_FREE( pCi2Lit ); + return pNew; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c new file mode 100644 index 00000000..ef433159 --- /dev/null +++ b/src/aig/gia/giaUtil.c @@ -0,0 +1,518 @@ +/**CFile**************************************************************** + + FileName [giaUtil.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Scalable AIG package.] + + Synopsis [Various utilities.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: giaUtil.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "gia.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Sets phases of the internal nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSetMark0( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + Gia_ManForEachObj( p, pObj, i ) + pObj->fMark0 = 1; +} + +/**Function************************************************************* + + Synopsis [Sets phases of the internal nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCleanMark0( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + Gia_ManForEachObj( p, pObj, i ) + pObj->fMark0 = 0; +} + +/**Function************************************************************* + + Synopsis [Sets phases of the internal nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSetMark1( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + Gia_ManForEachObj( p, pObj, i ) + pObj->fMark1 = 1; +} + +/**Function************************************************************* + + Synopsis [Sets phases of the internal nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCleanMark1( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + Gia_ManForEachObj( p, pObj, i ) + pObj->fMark1 = 0; +} + +/**Function************************************************************* + + Synopsis [Cleans the value.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCleanValue( Gia_Man_t * p ) +{ + int i; + for ( i = 0; i < p->nObjs; i++ ) + p->pObjs[i].Value = 0; +} + +/**Function************************************************************* + + Synopsis [Cleans the value.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManFillValue( Gia_Man_t * p ) +{ + int i; + for ( i = 0; i < p->nObjs; i++ ) + p->pObjs[i].Value = ~0; +} + +/**Function************************************************************* + + Synopsis [Sets phases of the internal nodes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +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; + } +} + +/**Function************************************************************* + + Synopsis [Assigns levels.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManLevelNum( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + if ( p->pLevels ) + return p->nLevels; + p->nLevels = 0; + p->pLevels = ABC_ALLOC( int, p->nObjsAlloc ); + Gia_ManForEachObj( p, pObj, i ) + if ( Gia_ObjIsAnd(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]; + } + else if ( Gia_ObjIsCo(pObj) ) + p->pLevels[i] = p->pLevels[Gia_ObjFaninId0(pObj, i)]; + else + p->pLevels[i] = 0; + return p->nLevels; +} + +/**Function************************************************************* + + Synopsis [Assigns levels.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManSetRefs( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + Gia_ManForEachObj( p, pObj, i ) + { + pObj->Value = 0; + if ( Gia_ObjIsAnd(pObj) ) + { + Gia_ObjFanin0(pObj)->Value++; + Gia_ObjFanin1(pObj)->Value++; + } + else if ( Gia_ObjIsCo(pObj) ) + Gia_ObjFanin0(pObj)->Value++; + } +} + +/**Function************************************************************* + + Synopsis [Assigns references.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManCreateRefs( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i; + assert( p->pRefs == NULL ); + p->pRefs = ABC_CALLOC( int, Gia_ManObjNum(p) ); + Gia_ManForEachObj( p, pObj, i ) + { + if ( Gia_ObjIsAnd(pObj) ) + { + Gia_ObjRefFanin0Inc( p, pObj ); + Gia_ObjRefFanin1Inc( p, pObj ); + } + else if ( Gia_ObjIsCo(pObj) ) + Gia_ObjRefFanin0Inc( p, pObj ); + } +} + +/**Function************************************************************* + + Synopsis [Computes the maximum frontier size.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManCrossCut( Gia_Man_t * p ) +{ + Gia_Obj_t * pObj; + int i, nCutCur = 0, nCutMax = 0; + Gia_ManSetRefs( p ); + Gia_ManForEachObj( p, pObj, i ) + { + if ( pObj->Value ) + nCutCur++; + if ( nCutMax < nCutCur ) + nCutMax = nCutCur; + if ( Gia_ObjIsAnd(pObj) ) + { + if ( --Gia_ObjFanin0(pObj)->Value == 0 ) + nCutCur--; + if ( --Gia_ObjFanin1(pObj)->Value == 0 ) + nCutCur--; + } + else if ( Gia_ObjIsCo(pObj) ) + { + if ( --Gia_ObjFanin0(pObj)->Value == 0 ) + nCutCur--; + } + } +// Gia_ManForEachObj( p, pObj, i ) +// assert( pObj->Value == 0 ); + return nCutMax; +} + +/**Function************************************************************* + + Synopsis [Makes sure the manager is normalized.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManIsNormalized( Gia_Man_t * p ) +{ + int i, nOffset; + nOffset = 1; + for ( i = 0; i < Gia_ManCiNum(p); i++ ) + if ( !Gia_ObjIsCi( Gia_ManObj(p, nOffset+i) ) ) + return 0; + nOffset = 1 + Gia_ManCiNum(p) + Gia_ManAndNum(p); + for ( i = 0; i < Gia_ManCoNum(p); i++ ) + if ( !Gia_ObjIsCo( Gia_ManObj(p, nOffset+i) ) ) + return 0; + return 1; +} + + +/**Function************************************************************* + + Synopsis [Collects PO Ids into one array.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Gia_ManCollectPoIds( Gia_Man_t * p ) +{ + Vec_Int_t * vStart; + int Entry, i; + vStart = Vec_IntAlloc( Gia_ManPoNum(p) ); + Vec_IntForEachEntryStop( p->vCos, Entry, i, Gia_ManPoNum(p) ) + Vec_IntPush( vStart, Entry ); + return vStart; +} + + +/**Function************************************************************* + + Synopsis [Returns 1 if the node is the root of MUX or EXOR/NEXOR.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ObjIsMuxType( Gia_Obj_t * pNode ) +{ + Gia_Obj_t * pNode0, * pNode1; + // check that the node is regular + assert( !Gia_IsComplement(pNode) ); + // if the node is not AND, this is not MUX + if ( !Gia_ObjIsAnd(pNode) ) + return 0; + // if the children are not complemented, this is not MUX + if ( !Gia_ObjFaninC0(pNode) || !Gia_ObjFaninC1(pNode) ) + return 0; + // get children + pNode0 = Gia_ObjFanin0(pNode); + pNode1 = Gia_ObjFanin1(pNode); + // if the children are not ANDs, this is not MUX + if ( !Gia_ObjIsAnd(pNode0) || !Gia_ObjIsAnd(pNode1) ) + return 0; + // otherwise the node is MUX iff it has a pair of equal grandchildren + return (Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1))) || + (Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1))) || + (Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1))) || + (Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1))); +} + + +/**Function************************************************************* + + Synopsis [Recognizes what nodes are inputs of the EXOR.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ObjRecognizeExor( Gia_Obj_t * pObj, Gia_Obj_t ** ppFan0, Gia_Obj_t ** ppFan1 ) +{ + Gia_Obj_t * p0, * p1; + assert( !Gia_IsComplement(pObj) ); + if ( !Gia_ObjIsAnd(pObj) ) + return 0; + assert( Gia_ObjIsAnd(pObj) ); + p0 = Gia_ObjChild0(pObj); + p1 = Gia_ObjChild1(pObj); + if ( !Gia_IsComplement(p0) || !Gia_IsComplement(p1) ) + return 0; + p0 = Gia_Regular(p0); + p1 = Gia_Regular(p1); + if ( !Gia_ObjIsAnd(p0) || !Gia_ObjIsAnd(p1) ) + return 0; + if ( Gia_ObjFanin0(p0) != Gia_ObjFanin0(p1) || Gia_ObjFanin1(p0) != Gia_ObjFanin1(p1) ) + return 0; + if ( Gia_ObjFaninC0(p0) == Gia_ObjFaninC0(p1) || Gia_ObjFaninC1(p0) == Gia_ObjFaninC1(p1) ) + return 0; + *ppFan0 = Gia_ObjChild0(p0); + *ppFan1 = Gia_ObjChild1(p0); + return 1; +} + +/**Function************************************************************* + + Synopsis [Recognizes what nodes are control and data inputs of a MUX.] + + Description [If the node is a MUX, returns the control variable C. + Assigns nodes T and E to be the then and else variables of the MUX. + Node C is never complemented. Nodes T and E can be complemented. + This function also recognizes EXOR/NEXOR gates as MUXes.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Obj_t * Gia_ObjRecognizeMux( Gia_Obj_t * pNode, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE ) +{ + Gia_Obj_t * pNode0, * pNode1; + assert( !Gia_IsComplement(pNode) ); + assert( Gia_ObjIsMuxType(pNode) ); + // get children + pNode0 = Gia_ObjFanin0(pNode); + pNode1 = Gia_ObjFanin1(pNode); + + // find the control variable + if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC1(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p2) ) + if ( Gia_ObjFaninC1(pNode0) ) + { // pNode2->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + return Gia_ObjChild1(pNode1);//pNode2->p2; + } + else + { // pNode1->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + return Gia_ObjChild1(pNode0);//pNode1->p2; + } + } + else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC0(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p1) ) + if ( Gia_ObjFaninC0(pNode0) ) + { // pNode2->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + return Gia_ObjChild0(pNode1);//pNode2->p1; + } + else + { // pNode1->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + return Gia_ObjChild0(pNode0);//pNode1->p1; + } + } + else if ( Gia_ObjFanin0(pNode0) == Gia_ObjFanin1(pNode1) && (Gia_ObjFaninC0(pNode0) ^ Gia_ObjFaninC1(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p1) ) + if ( Gia_ObjFaninC0(pNode0) ) + { // pNode2->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + return Gia_ObjChild1(pNode1);//pNode2->p2; + } + else + { // pNode1->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode0));//pNode1->p2); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode1));//pNode2->p1); + return Gia_ObjChild0(pNode0);//pNode1->p1; + } + } + else if ( Gia_ObjFanin1(pNode0) == Gia_ObjFanin0(pNode1) && (Gia_ObjFaninC1(pNode0) ^ Gia_ObjFaninC0(pNode1)) ) + { +// if ( FrGia_IsComplement(pNode1->p2) ) + if ( Gia_ObjFaninC1(pNode0) ) + { // pNode2->p1 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + *ppNodeE = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + return Gia_ObjChild0(pNode1);//pNode2->p1; + } + else + { // pNode1->p2 is positive phase of C + *ppNodeT = Gia_Not(Gia_ObjChild0(pNode0));//pNode1->p1); + *ppNodeE = Gia_Not(Gia_ObjChild1(pNode1));//pNode2->p2); + return Gia_ObjChild1(pNode0);//pNode1->p2; + } + } + assert( 0 ); // this is not MUX + return NULL; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/aig/gia/module.make b/src/aig/gia/module.make new file mode 100644 index 00000000..67798476 --- /dev/null +++ b/src/aig/gia/module.make @@ -0,0 +1,19 @@ +SRC += src/aig/gia/gia.c \ + src/aig/gia/giaAig.c \ + src/aig/gia/giaAiger.c \ + src/aig/gia/giaCof.c \ + src/aig/gia/giaDfs.c \ + src/aig/gia/giaDup.c \ + src/aig/gia/giaFanout.c \ + src/aig/gia/giaForce.c \ + src/aig/gia/giaFrames.c \ + src/aig/gia/giaFront.c \ + src/aig/gia/giaGlitch.c \ + src/aig/gia/giaHash.c \ + src/aig/gia/giaLogic.c \ + src/aig/gia/giaMan.c \ + src/aig/gia/giaScl.c \ + src/aig/gia/giaSim.c \ + src/aig/gia/giaSwitch.c \ + src/aig/gia/giaTsim.c \ + src/aig/gia/giaUtil.c diff --git a/src/aig/hop/cudd2.h b/src/aig/hop/cudd2.h index 69711c11..27359b3f 100644 --- a/src/aig/hop/cudd2.h +++ b/src/aig/hop/cudd2.h @@ -21,10 +21,6 @@ #ifndef __CUDD2_H__ #define __CUDD2_H__ -#ifdef __cplusplus -extern "C" { -#endif - // HA: Added for printing messages #ifndef MSG #define MSG(msg) (printf("%s = \n",(msg))); @@ -38,6 +34,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/hop/hop.h b/src/aig/hop/hop.h index 6ffc4eac..1e58e825 100644 --- a/src/aig/hop/hop.h +++ b/src/aig/hop/hop.h @@ -21,10 +21,6 @@ #ifndef __HOP_H__ #define __HOP_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -41,6 +37,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -102,7 +102,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 free nodes + Hop_Obj_t * pListFree; // the list of ABC_FREE nodes // timing statistics int time1; int time2; @@ -115,10 +115,6 @@ struct Hop_Man_t_ #define AIG_MIN(a,b) (((a) < (b))? (a) : (b)) #define AIG_MAX(a,b) (((a) > (b))? (a) : (b)) -#ifndef PRT -#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)) -#endif - static inline int Hop_BitWordNum( int nBits ) { return (nBits>>5) + ((nBits&31) > 0); } static inline int Hop_TruthWordNum( int nVars ) { return nVars <= 5 ? 1 : (1 << (nVars - 5)); } static inline int Hop_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; } @@ -127,10 +123,10 @@ static inline void Hop_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= 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 Hop_Obj_t * Hop_Regular( Hop_Obj_t * p ) { return (Hop_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); } -static inline Hop_Obj_t * Hop_Not( Hop_Obj_t * p ) { return (Hop_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); } -static inline Hop_Obj_t * Hop_NotCond( Hop_Obj_t * p, int c ) { return (Hop_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); } -static inline int Hop_IsComplement( Hop_Obj_t * p ) { return (int)((PORT_PTRUINT_T)(p) & 01); } +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); } +static inline Hop_Obj_t * Hop_NotCond( Hop_Obj_t * p, int c ) { return (Hop_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); } +static inline int Hop_IsComplement( Hop_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); } static inline Hop_Obj_t * Hop_ManConst0( Hop_Man_t * p ) { return Hop_Not(p->pConst1); } static inline Hop_Obj_t * Hop_ManConst1( Hop_Man_t * p ) { return p->pConst1; } @@ -169,13 +165,13 @@ static inline int Hop_ObjIsMarkA( Hop_Obj_t * pObj ) { return pObj- static inline void Hop_ObjSetMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 1; } static inline void Hop_ObjClearMarkA( Hop_Obj_t * pObj ) { pObj->fMarkA = 0; } -static inline void Hop_ObjSetTravId( Hop_Obj_t * pObj, int TravId ) { pObj->pData = (void *)(PORT_PTRINT_T)TravId; } -static inline void Hop_ObjSetTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(PORT_PTRINT_T)p->nTravIds; } -static inline void Hop_ObjSetTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(PORT_PTRINT_T)(p->nTravIds - 1); } -static inline int Hop_ObjIsTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(PORT_PTRINT_T)pObj->pData == p->nTravIds); } -static inline int Hop_ObjIsTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(PORT_PTRINT_T)pObj->pData == p->nTravIds - 1); } +static inline void Hop_ObjSetTravId( Hop_Obj_t * pObj, int TravId ) { pObj->pData = (void *)(ABC_PTRINT_T)TravId; } +static inline void Hop_ObjSetTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(ABC_PTRINT_T)p->nTravIds; } +static inline void Hop_ObjSetTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { pObj->pData = (void *)(ABC_PTRINT_T)(p->nTravIds - 1); } +static inline int Hop_ObjIsTravIdCurrent( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(ABC_PTRINT_T)pObj->pData == p->nTravIds); } +static inline int Hop_ObjIsTravIdPrevious( Hop_Man_t * p, Hop_Obj_t * pObj ) { return (int)((int)(ABC_PTRINT_T)pObj->pData == p->nTravIds - 1); } -static inline int Hop_ObjTravId( Hop_Obj_t * pObj ) { return (int)(PORT_PTRINT_T)pObj->pData; } +static inline int Hop_ObjTravId( Hop_Obj_t * pObj ) { return (int)(ABC_PTRINT_T)pObj->pData; } static inline int Hop_ObjPhase( Hop_Obj_t * pObj ) { return pObj->fPhase; } static inline int Hop_ObjRefs( Hop_Obj_t * pObj ) { return pObj->nRefs; } static inline void Hop_ObjRef( Hop_Obj_t * pObj ) { pObj->nRefs++; } diff --git a/src/aig/hop/hopDfs.c b/src/aig/hop/hopDfs.c index bf196aea..3dd8793c 100644 --- a/src/aig/hop/hopDfs.c +++ b/src/aig/hop/hopDfs.c @@ -123,15 +123,15 @@ int Hop_ManCountLevels( Hop_Man_t * p ) vNodes = Hop_ManDfs( p ); Vec_PtrForEachEntry( vNodes, pObj, i ) { - Level0 = (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData; - Level1 = (int)(PORT_PTRUINT_T)Hop_ObjFanin1(pObj)->pData; - pObj->pData = (void *)(PORT_PTRUINT_T)(1 + Hop_ObjIsExor(pObj) + AIG_MAX(Level0, Level1)); + Level0 = (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData; + Level1 = (int)(ABC_PTRUINT_T)Hop_ObjFanin1(pObj)->pData; + pObj->pData = (void *)(ABC_PTRUINT_T)(1 + Hop_ObjIsExor(pObj) + AIG_MAX(Level0, Level1)); } Vec_PtrFree( vNodes ); // get levels of the POs LevelsMax = 0; Hop_ManForEachPo( p, pObj, i ) - LevelsMax = AIG_MAX( LevelsMax, (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData ); + LevelsMax = AIG_MAX( LevelsMax, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData ); return LevelsMax; } diff --git a/src/aig/hop/hopMan.c b/src/aig/hop/hopMan.c index 99f5d316..bf38a780 100644 --- a/src/aig/hop/hopMan.c +++ b/src/aig/hop/hopMan.c @@ -43,7 +43,7 @@ Hop_Man_t * Hop_ManStart() { Hop_Man_t * p; // start the manager - p = ALLOC( Hop_Man_t, 1 ); + p = ABC_ALLOC( Hop_Man_t, 1 ); memset( p, 0, sizeof(Hop_Man_t) ); // perform initializations p->nTravIds = 1; @@ -62,7 +62,7 @@ Hop_Man_t * Hop_ManStart() // start the table // p->nTableSize = 107; p->nTableSize = 10007; - p->pTable = ALLOC( Hop_Obj_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Hop_Obj_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize ); return p; } @@ -92,15 +92,15 @@ void Hop_ManStop( Hop_Man_t * p ) Hop_ManForEachNode( p, pObj, i ) assert( !pObj->fMarkA && !pObj->fMarkB ); // print time - if ( p->time1 ) { PRT( "time1", p->time1 ); } - if ( p->time2 ) { PRT( "time2", p->time2 ); } + if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); } + if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); } // Hop_TableProfile( p ); if ( p->vChunks ) Hop_ManStopMemory( p ); if ( p->vPis ) Vec_PtrFree( p->vPis ); if ( p->vPos ) Vec_PtrFree( p->vPos ); if ( p->vObjs ) Vec_PtrFree( p->vObjs ); - free( p->pTable ); - free( p ); + ABC_FREE( p->pTable ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/hop/hopMem.c b/src/aig/hop/hopMem.c index 60f89d53..c6d05865 100644 --- a/src/aig/hop/hopMem.c +++ b/src/aig/hop/hopMem.c @@ -65,7 +65,7 @@ void Hop_ManStopMemory( Hop_Man_t * p ) void * pMemory; int i; Vec_PtrForEachEntry( p->vChunks, pMemory, i ) - free( pMemory ); + ABC_FREE( pMemory ); Vec_PtrFree( p->vChunks ); Vec_PtrFree( p->vPages ); p->pListFree = NULL; @@ -92,10 +92,10 @@ void Hop_ManAddMemory( Hop_Man_t * p ) // assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 ); // allocate new memory page nBytes = sizeof(Hop_Obj_t) * (1<vChunks, pMemory ); // align memory at the 32-byte boundary - pMemory = pMemory + 64 - (((int)(PORT_PTRUINT_T)pMemory) & 63); + pMemory = pMemory + 64 - (((int)(ABC_PTRUINT_T)pMemory) & 63); // remember the manager in the first entry Vec_PtrPush( p->vPages, pMemory ); // break the memory down into nodes diff --git a/src/aig/hop/hopObj.c b/src/aig/hop/hopObj.c index f173248f..eccf58b8 100644 --- a/src/aig/hop/hopObj.c +++ b/src/aig/hop/hopObj.c @@ -193,7 +193,7 @@ void Hop_ObjDelete( Hop_Man_t * p, Hop_Obj_t * pObj ) // remove PIs/POs from the arrays if ( Hop_ObjIsPi(pObj) ) Vec_PtrRemove( p->vPis, pObj ); - // free the node + // ABC_FREE the node Hop_ManRecycleMemory( p, pObj ); } diff --git a/src/aig/hop/hopTable.c b/src/aig/hop/hopTable.c index 76390054..cfc6add0 100644 --- a/src/aig/hop/hopTable.c +++ b/src/aig/hop/hopTable.c @@ -172,7 +172,7 @@ clk = clock(); nTableSizeOld = p->nTableSize; // get the new table p->nTableSize = Cudd_PrimeAig( 2 * Hop_ManNodeNum(p) ); - p->pTable = ALLOC( Hop_Obj_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Hop_Obj_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Hop_Obj_t *) * p->nTableSize ); // rehash the entries from the old table Counter = 0; @@ -190,9 +190,9 @@ clk = clock(); nEntries = Hop_ManNodeNum(p); assert( Counter == nEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( pTableOld ); + ABC_FREE( pTableOld ); } /**Function******************************************************************** diff --git a/src/aig/hop/hopUtil.c b/src/aig/hop/hopUtil.c index d9dbbcaa..d541ab99 100644 --- a/src/aig/hop/hopUtil.c +++ b/src/aig/hop/hopUtil.c @@ -516,13 +516,13 @@ void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName ) // collect nodes in the DFS order vNodes = Hop_ManDfs( p ); // assign IDs to objects - Hop_ManConst1(p)->pData = (void *)(PORT_PTRUINT_T)Counter++; + Hop_ManConst1(p)->pData = (void *)(ABC_PTRUINT_T)Counter++; Hop_ManForEachPi( p, pObj, i ) - pObj->pData = (void *)(PORT_PTRUINT_T)Counter++; + pObj->pData = (void *)(ABC_PTRUINT_T)Counter++; Hop_ManForEachPo( p, pObj, i ) - pObj->pData = (void *)(PORT_PTRUINT_T)Counter++; + pObj->pData = (void *)(ABC_PTRUINT_T)Counter++; Vec_PtrForEachEntry( vNodes, pObj, i ) - pObj->pData = (void *)(PORT_PTRUINT_T)Counter++; + pObj->pData = (void *)(ABC_PTRUINT_T)Counter++; nDigits = Hop_Base10Log( Counter ); // write the file pFile = fopen( pFileName, "w" ); @@ -532,34 +532,34 @@ void Hop_ManDumpBlif( Hop_Man_t * p, char * pFileName ) // write PIs fprintf( pFile, ".inputs" ); Hop_ManForEachPi( p, pObj, i ) - fprintf( pFile, " n%0*d", nDigits, (int)(PORT_PTRUINT_T)pObj->pData ); + fprintf( pFile, " n%0*d", nDigits, (int)(ABC_PTRUINT_T)pObj->pData ); fprintf( pFile, "\n" ); // write POs fprintf( pFile, ".outputs" ); Hop_ManForEachPo( p, pObj, i ) - fprintf( pFile, " n%0*d", nDigits, (int)(PORT_PTRUINT_T)pObj->pData ); + fprintf( pFile, " n%0*d", nDigits, (int)(ABC_PTRUINT_T)pObj->pData ); fprintf( pFile, "\n" ); // write nodes Vec_PtrForEachEntry( vNodes, pObj, i ) { fprintf( pFile, ".names n%0*d n%0*d n%0*d\n", - nDigits, (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData, - nDigits, (int)(PORT_PTRUINT_T)Hop_ObjFanin1(pObj)->pData, - nDigits, (int)(PORT_PTRUINT_T)pObj->pData ); + nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData, + nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin1(pObj)->pData, + nDigits, (int)(ABC_PTRUINT_T)pObj->pData ); fprintf( pFile, "%d%d 1\n", !Hop_ObjFaninC0(pObj), !Hop_ObjFaninC1(pObj) ); } // write POs Hop_ManForEachPo( p, pObj, i ) { fprintf( pFile, ".names n%0*d n%0*d\n", - nDigits, (int)(PORT_PTRUINT_T)Hop_ObjFanin0(pObj)->pData, - nDigits, (int)(PORT_PTRUINT_T)pObj->pData ); + nDigits, (int)(ABC_PTRUINT_T)Hop_ObjFanin0(pObj)->pData, + nDigits, (int)(ABC_PTRUINT_T)pObj->pData ); fprintf( pFile, "%d 1\n", !Hop_ObjFaninC0(pObj) ); if ( Hop_ObjIsConst1(Hop_ObjFanin0(pObj)) ) pConst1 = Hop_ManConst1(p); } if ( pConst1 ) - fprintf( pFile, ".names n%0*d\n 1\n", nDigits, (int)(PORT_PTRUINT_T)pConst1->pData ); + fprintf( pFile, ".names n%0*d\n 1\n", nDigits, (int)(ABC_PTRUINT_T)pConst1->pData ); fprintf( pFile, ".end\n\n" ); fclose( pFile ); Vec_PtrFree( vNodes ); diff --git a/src/aig/int/int.h b/src/aig/int/int.h index e0c4e960..c9c5cd1a 100644 --- a/src/aig/int/int.h +++ b/src/aig/int/int.h @@ -21,10 +21,6 @@ #ifndef __INT_H__ #define __INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - /* The interpolation algorithm implemented here was introduced in the paper: K. L. McMillan. Interpolation and SAT-based model checking. CAV’03, pp. 1-13. @@ -38,6 +34,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/int/intContain.c b/src/aig/int/intContain.c index dcc80b29..3c16629f 100644 --- a/src/aig/int/intContain.c +++ b/src/aig/int/intContain.c @@ -231,7 +231,7 @@ int Inter_ManCheckInductiveContainment( Aig_Man_t * pTrans, Aig_Man_t * pInter, } // solve the problem - status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); // Inter_ManCheckUniqueness( pTrans, pSat, pCnf, nSteps ); @@ -317,7 +317,7 @@ int Inter_ManCheckUniqueness( Aig_Man_t * p, sat_solver * pSat, Cnf_Dat_t * pCnf printf( "Uniquness does not hold in %d frames.\n", Counter ); Fra_SmlStop( pSml ); - free( pCounterEx ); + ABC_FREE( pCounterEx ); return 1; } diff --git a/src/aig/int/intCore.c b/src/aig/int/intCore.c index 8fe15cda..cab0302f 100644 --- a/src/aig/int/intCore.c +++ b/src/aig/int/intCore.c @@ -146,7 +146,7 @@ p->timeCnf += clock() - clk; { printf( "Step = %2d. Frames = 1 + %d. And = %5d. Lev = %5d. ", s+1, p->nFrames, Aig_ManNodeNum(p->pFrames), Aig_ManLevelNum(p->pFrames) ); - PRT( "Time", clock() - clk2 ); + ABC_PRT( "Time", clock() - clk2 ); } // iterate the interpolation procedure for ( i = 0; ; i++ ) @@ -176,7 +176,7 @@ p->timeCnf += clock() - clk; { printf( " I = %2d. Bmc =%3d. IntAnd =%6d. IntLev =%5d. Conf =%6d. ", i+1, i + 1 + p->nFrames, Aig_ManNodeNum(p->pInter), Aig_ManLevelNum(p->pInter), p->nConfCur ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } if ( RetValue == 0 ) // found a (spurious?) counter-example { diff --git a/src/aig/int/intCtrex.c b/src/aig/int/intCtrex.c index 4cbe2007..98c01de6 100644 --- a/src/aig/int/intCtrex.c +++ b/src/aig/int/intCtrex.c @@ -123,7 +123,7 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose ) return NULL; } // solve the miter - status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); // if the problem is SAT, get the counterexample if ( status == l_True ) { @@ -134,9 +134,9 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose ) for ( i = 0; i < Vec_IntSize(vCiIds); i++ ) if ( pModel[i] ) Aig_InfoSetBit( pCtrex->pData, Saig_ManRegNum(pAig) + i ); - free( pModel ); + ABC_FREE( pModel ); } - // free the sat_solver + // ABC_FREE the sat_solver sat_solver_delete( pSat ); Vec_IntFree( vCiIds ); // verify counter-example @@ -146,7 +146,7 @@ void * Inter_ManGetCounterExample( Aig_Man_t * pAig, int nFrames, int fVerbose ) // report the results if ( fVerbose ) { - PRT( "Total ctrex generation time", clock() - clk ); + ABC_PRT( "Total ctrex generation time", clock() - clk ); } return pCtrex; diff --git a/src/aig/int/intDup.c b/src/aig/int/intDup.c index 3e5aaa7e..4c5b7ab6 100644 --- a/src/aig/int/intDup.c +++ b/src/aig/int/intDup.c @@ -46,13 +46,13 @@ Aig_Man_t * Inter_ManStartInitState( int nRegs ) Aig_Obj_t ** ppInputs; int i; assert( nRegs > 0 ); - ppInputs = ALLOC( Aig_Obj_t *, nRegs ); + ppInputs = ABC_ALLOC( Aig_Obj_t *, nRegs ); p = Aig_ManStart( nRegs ); for ( i = 0; i < nRegs; i++ ) ppInputs[i] = Aig_Not( Aig_ObjCreatePi(p) ); pRes = Aig_Multi( p, ppInputs, nRegs, AIG_OBJ_AND ); Aig_ObjCreatePo( p, pRes ); - free( ppInputs ); + ABC_FREE( ppInputs ); return p; } diff --git a/src/aig/int/intInt.h b/src/aig/int/intInt.h index c84fef2d..2d571f09 100644 --- a/src/aig/int/intInt.h +++ b/src/aig/int/intInt.h @@ -21,10 +21,6 @@ #ifndef __INT_INT_H__ #define __INT_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -39,6 +35,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/int/intM114.c b/src/aig/int/intM114.c index dbf078e2..359d5458 100644 --- a/src/aig/int/intM114.c +++ b/src/aig/int/intM114.c @@ -217,19 +217,19 @@ int Inter_ManPerformOneStep( Inter_Man_t * p, int fUseBias, int fUseBackward ) } // collect global variables - pGlobalVars = CALLOC( int, sat_solver_nvars(pSat) ); + pGlobalVars = ABC_CALLOC( int, sat_solver_nvars(pSat) ); Vec_IntForEachEntry( p->vVarsAB, Var, i ) pGlobalVars[Var] = 1; pSat->pGlobalVars = fUseBias? pGlobalVars : NULL; // solve the problem clk = clock(); - status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->nConfLimit, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); p->nConfCur = pSat->stats.conflicts; p->timeSat += clock() - clk; pSat->pGlobalVars = NULL; - FREE( pGlobalVars ); + ABC_FREE( pGlobalVars ); if ( status == l_False ) { pSatCnf = sat_solver_store_release( pSat ); diff --git a/src/aig/int/intMan.c b/src/aig/int/intMan.c index ec5d06d3..14a79f65 100644 --- a/src/aig/int/intMan.c +++ b/src/aig/int/intMan.c @@ -43,7 +43,7 @@ Inter_Man_t * Inter_ManCreate( Aig_Man_t * pAig, Inter_ManParams_t * pPars ) { Inter_Man_t * p; // create interpolation manager - p = ALLOC( Inter_Man_t, 1 ); + p = ABC_ALLOC( Inter_Man_t, 1 ); memset( p, 0, sizeof(Inter_Man_t) ); p->vVarsAB = Vec_IntAlloc( Aig_ManRegNum(pAig) ); p->nConfLimit = pPars->nBTLimit; @@ -92,13 +92,13 @@ void Inter_ManStop( Inter_Man_t * p ) { p->timeOther = p->timeTotal-p->timeRwr-p->timeCnf-p->timeSat-p->timeInt-p->timeEqu; printf( "Runtime statistics:\n" ); - PRTP( "Rewriting ", p->timeRwr, p->timeTotal ); - PRTP( "CNF mapping", p->timeCnf, p->timeTotal ); - PRTP( "SAT solving", p->timeSat, p->timeTotal ); - PRTP( "Interpol ", p->timeInt, p->timeTotal ); - PRTP( "Containment", p->timeEqu, p->timeTotal ); - PRTP( "Other ", p->timeOther, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + ABC_PRTP( "Rewriting ", p->timeRwr, p->timeTotal ); + ABC_PRTP( "CNF mapping", p->timeCnf, p->timeTotal ); + ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal ); + ABC_PRTP( "Interpol ", p->timeInt, p->timeTotal ); + ABC_PRTP( "Containment", p->timeEqu, p->timeTotal ); + ABC_PRTP( "Other ", p->timeOther, p->timeTotal ); + ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); } if ( p->pCnfAig ) @@ -116,7 +116,7 @@ void Inter_ManStop( Inter_Man_t * p ) Aig_ManStop( p->pInter ); if ( p->pInterNew ) Aig_ManStop( p->pInterNew ); - free( p ); + ABC_FREE( p ); } diff --git a/src/aig/int/intUtil.c b/src/aig/int/intUtil.c index 722a3611..c0dc9ddb 100644 --- a/src/aig/int/intUtil.c +++ b/src/aig/int/intUtil.c @@ -51,9 +51,9 @@ int Inter_ManCheckInitialState( Aig_Man_t * p ) Cnf_DataFree( pCnf ); if ( pSat == NULL ) return 0; - status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); sat_solver_delete( pSat ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); return status == l_True; } @@ -79,9 +79,9 @@ int Inter_ManCheckAllStates( Aig_Man_t * p ) Cnf_DataFree( pCnf ); if ( pSat == NULL ) return 1; - status = sat_solver_solve( pSat, NULL, NULL, (sint64)0, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); sat_solver_delete( pSat ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); return status == l_False; } diff --git a/src/aig/ioa/ioa.h b/src/aig/ioa/ioa.h index be8594e7..55d95f6e 100644 --- a/src/aig/ioa/ioa.h +++ b/src/aig/ioa/ioa.h @@ -21,10 +21,6 @@ #ifndef __IOA_H__ #define __IOA_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -43,6 +39,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/ioa/ioaReadAig.c b/src/aig/ioa/ioaReadAig.c index 342bd9fa..11c866f4 100644 --- a/src/aig/ioa/ioaReadAig.c +++ b/src/aig/ioa/ioaReadAig.c @@ -112,7 +112,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck ) // read the file into the buffer nFileSize = Ioa_FileSize( pFileName ); pFile = fopen( pFileName, "rb" ); - pContents = ALLOC( char, nFileSize ); + pContents = ABC_ALLOC( char, nFileSize ); fread( pContents, nFileSize, 1, pFile ); fclose( pFile ); @@ -120,6 +120,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck ) if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') ) { fprintf( stdout, "Wrong input file format.\n" ); + free( pContents ); return NULL; } @@ -147,7 +148,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck ) pName = Ioa_FileNameGeneric( pFileName ); pNew->pName = Aig_UtilStrsav( pName ); // pNew->pSpec = Ioa_UtilStrsav( pFileName ); - free( pName ); + ABC_FREE( pName ); // prepare the array of nodes vNodes = Vec_PtrAlloc( 1 + nInputs + nLatches + nAnds ); @@ -342,7 +343,7 @@ Aig_Man_t * Ioa_ReadAiger( char * pFileName, int fCheck ) */ // skipping the comments - free( pContents ); + ABC_FREE( pContents ); Vec_PtrFree( vNodes ); // remove the extra nodes diff --git a/src/aig/ioa/ioaWriteAig.c b/src/aig/ioa/ioaWriteAig.c index ec37b40e..3d37c0a7 100644 --- a/src/aig/ioa/ioaWriteAig.c +++ b/src/aig/ioa/ioaWriteAig.c @@ -329,7 +329,7 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int // write the nodes into the buffer Pos = 0; nBufferSize = 6 * Aig_ManNodeNum(pMan) + 100; // skeptically assuming 3 chars per one AIG edge - pBuffer = ALLOC( unsigned char, nBufferSize ); + pBuffer = ABC_ALLOC( unsigned char, nBufferSize ); // pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(pMan) ); Aig_ManForEachNode( pMan, pObj, i ) { @@ -337,7 +337,13 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int 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 ); + 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 ); if ( Pos > nBufferSize - 10 ) @@ -352,7 +358,7 @@ void Ioa_WriteAiger( Aig_Man_t * pMan, char * pFileName, int fWriteSymbols, int // write the buffer fwrite( pBuffer, 1, Pos, pFile ); - free( pBuffer ); + ABC_FREE( pBuffer ); /* // write the symbol table if ( fWriteSymbols ) diff --git a/src/aig/ivy/attr.h b/src/aig/ivy/attr.h index 16cf0b84..ad342ce9 100644 --- a/src/aig/ivy/attr.h +++ b/src/aig/ivy/attr.h @@ -21,10 +21,6 @@ #ifndef __ATTR_H__ #define __ATTR_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -35,6 +31,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/ivy/ivy.h b/src/aig/ivy/ivy.h index 9832e061..2c915e5b 100644 --- a/src/aig/ivy/ivy.h +++ b/src/aig/ivy/ivy.h @@ -21,10 +21,6 @@ #ifndef __IVY_H__ #define __IVY_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -121,7 +121,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 free nodes + Ivy_Obj_t * pListFree; // the list of ABC_FREE nodes // timing statistics int time1; int time2; @@ -186,10 +186,10 @@ static inline int Ivy_InfoHasBit( unsigned * p, int i ) { return (p[(i static inline void Ivy_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); } static inline void Ivy_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); } -static inline Ivy_Obj_t * Ivy_Regular( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); } -static inline Ivy_Obj_t * Ivy_Not( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); } -static inline Ivy_Obj_t * Ivy_NotCond( Ivy_Obj_t * p, int c ) { return (Ivy_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); } -static inline int Ivy_IsComplement( Ivy_Obj_t * p ) { return (int)((PORT_PTRUINT_T)(p) & 01); } +static inline Ivy_Obj_t * Ivy_Regular( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); } +static inline Ivy_Obj_t * Ivy_Not( Ivy_Obj_t * p ) { return (Ivy_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); } +static inline Ivy_Obj_t * Ivy_NotCond( Ivy_Obj_t * p, int c ) { return (Ivy_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); } +static inline int Ivy_IsComplement( Ivy_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); } static inline Ivy_Obj_t * Ivy_ManConst0( Ivy_Man_t * p ) { return Ivy_Not(p->pConst1); } static inline Ivy_Obj_t * Ivy_ManConst1( Ivy_Man_t * p ) { return p->pConst1; } diff --git a/src/aig/ivy/ivyCut.c b/src/aig/ivy/ivyCut.c index b0dd6db7..e3651645 100644 --- a/src/aig/ivy/ivyCut.c +++ b/src/aig/ivy/ivyCut.c @@ -980,7 +980,7 @@ void Ivy_ManTestCutsAll( Ivy_Man_t * p ) } printf( "Total cuts = %6d. Trivial = %6d. Nodes = %6d. Satur = %6d. ", nCutsTotal, Ivy_ManPiNum(p) + Ivy_ManNodeNum(p), nNodeTotal, nNodeOver ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/ivy/ivyCutTrav.c b/src/aig/ivy/ivyCutTrav.c index ea57c9f5..a52bbcf9 100644 --- a/src/aig/ivy/ivyCutTrav.c +++ b/src/aig/ivy/ivyCutTrav.c @@ -457,7 +457,7 @@ void Ivy_ManTestCutsTravAll( Ivy_Man_t * p ) } printf( "Total cuts = %6d. Trivial = %6d. Nodes = %6d. Satur = %6d. ", nCutsTotal, Ivy_ManPiNum(p) + Ivy_ManNodeNum(p), nNodeTotal, nNodeOver ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); Vec_PtrFree( vNodes ); Vec_PtrFree( vFront ); diff --git a/src/aig/ivy/ivyFastMap.c b/src/aig/ivy/ivyFastMap.c index 6ee177a4..0c0102c0 100644 --- a/src/aig/ivy/ivyFastMap.c +++ b/src/aig/ivy/ivyFastMap.c @@ -105,12 +105,12 @@ void Ivy_FastMapPerform( Ivy_Man_t * pAig, int nLimit, int fRecovery, int fVerbo Ivy_Obj_t * pObj; int i, Delay, Area, clk, clkTotal = clock(); // start the memory for supports - pMan = ALLOC( Ivy_SuppMan_t, 1 ); + pMan = ABC_ALLOC( Ivy_SuppMan_t, 1 ); memset( pMan, 0, sizeof(Ivy_SuppMan_t) ); pMan->nLimit = nLimit; pMan->nObjs = Ivy_ManObjIdMax(pAig) + 1; pMan->nSize = sizeof(Ivy_Supp_t) + nLimit * sizeof(int); - pMan->pMem = (char *)malloc( pMan->nObjs * pMan->nSize ); + pMan->pMem = (char *)ABC_ALLOC( char, pMan->nObjs * pMan->nSize ); memset( pMan->pMem, 0, pMan->nObjs * pMan->nSize ); pMan->vLuts = Vec_VecAlloc( 100 ); pAig->pData = pMan; @@ -191,8 +191,8 @@ void Ivy_FastMapStop( Ivy_Man_t * pAig ) { Ivy_SuppMan_t * p = pAig->pData; Vec_VecFree( p->vLuts ); - free( p->pMem ); - free( p ); + ABC_FREE( p->pMem ); + ABC_FREE( p ); pAig->pData = NULL; } @@ -210,7 +210,7 @@ void Ivy_FastMapStop( Ivy_Man_t * pAig ) void Ivy_FastMapPrint( Ivy_Man_t * pAig, int Delay, int Area, int Time, char * pStr ) { printf( "%s : Delay = %3d. Area = %6d. ", pStr, Delay, Area ); - PRT( "Time", Time ); + ABC_PRT( "Time", Time ); } /**Function************************************************************* diff --git a/src/aig/ivy/ivyFraig.c b/src/aig/ivy/ivyFraig.c index 7c5a139c..c0ec3021 100644 --- a/src/aig/ivy/ivyFraig.c +++ b/src/aig/ivy/ivyFraig.c @@ -50,9 +50,9 @@ struct Ivy_FraigMan_t_ { // general info Ivy_FraigParams_t * pParams; // various parameters - // temporary backtrack limits because "sint64" cannot be defined in Ivy_FraigParams_t ... - sint64 nBTLimitGlobal; // global limit on the number of backtracks - sint64 nInsLimitGlobal;// global limit on the number of clause inspects + // temporary backtrack limits because "ABC_INT64_T" cannot be defined in Ivy_FraigParams_t ... + ABC_INT64_T nBTLimitGlobal; // global limit on the number of backtracks + ABC_INT64_T nInsLimitGlobal;// global limit on the number of clause inspects // AIG manager Ivy_Man_t * pManAig; // the starting AIG manager Ivy_Man_t * pManFraig; // the final AIG manager @@ -126,11 +126,11 @@ struct Prove_ParamsStruct_t_ // last-gasp mitering int nMiteringLimitLast; // final mitering limit // global SAT solver limits - sint64 nTotalBacktrackLimit; // global limit on the number of backtracks - sint64 nTotalInspectLimit; // global limit on the number of clause inspects + ABC_INT64_T nTotalBacktrackLimit; // global limit on the number of backtracks + ABC_INT64_T nTotalInspectLimit; // global limit on the number of clause inspects // global resources applied - sint64 nTotalBacktracksMade; // the total number of backtracks made - sint64 nTotalInspectsMade; // the total number of inspects made + ABC_INT64_T nTotalBacktracksMade; // the total number of backtracks made + ABC_INT64_T nTotalInspectsMade; // the total number of inspects made }; static inline Ivy_FraigSim_t * Ivy_ObjSim( Ivy_Obj_t * pObj ) { return (Ivy_FraigSim_t *)pObj->pFanout; } @@ -141,7 +141,7 @@ static inline Ivy_Obj_t * Ivy_ObjNodeHashNext( Ivy_Obj_t * pObj ) static inline Ivy_Obj_t * Ivy_ObjEquivListNext( Ivy_Obj_t * pObj ) { return pObj->pPrevFan0; } static inline Ivy_Obj_t * Ivy_ObjEquivListPrev( Ivy_Obj_t * pObj ) { return pObj->pPrevFan1; } static inline Ivy_Obj_t * Ivy_ObjFraig( Ivy_Obj_t * pObj ) { return pObj->pEquiv; } -static inline int Ivy_ObjSatNum( Ivy_Obj_t * pObj ) { return (int)(PORT_PTRUINT_T)pObj->pNextFan0; } +static inline int Ivy_ObjSatNum( Ivy_Obj_t * pObj ) { return (int)(ABC_PTRUINT_T)pObj->pNextFan0; } static inline Vec_Ptr_t * Ivy_ObjFaninVec( Ivy_Obj_t * pObj ) { return (Vec_Ptr_t *)pObj->pNextFan1; } static inline void Ivy_ObjSetSim( Ivy_Obj_t * pObj, Ivy_FraigSim_t * pSim ) { pObj->pFanout = (Ivy_Obj_t *)pSim; } @@ -152,7 +152,7 @@ static inline void Ivy_ObjSetNodeHashNext( Ivy_Obj_t * pObj, Ivy_Obj_t * static inline void Ivy_ObjSetEquivListNext( Ivy_Obj_t * pObj, Ivy_Obj_t * pNext ) { pObj->pPrevFan0 = pNext; } static inline void Ivy_ObjSetEquivListPrev( Ivy_Obj_t * pObj, Ivy_Obj_t * pPrev ) { pObj->pPrevFan1 = pPrev; } static inline void Ivy_ObjSetFraig( Ivy_Obj_t * pObj, Ivy_Obj_t * pNode ) { pObj->pEquiv = pNode; } -static inline void Ivy_ObjSetSatNum( Ivy_Obj_t * pObj, int Num ) { pObj->pNextFan0 = (Ivy_Obj_t *)(PORT_PTRUINT_T)Num; } +static inline void Ivy_ObjSetSatNum( Ivy_Obj_t * pObj, int Num ) { pObj->pNextFan0 = (Ivy_Obj_t *)(ABC_PTRUINT_T)Num; } static inline void Ivy_ObjSetFaninVec( Ivy_Obj_t * pObj, Vec_Ptr_t * vFanins ) { pObj->pNextFan1 = (Ivy_Obj_t *)vFanins; } static inline unsigned Ivy_ObjRandomSim() { return (rand() << 24) ^ (rand() << 12) ^ rand(); } @@ -181,7 +181,7 @@ static inline unsigned Ivy_ObjRandomSim() { return (ran static Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams ); static Ivy_FraigMan_t * Ivy_FraigStartSimple( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams ); -static Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 nBTLimitGlobal, sint64 nInsLimitGlobal, sint64 * pnSatConfs, sint64 * pnSatInspects ); +static Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, ABC_INT64_T nBTLimitGlobal, ABC_INT64_T nInsLimitGlobal, ABC_INT64_T * pnSatConfs, ABC_INT64_T * pnSatInspects ); static void Ivy_FraigPrint( Ivy_FraigMan_t * p ); static void Ivy_FraigStop( Ivy_FraigMan_t * p ); static void Ivy_FraigSimulate( Ivy_FraigMan_t * p ); @@ -199,8 +199,8 @@ static int * Ivy_FraigCreateModel( Ivy_FraigMan_t * p ); static int Ivy_FraigNodesAreEquivBdd( Ivy_Obj_t * pObj1, Ivy_Obj_t * pObj2 ); -static sint64 s_nBTLimitGlobal = 0; -static sint64 s_nInsLimitGlobal = 0; +static ABC_INT64_T s_nBTLimitGlobal = 0; +static ABC_INT64_T s_nInsLimitGlobal = 0; //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -253,7 +253,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars ) Ivy_FraigParams_t Params, * pIvyParams = &Params; Ivy_Man_t * pManAig, * pManTemp; int RetValue, nIter, clk;//, Counter; - sint64 nSatConfs = 0, nSatInspects = 0; + ABC_INT64_T nSatConfs = 0, nSatInspects = 0; // start the network and parameters pManAig = *ppManAig; @@ -334,7 +334,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars ) { clk = clock(); pIvyParams->nBTLimitNode = (int)(pParams->nFraigingLimitStart * pow(pParams->nFraigingLimitMulti,nIter)); - pIvyParams->nBTLimitMiter = (int)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)) / Ivy_ManPoNum(pManAig); + pIvyParams->nBTLimitMiter = 1 + (int)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)) / Ivy_ManPoNum(pManAig); pManAig = Ivy_FraigPerform_int( pManTemp = pManAig, pIvyParams, pParams->nTotalBacktrackLimit, pParams->nTotalInspectLimit, &nSatConfs, &nSatInspects ); Ivy_ManStop( pManTemp ); RetValue = Ivy_FraigMiterStatus( pManAig ); Ivy_FraigMiterPrint( pManAig, "Fraiging ", clk, pParams->fVerbose ); @@ -387,7 +387,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars ) // assign the model if it was proved by rewriting (const 1 miter) if ( RetValue == 0 && pManAig->pData == NULL ) { - pManAig->pData = ALLOC( int, Ivy_ManPiNum(pManAig) ); + pManAig->pData = ABC_ALLOC( int, Ivy_ManPiNum(pManAig) ); memset( pManAig->pData, 0, sizeof(int) * Ivy_ManPiNum(pManAig) ); } *ppManAig = pManAig; @@ -405,7 +405,7 @@ int Ivy_FraigProve( Ivy_Man_t ** ppManAig, void * pPars ) SeeAlso [] ***********************************************************************/ -Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, sint64 nBTLimitGlobal, sint64 nInsLimitGlobal, sint64 * pnSatConfs, sint64 * pnSatInspects ) +Ivy_Man_t * Ivy_FraigPerform_int( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParams, ABC_INT64_T nBTLimitGlobal, ABC_INT64_T nInsLimitGlobal, ABC_INT64_T * pnSatConfs, ABC_INT64_T * pnSatInspects ) { Ivy_FraigMan_t * p; Ivy_Man_t * pManAigNew; @@ -504,7 +504,7 @@ clk = clock(); p->timeTotal = clock() - clk; //printf( "Final nodes = %6d. ", Ivy_ManNodeNum(pManAigNew) ); -//PRT( "Time", p->timeTotal ); +//ABC_PRT( "Time", p->timeTotal ); Ivy_FraigStop( p ); return pManAigNew; } @@ -524,7 +524,7 @@ Ivy_FraigMan_t * Ivy_FraigStartSimple( Ivy_Man_t * pManAig, Ivy_FraigParams_t * { Ivy_FraigMan_t * p; // allocat the fraiging manager - p = ALLOC( Ivy_FraigMan_t, 1 ); + p = ABC_ALLOC( Ivy_FraigMan_t, 1 ); memset( p, 0, sizeof(Ivy_FraigMan_t) ); p->pParams = pParams; p->pManAig = pManAig; @@ -555,16 +555,16 @@ Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParam // pObj->pEquiv = pObj->pFanout = pObj->pNextFan0 = pObj->pNextFan1 = pObj->pPrevFan0 = pObj->pPrevFan1 = NULL; assert( !pObj->pEquiv && !pObj->pFanout ); // allocat the fraiging manager - p = ALLOC( Ivy_FraigMan_t, 1 ); + p = ABC_ALLOC( Ivy_FraigMan_t, 1 ); memset( p, 0, sizeof(Ivy_FraigMan_t) ); p->pParams = pParams; p->pManAig = pManAig; p->pManFraig = Ivy_ManStartFrom( pManAig ); // allocate simulation info p->nSimWords = pParams->nSimWords; -// p->pSimWords = ALLOC( unsigned, Ivy_ManObjNum(pManAig) * p->nSimWords ); +// p->pSimWords = ABC_ALLOC( unsigned, Ivy_ManObjNum(pManAig) * p->nSimWords ); EntrySize = sizeof(Ivy_FraigSim_t) + sizeof(unsigned) * p->nSimWords; - p->pSimWords = (char *)malloc( Ivy_ManObjNum(pManAig) * EntrySize ); + p->pSimWords = (char *)ABC_ALLOC( char, Ivy_ManObjNum(pManAig) * EntrySize ); memset( p->pSimWords, 0, EntrySize ); k = 0; Ivy_ManForEachObj( pManAig, pObj, i ) @@ -592,8 +592,8 @@ Ivy_FraigMan_t * Ivy_FraigStart( Ivy_Man_t * pManAig, Ivy_FraigParams_t * pParam assert( k == Ivy_ManObjNum(pManAig) ); // allocate storage for sim pattern p->nPatWords = Ivy_BitWordNum( Ivy_ManPiNum(pManAig) ); - p->pPatWords = ALLOC( unsigned, p->nPatWords ); - p->pPatScores = ALLOC( int, 32 * p->nSimWords ); + p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords ); + p->pPatScores = ABC_ALLOC( int, 32 * p->nSimWords ); p->vPiVars = Vec_PtrAlloc( 100 ); // set random number generator srand( 0xABCABC ); @@ -617,10 +617,10 @@ void Ivy_FraigStop( Ivy_FraigMan_t * p ) Ivy_FraigPrint( p ); if ( p->vPiVars ) Vec_PtrFree( p->vPiVars ); if ( p->pSat ) sat_solver_delete( p->pSat ); - FREE( p->pPatScores ); - FREE( p->pPatWords ); - FREE( p->pSimWords ); - free( p ); + ABC_FREE( p->pPatScores ); + ABC_FREE( p->pPatWords ); + ABC_FREE( p->pSimWords ); + ABC_FREE( p ); } /**Function************************************************************* @@ -646,15 +646,15 @@ void Ivy_FraigPrint( Ivy_FraigMan_t * p ) printf( "Final = %d. Miter = %d. Total = %d. Mux = %d. (Exor = %d.) SatVars = %d.\n", Ivy_ManNodeNum(p->pManFraig), p->nNodesMiter, Ivy_ManNodeNum(p->pManAig), 0, 0, p->nSatVars ); if ( p->pSat ) Sat_SolverPrintStats( stdout, p->pSat ); - PRT( "AIG simulation ", p->timeSim ); - PRT( "AIG traversal ", p->timeTrav ); - PRT( "SAT solving ", p->timeSat ); - PRT( " Unsat ", p->timeSatUnsat ); - PRT( " Sat ", p->timeSatSat ); - PRT( " Fail ", p->timeSatFail ); - PRT( "Class refining ", p->timeRef ); - PRT( "TOTAL RUNTIME ", p->timeTotal ); - if ( p->time1 ) { PRT( "time1 ", p->time1 ); } + ABC_PRT( "AIG simulation ", p->timeSim ); + ABC_PRT( "AIG traversal ", p->timeTrav ); + ABC_PRT( "SAT solving ", p->timeSat ); + ABC_PRT( " Unsat ", p->timeSatUnsat ); + ABC_PRT( " Sat ", p->timeSatSat ); + ABC_PRT( " Fail ", p->timeSatFail ); + ABC_PRT( "Class refining ", p->timeRef ); + ABC_PRT( "TOTAL RUNTIME ", p->timeTotal ); + if ( p->time1 ) { ABC_PRT( "time1 ", p->time1 ); } } @@ -1172,7 +1172,7 @@ void Ivy_FraigCreateClasses( Ivy_FraigMan_t * p ) pConst1 = Ivy_ManConst1(p->pManAig); // allocate the table nTableSize = Ivy_ManObjNum(p->pManAig) / 2 + 13; - pTable = ALLOC( Ivy_Obj_t *, nTableSize ); + pTable = ABC_ALLOC( Ivy_Obj_t *, nTableSize ); memset( pTable, 0, sizeof(Ivy_Obj_t *) * nTableSize ); // collect nodes into the table Ivy_ManForEachObj( p->pManAig, pObj, i ) @@ -1218,8 +1218,8 @@ void Ivy_FraigCreateClasses( Ivy_FraigMan_t * p ) Ivy_ObjSetClassNodeRepr( pObj, NULL ); Ivy_FraigAddClass( &p->lClasses, pObj ); } - // free the table - free( pTable ); + // ABC_FREE the table + ABC_FREE( pTable ); } /**Function************************************************************* @@ -1314,7 +1314,7 @@ void Ivy_FraigCheckOutputSimsSavePattern( Ivy_FraigMan_t * p, Ivy_Obj_t * pObj ) // determine the best pattern BestPat = i * 32 + k; // fill in the counter-example data - pModel = ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); + pModel = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); Ivy_ManForEachPi( p->pManAig, pObj, i ) { pModel[i] = Ivy_InfoHasBit(Ivy_ObjSim(pObj)->pData, BestPat); @@ -1513,7 +1513,7 @@ int * Ivy_FraigCreateModel( Ivy_FraigMan_t * p ) int * pModel; Ivy_Obj_t * pObj; int i; - pModel = ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); + pModel = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); Ivy_ManForEachPi( p->pManFraig, pObj, i ) pModel[i] = ( p->pSat->model.ptr[Ivy_ObjSatNum(pObj)] == l_True ); return pModel; @@ -1785,7 +1785,7 @@ void Ivy_FraigMiterPrint( Ivy_Man_t * pNtk, char * pString, int clk, int fVerbos if ( !fVerbose ) return; printf( "Nodes = %7d. Levels = %4d. ", Ivy_ManNodeNum(pNtk), Ivy_ManLevels(pNtk) ); - PRT( pString, clock() - clk ); + ABC_PRT( pString, clock() - clk ); } /**Function************************************************************* @@ -1871,7 +1871,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p ) { if ( i && fVerbose ) { - PRT( "Time", clock() -clk ); + ABC_PRT( "Time", clock() -clk ); } pObjNew = Ivy_ObjChild0Equiv(pObj); // check if the output is constant 1 @@ -1880,7 +1880,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p ) if ( fVerbose ) printf( "Output %2d (out of %2d) is constant 1. ", i, Ivy_ManPoNum(p->pManAig) ); // assing constant 0 model - p->pManFraig->pData = ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); + p->pManFraig->pData = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); memset( p->pManFraig->pData, 0, sizeof(int) * Ivy_ManPiNum(p->pManFraig) ); break; } @@ -1897,7 +1897,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p ) if ( fVerbose ) printf( "Output %2d (out of %2d) cannot be constant 0. ", i, Ivy_ManPoNum(p->pManAig) ); // assing constant 0 model - p->pManFraig->pData = ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); + p->pManFraig->pData = ABC_ALLOC( int, Ivy_ManPiNum(p->pManFraig) ); memset( p->pManFraig->pData, 0, sizeof(int) * Ivy_ManPiNum(p->pManFraig) ); break; } @@ -1934,7 +1934,7 @@ void Ivy_FraigMiterProve( Ivy_FraigMan_t * p ) } if ( fVerbose ) { - PRT( "Time", clock() -clk ); + ABC_PRT( "Time", clock() -clk ); } } @@ -2127,7 +2127,7 @@ clk = clock(); pLits[1] = toLitCond( Ivy_ObjSatNum(pNew), pOld->fPhase == pNew->fPhase ); //Sat_SolverWriteDimacs( p->pSat, "temp.cnf", pLits, pLits + 2, 1 ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) @@ -2171,7 +2171,7 @@ clk = clock(); pLits[0] = toLitCond( Ivy_ObjSatNum(pOld), 1 ); pLits[1] = toLitCond( Ivy_ObjSatNum(pNew), pOld->fPhase ^ pNew->fPhase ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 2, - (sint64)nBTLimit, (sint64)0, + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) @@ -2203,12 +2203,12 @@ p->timeSatFail += clock() - clk; // check BDD proof { int RetVal; - PRT( "Sat", clock() - clk2 ); + ABC_PRT( "Sat", clock() - clk2 ); clk2 = clock(); RetVal = Ivy_FraigNodesAreEquivBdd( pOld, pNew ); // printf( "%d ", RetVal ); assert( RetVal ); - PRT( "Bdd", clock() - clk2 ); + ABC_PRT( "Bdd", clock() - clk2 ); printf( "\n" ); } */ @@ -2259,7 +2259,7 @@ int Ivy_FraigNodeIsConst( Ivy_FraigMan_t * p, Ivy_Obj_t * pNew ) clk = clock(); pLits[0] = toLitCond( Ivy_ObjSatNum(pNew), pNew->fPhase ); RetValue1 = sat_solver_solve( p->pSat, pLits, pLits + 1, - (sint64)p->pParams->nBTLimitMiter, (sint64)0, + (ABC_INT64_T)p->pParams->nBTLimitMiter, (ABC_INT64_T)0, p->nBTLimitGlobal, p->nInsLimitGlobal ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) @@ -2395,7 +2395,7 @@ void Ivy_FraigAddClausesSuper( Ivy_FraigMan_t * p, Ivy_Obj_t * pNode, Vec_Ptr_t assert( Ivy_ObjIsNode( pNode ) ); // create storage for literals nLits = Vec_PtrSize(vSuper) + 1; - pLits = ALLOC( int, nLits ); + pLits = ABC_ALLOC( int, nLits ); // suppose AND-gate is A & B = C // add !A => !C or A + !C Vec_PtrForEachEntry( vSuper, pFanin, i ) @@ -2411,7 +2411,7 @@ void Ivy_FraigAddClausesSuper( Ivy_FraigMan_t * p, Ivy_Obj_t * pNode, Vec_Ptr_t pLits[nLits-1] = toLitCond(Ivy_ObjSatNum(pNode), 0); RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits ); assert( RetValue ); - free( pLits ); + ABC_FREE( pLits ); } /**Function************************************************************* @@ -2663,7 +2663,7 @@ DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_ } // collect the permutation NewSize = IVY_MAX(dd->size, Vec_PtrSize(vTemp)); - pFuncs = ALLOC( DdNode *, NewSize ); + pFuncs = ABC_ALLOC( DdNode *, NewSize ); Vec_PtrForEachEntry( vFront, pObj, i ) { if ( (int)pObj->Level != Level ) @@ -2693,9 +2693,9 @@ DdNode * Ivy_FraigNodesAreEquivBdd_int( DdManager * dd, DdNode * bFunc, Vec_Ptr_ // deref for ( i = 0; i < dd->size; i++ ) Cudd_RecursiveDeref( dd, pFuncs[i] ); - free( pFuncs ); + ABC_FREE( pFuncs ); - free( vFront->pArray ); + ABC_FREE( vFront->pArray ); *vFront = *vTemp; vTemp->nCap = vTemp->nSize = 0; diff --git a/src/aig/ivy/ivyHaig.c b/src/aig/ivy/ivyHaig.c index 87021600..62624642 100644 --- a/src/aig/ivy/ivyHaig.c +++ b/src/aig/ivy/ivyHaig.c @@ -518,7 +518,7 @@ printf( "Using latch %d with fanin %d\n", pObj->Id, Ivy_ObjFanin0(pObj)->Id ); Ivy_ManForEachNodeVec( p, vLatches, pObj, i ) pObj->Init = pObj->Level, pObj->Level = 0; } - // free arrays + // ABC_FREE arrays Vec_IntFree( vNodes ); Vec_IntFree( vLatches ); } diff --git a/src/aig/ivy/ivyMan.c b/src/aig/ivy/ivyMan.c index 66c279cf..d09f6ffd 100644 --- a/src/aig/ivy/ivyMan.c +++ b/src/aig/ivy/ivyMan.c @@ -43,7 +43,7 @@ Ivy_Man_t * Ivy_ManStart() { Ivy_Man_t * p; // start the manager - p = ALLOC( Ivy_Man_t, 1 ); + p = ABC_ALLOC( Ivy_Man_t, 1 ); memset( p, 0, sizeof(Ivy_Man_t) ); // perform initializations p->Ghost.Id = -1; @@ -63,7 +63,7 @@ Ivy_Man_t * Ivy_ManStart() p->nCreated = 1; // start the table p->nTableSize = 10007; - p->pTable = ALLOC( int, p->nTableSize ); + p->pTable = ABC_ALLOC( int, p->nTableSize ); memset( p->pTable, 0, sizeof(int) * p->nTableSize ); return p; } @@ -143,7 +143,7 @@ Ivy_Man_t * Ivy_ManDup( Ivy_Man_t * p ) // update the counters of different objects pNew->nObjs[IVY_PI] -= Ivy_ManLatchNum(p); pNew->nObjs[IVY_LATCH] += Ivy_ManLatchNum(p); - // free arrays + // ABC_FREE arrays Vec_IntFree( vNodes ); Vec_IntFree( vLatches ); // make sure structural hashing did not change anything @@ -234,8 +234,8 @@ Ivy_Man_t * Ivy_ManFrames( Ivy_Man_t * pMan, int nLatches, int nFrames, int fIni ***********************************************************************/ void Ivy_ManStop( Ivy_Man_t * p ) { - if ( p->time1 ) { PRT( "Update lev ", p->time1 ); } - if ( p->time2 ) { PRT( "Update levR ", p->time2 ); } + if ( p->time1 ) { ABC_PRT( "Update lev ", p->time1 ); } + if ( p->time2 ) { ABC_PRT( "Update levR ", p->time2 ); } // Ivy_TableProfile( p ); // if ( p->vFanouts ) Ivy_ManStopFanout( p ); if ( p->vChunks ) Ivy_ManStopMemory( p ); @@ -244,8 +244,8 @@ void Ivy_ManStop( Ivy_Man_t * p ) if ( p->vPos ) Vec_PtrFree( p->vPos ); if ( p->vBufs ) Vec_PtrFree( p->vBufs ); if ( p->vObjs ) Vec_PtrFree( p->vObjs ); - free( p->pTable ); - free( p ); + ABC_FREE( p->pTable ); + ABC_FREE( p ); } /**Function************************************************************* @@ -346,7 +346,7 @@ int Ivy_ManCleanupSeq( Ivy_Man_t * p ) // delete buffer from the array of buffers if ( p->fFanout && Ivy_ObjIsBuf(pObj) ) Vec_PtrRemove( p->vBufs, pObj ); - // free the node + // ABC_FREE the node Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL ); Ivy_ManRecycleMemory( p, pObj ); } diff --git a/src/aig/ivy/ivyMem.c b/src/aig/ivy/ivyMem.c index fd29e9ae..4ea6d891 100644 --- a/src/aig/ivy/ivyMem.c +++ b/src/aig/ivy/ivyMem.c @@ -65,7 +65,7 @@ void Ivy_ManStopMemory( Ivy_Man_t * p ) void * pMemory; int i; Vec_PtrForEachEntry( p->vChunks, pMemory, i ) - free( pMemory ); + ABC_FREE( pMemory ); Vec_PtrFree( p->vChunks ); Vec_PtrFree( p->vPages ); p->pListFree = NULL; @@ -93,10 +93,10 @@ void Ivy_ManAddMemory( Ivy_Man_t * p ) // assert( (Ivy_ManObjNum(p) & IVY_PAGE_MASK) == 0 ); // allocate new memory page nBytes = sizeof(Ivy_Obj_t) * (1<vChunks, pMemory ); // align memory at the 32-byte boundary - pMemory = pMemory + EntrySizeMax - (((int)(PORT_PTRUINT_T)pMemory) & (EntrySizeMax-1)); + pMemory = pMemory + EntrySizeMax - (((int)(ABC_PTRUINT_T)pMemory) & (EntrySizeMax-1)); // remember the manager in the first entry Vec_PtrPush( p->vPages, pMemory ); // break the memory down into nodes diff --git a/src/aig/ivy/ivyObj.c b/src/aig/ivy/ivyObj.c index 59dda19c..d7925fab 100644 --- a/src/aig/ivy/ivyObj.c +++ b/src/aig/ivy/ivyObj.c @@ -268,7 +268,7 @@ void Ivy_ObjDelete( Ivy_Man_t * p, Ivy_Obj_t * pObj, int fFreeTop ) // clean and recycle the entry if ( fFreeTop ) { - // free the node + // ABC_FREE the node Vec_PtrWriteEntry( p->vObjs, pObj->Id, NULL ); Ivy_ManRecycleMemory( p, pObj ); } diff --git a/src/aig/ivy/ivyResyn.c b/src/aig/ivy/ivyResyn.c index f42d7464..35ecb122 100644 --- a/src/aig/ivy/ivyResyn.c +++ b/src/aig/ivy/ivyResyn.c @@ -50,21 +50,21 @@ if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); pMan = Ivy_ManBalance( pMan, fUpdateLevel ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); // Ivy_ManRewriteAlg( pMan, fUpdateLevel, 0 ); clk = clock(); Ivy_ManRewritePre( pMan, fUpdateLevel, 0, 0 ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel ); Ivy_ManStop( pTemp ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); return pMan; } @@ -91,49 +91,49 @@ if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); pMan = Ivy_ManBalance( pMan, fUpdateLevel ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); // Ivy_ManRewriteAlg( pMan, fUpdateLevel, 0 ); clk = clock(); Ivy_ManRewritePre( pMan, fUpdateLevel, 0, 0 ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel ); Ivy_ManStop( pTemp ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); // Ivy_ManRewriteAlg( pMan, fUpdateLevel, 1 ); clk = clock(); Ivy_ManRewritePre( pMan, fUpdateLevel, 1, 0 ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel ); Ivy_ManStop( pTemp ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); // Ivy_ManRewriteAlg( pMan, fUpdateLevel, 1 ); clk = clock(); Ivy_ManRewritePre( pMan, fUpdateLevel, 1, 0 ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); pMan = Ivy_ManBalance( pTemp = pMan, fUpdateLevel ); Ivy_ManStop( pTemp ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); return pMan; } @@ -160,7 +160,7 @@ if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); Ivy_ManRewritePre( pMan, 0, 0, 0 ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); @@ -168,21 +168,21 @@ clk = clock(); // pMan = Ivy_ManDup( pTemp = pMan ); Ivy_ManStop( pTemp ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); /* clk = clock(); Ivy_ManRewritePre( pMan, 0, 0, 0 ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Rewrite", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Rewrite", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); clk = clock(); pMan = Ivy_ManBalance( pTemp = pMan, 0 ); Ivy_ManStop( pTemp ); if ( fVerbose ) { printf( "\n" ); } -if ( fVerbose ) { PRT( "Balance", clock() - clk ); } +if ( fVerbose ) { ABC_PRT( "Balance", clock() - clk ); } if ( fVerbose ) Ivy_ManPrintStats( pMan ); */ return pMan; diff --git a/src/aig/ivy/ivySeq.c b/src/aig/ivy/ivySeq.c index f4585fa2..0971a548 100644 --- a/src/aig/ivy/ivySeq.c +++ b/src/aig/ivy/ivySeq.c @@ -1127,7 +1127,7 @@ void Ivy_CutComputeAll( Ivy_Man_t * p, int nInputs ) } printf( "All = %6d. Minus = %6d. Triv = %6d. Node = %6d. Satur = %6d. ", nCutsTotal, nCutsTotalM, Ivy_ManPiNum(p) + Ivy_ManNodeNum(p), nNodeTotal, nNodeOver ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/ivy/ivyTable.c b/src/aig/ivy/ivyTable.c index 2ac0ae49..fdcc4bfb 100644 --- a/src/aig/ivy/ivyTable.c +++ b/src/aig/ivy/ivyTable.c @@ -210,7 +210,7 @@ clk = clock(); nTableSizeOld = p->nTableSize; // get the new table p->nTableSize = Cudd_PrimeAig( 5 * Ivy_ManHashObjNum(p) ); - p->pTable = ALLOC( int, p->nTableSize ); + p->pTable = ABC_ALLOC( int, p->nTableSize ); memset( p->pTable, 0, sizeof(int) * p->nTableSize ); // rehash the entries from the old table Counter = 0; @@ -227,9 +227,9 @@ clk = clock(); nEntries = Ivy_ManHashObjNum(p); // assert( Counter == nEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", nTableSizeOld, p->nTableSize ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( pTableOld ); + ABC_FREE( pTableOld ); } /**Function******************************************************************** diff --git a/src/aig/kit/cloud.c b/src/aig/kit/cloud.c index f5c91fe7..dc57e2b7 100644 --- a/src/aig/kit/cloud.c +++ b/src/aig/kit/cloud.c @@ -77,7 +77,7 @@ CloudManager * Cloud_Init( int nVars, int nBits ) nBits = CLOUD_NODE_BITS; // start the manager - dd = CALLOC( CloudManager, 1 ); + dd = ABC_CALLOC( CloudManager, 1 ); dd->nMemUsed += sizeof(CloudManager); // variables @@ -96,10 +96,10 @@ CloudManager * Cloud_Init( int nVars, int nBits ) // unique table clk1 = clock(); - dd->tUnique = CALLOC( CloudNode, dd->nNodesAlloc ); + dd->tUnique = ABC_CALLOC( CloudNode, dd->nNodesAlloc ); dd->nMemUsed += sizeof(CloudNode) * dd->nNodesAlloc; clk2 = clock(); -//PRT( "calloc() time", clk2 - clk1 ); +//ABC_PRT( "calloc() time", clk2 - clk1 ); // set up the constant node (the only node that is not in the hash table) dd->nSignCur = 1; @@ -116,7 +116,7 @@ clk2 = clock(); dd->pNodeEnd = dd->tUnique + dd->nNodesAlloc; // set up the elementary variables - dd->vars = ALLOC( CloudNode *, dd->nVars ); + dd->vars = ABC_ALLOC( CloudNode *, dd->nVars ); dd->nMemUsed += sizeof(CloudNode *) * dd->nVars; for ( i = 0; i < dd->nVars; i++ ) dd->vars[i] = cloudMakeNode( dd, i, dd->one, dd->zero ); @@ -140,12 +140,12 @@ clk2 = clock(); void Cloud_Quit( CloudManager * dd ) { int i; - FREE( dd->ppNodes ); - free( dd->tUnique ); - free( dd->vars ); + ABC_FREE( dd->ppNodes ); + ABC_FREE( dd->tUnique ); + ABC_FREE( dd->vars ); for ( i = 0; i < 4; i++ ) - FREE( dd->tCaches[i] ); - free( dd ); + ABC_FREE( dd->tCaches[i] ); + ABC_FREE( dd ); } /**Function******************************************************************** @@ -218,17 +218,17 @@ void cloudCacheAllocate( CloudManager * dd, CloudOper oper ) if ( CacheSize[oper] == 1 ) { - dd->tCaches[oper] = (CloudCacheEntry2 *)CALLOC( CloudCacheEntry1, nCacheEntries ); + dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry1, nCacheEntries ); dd->nMemUsed += sizeof(CloudCacheEntry1) * nCacheEntries; } else if ( CacheSize[oper] == 2 ) { - dd->tCaches[oper] = (CloudCacheEntry2 *)CALLOC( CloudCacheEntry2, nCacheEntries ); + dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry2, nCacheEntries ); dd->nMemUsed += sizeof(CloudCacheEntry2) * nCacheEntries; } else if ( CacheSize[oper] == 3 ) { - dd->tCaches[oper] = (CloudCacheEntry2 *)CALLOC( CloudCacheEntry3, nCacheEntries ); + dd->tCaches[oper] = (CloudCacheEntry2 *)ABC_CALLOC( CloudCacheEntry3, nCacheEntries ); dd->nMemUsed += sizeof(CloudCacheEntry3) * nCacheEntries; } } @@ -619,7 +619,7 @@ CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n ) CLOUD_ASSERT(n); // allocate and initialize support array for cloudSupport - support = CALLOC( int, dd->nVars ); + support = ABC_CALLOC( int, dd->nVars ); // compute support and clean up markers cloudSupport( dd, Cloud_Regular(n), support ); @@ -634,7 +634,7 @@ CloudNode * Cloud_Support( CloudManager * dd, CloudNode * n ) if ( res == NULL ) break; } - FREE( support ); + ABC_FREE( support ); return res; } @@ -658,7 +658,7 @@ int Cloud_SupportSize( CloudManager * dd, CloudNode * n ) CLOUD_ASSERT(n); // allocate and initialize support array for cloudSupport - support = CALLOC( int, dd->nVars ); + support = ABC_CALLOC( int, dd->nVars ); // compute support and clean up markers cloudSupport( dd, Cloud_Regular(n), support ); @@ -672,7 +672,7 @@ int Cloud_SupportSize( CloudManager * dd, CloudNode * n ) count++; } - FREE( support ); + ABC_FREE( support ); return count; } @@ -769,7 +769,7 @@ int Cloud_DagCollect( CloudManager * dd, CloudNode * n ) { int res, Counter = 0; if ( dd->ppNodes == NULL ) - dd->ppNodes = ALLOC( CloudNode *, dd->nNodesLimit ); + dd->ppNodes = ABC_ALLOC( CloudNode *, dd->nNodesLimit ); res = Cloud_DagCollect_rec( dd, Cloud_Regular( n ), &Counter ); cloudClearMark( dd, Cloud_Regular( n ) ); assert( res == Counter ); diff --git a/src/aig/kit/cloud.h b/src/aig/kit/cloud.h index ec8e9059..6f6a1eae 100644 --- a/src/aig/kit/cloud.h +++ b/src/aig/kit/cloud.h @@ -19,15 +19,15 @@ #ifndef __CLOUD_H__ #define __CLOUD_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include #include -#include "port_type.h" +#include "abc_global.h" + +#ifdef __cplusplus +extern "C" { +#endif #ifdef _WIN32 #define inline __inline // compatible with MS VS 6.0 @@ -176,14 +176,14 @@ struct cloudCacheEntry3 // the three-argument cache #define DD_P2 4256249 #define DD_P3 741457 #define DD_P4 1618033999 -#define cloudHashCudd2(f,g,s) ((((unsigned)(PORT_PTRUINT_T)(f) * DD_P1 + (unsigned)(PORT_PTRUINT_T)(g)) * DD_P2) >> (s)) -#define cloudHashCudd3(f,g,h,s) (((((unsigned)(PORT_PTRUINT_T)(f) * DD_P1 + (unsigned)(PORT_PTRUINT_T)(g)) * DD_P2 + (unsigned)(PORT_PTRUINT_T)(h)) * DD_P3) >> (s)) +#define cloudHashCudd2(f,g,s) ((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2) >> (s)) +#define cloudHashCudd3(f,g,h,s) (((((unsigned)(ABC_PTRUINT_T)(f) * DD_P1 + (unsigned)(ABC_PTRUINT_T)(g)) * DD_P2 + (unsigned)(ABC_PTRUINT_T)(h)) * DD_P3) >> (s)) // node complementation (using node) -#define Cloud_Regular(p) ((CloudNode*)(((PORT_PTRUINT_T)(p)) & ~01)) // get the regular node (w/o bubble) -#define Cloud_Not(p) ((CloudNode*)(((PORT_PTRUINT_T)(p)) ^ 01)) // complement the node -#define Cloud_NotCond(p,c) ((CloudNode*)(((PORT_PTRUINT_T)(p)) ^ (c))) // complement the node conditionally -#define Cloud_IsComplement(p) ((int)(((PORT_PTRUINT_T)(p)) & 01)) // check if complemented +#define Cloud_Regular(p) ((CloudNode*)(((ABC_PTRUINT_T)(p)) & ~01)) // get the regular node (w/o bubble) +#define Cloud_Not(p) ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ 01)) // complement the node +#define Cloud_NotCond(p,c) ((CloudNode*)(((ABC_PTRUINT_T)(p)) ^ (c))) // complement the node conditionally +#define Cloud_IsComplement(p) ((int)(((ABC_PTRUINT_T)(p)) & 01)) // check if complemented // checking constants (using node) #define Cloud_IsConstant(p) (((Cloud_Regular(p))->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX) #define cloudIsConstant(p) (((p)->v & CLOUD_MARK_OFF) == CLOUD_CONST_INDEX) @@ -213,23 +213,6 @@ struct cloudCacheEntry3 // the three-argument cache //#define CLOUD_ASSERT(p) (assert((p) >= (dd->pNodeStart-1) && (p) < dd->pNodeEnd)) #define CLOUD_ASSERT(p) assert((p) >= dd->tUnique && (p) < dd->tUnique+dd->nNodesAlloc) -// utility macros -#ifndef ALLOC -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#endif - -#ifndef CALLOC -#define CALLOC(type, num) ((type *) calloc((num), sizeof(type))) -#endif - -#ifndef FREE -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#endif - -#ifndef PRT -#define PRT(a,t) fprintf( stdout, "%s = ", (a)); printf( "%.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC) ) -#endif - //////////////////////////////////////////////////////////////////////// /// FUNCTION DECLARATIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/kit/kit.h b/src/aig/kit/kit.h index e8dea11a..3b564da5 100644 --- a/src/aig/kit/kit.h +++ b/src/aig/kit/kit.h @@ -21,10 +21,6 @@ #ifndef __KIT_H__ #define __KIT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -42,6 +38,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -140,17 +140,6 @@ struct Kit_DsdMan_t_ Vec_Int_t * vNodes; // temporary array for BDD nodes }; -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - static inline int Kit_DsdVar2Lit( int Var, int fCompl ) { return Var + Var + fCompl; } static inline int Kit_DsdLit2Var( int Lit ) { return Lit >> 1; } static inline int Kit_DsdLitIsCompl( int Lit ) { return Lit & 1; } @@ -186,20 +175,6 @@ static inline unsigned Kit_DsdLitSupport( Kit_DsdNtk_t * pNtk, int Lit ) #define KIT_MAX(a,b) (((a) > (b))? (a) : (b)) #define KIT_INFINITY (100000000) -#ifndef ALLOC -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#endif - -#ifndef FREE -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#endif - -#ifndef REALLOC -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) -#endif - static inline int Kit_CubeHasLit( unsigned uCube, int i ) { return(uCube & (unsigned)(1< 0; } static inline unsigned Kit_CubeSetLit( unsigned uCube, int i ) { return uCube | (unsigned)(1<nVars = nVars; p->nWords = Kit_TruthWordNum( p->nVars ); @@ -72,7 +72,7 @@ void Kit_DsdManFree( Kit_DsdMan_t * p ) Vec_PtrFree( p->vTtBdds ); Vec_PtrFree( p->vTtElems ); Vec_PtrFree( p->vTtNodes ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -90,7 +90,7 @@ Kit_DsdObj_t * Kit_DsdObjAlloc( Kit_DsdNtk_t * pNtk, Kit_Dsd_t Type, int nFans ) { Kit_DsdObj_t * pObj; int nSize = sizeof(Kit_DsdObj_t) + sizeof(unsigned) * (Kit_DsdObjOffset(nFans) + (Type == KIT_DSD_PRIME) * Kit_TruthWordNum(nFans)); - pObj = (Kit_DsdObj_t *)ALLOC( char, nSize ); + pObj = (Kit_DsdObj_t *)ABC_ALLOC( char, nSize ); memset( pObj, 0, nSize ); pObj->Id = pNtk->nVars + pNtk->nNodes; pObj->Type = Type; @@ -100,7 +100,7 @@ Kit_DsdObj_t * Kit_DsdObjAlloc( Kit_DsdNtk_t * pNtk, Kit_Dsd_t Type, int nFans ) if ( pNtk->nNodes == pNtk->nNodesAlloc ) { pNtk->nNodesAlloc *= 2; - pNtk->pNodes = REALLOC( Kit_DsdObj_t *, pNtk->pNodes, pNtk->nNodesAlloc ); + pNtk->pNodes = ABC_REALLOC( Kit_DsdObj_t *, pNtk->pNodes, pNtk->nNodesAlloc ); } assert( pNtk->nNodes < pNtk->nNodesAlloc ); pNtk->pNodes[pNtk->nNodes++] = pObj; @@ -120,7 +120,7 @@ Kit_DsdObj_t * Kit_DsdObjAlloc( Kit_DsdNtk_t * pNtk, Kit_Dsd_t Type, int nFans ) ***********************************************************************/ void Kit_DsdObjFree( Kit_DsdNtk_t * p, Kit_DsdObj_t * pObj ) { - free( pObj ); + ABC_FREE( pObj ); } /**Function************************************************************* @@ -137,12 +137,12 @@ void Kit_DsdObjFree( Kit_DsdNtk_t * p, Kit_DsdObj_t * pObj ) Kit_DsdNtk_t * Kit_DsdNtkAlloc( int nVars ) { Kit_DsdNtk_t * pNtk; - pNtk = ALLOC( Kit_DsdNtk_t, 1 ); + pNtk = ABC_ALLOC( Kit_DsdNtk_t, 1 ); memset( pNtk, 0, sizeof(Kit_DsdNtk_t) ); - pNtk->pNodes = ALLOC( Kit_DsdObj_t *, nVars+1 ); + pNtk->pNodes = ABC_ALLOC( Kit_DsdObj_t *, nVars+1 ); pNtk->nVars = nVars; pNtk->nNodesAlloc = nVars+1; - pNtk->pMem = ALLOC( unsigned, 6 * Kit_TruthWordNum(nVars) ); + pNtk->pMem = ABC_ALLOC( unsigned, 6 * Kit_TruthWordNum(nVars) ); return pNtk; } @@ -162,11 +162,11 @@ void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk ) Kit_DsdObj_t * pObj; unsigned i; Kit_DsdNtkForEachObj( pNtk, pObj, i ) - free( pObj ); - FREE( pNtk->pSupps ); - free( pNtk->pNodes ); - free( pNtk->pMem ); - free( pNtk ); + ABC_FREE( pObj ); + ABC_FREE( pNtk->pSupps ); + ABC_FREE( pNtk->pNodes ); + ABC_FREE( pNtk->pMem ); + ABC_FREE( pNtk ); } /**Function************************************************************* @@ -1032,7 +1032,7 @@ unsigned Kit_DsdNonDsdSupports( Kit_DsdNtk_t * pNtk ) { Kit_DsdObj_t * pObj; unsigned i, uSupport = 0; -// FREE( pNtk->pSupps ); +// ABC_FREE( pNtk->pSupps ); Kit_DsdGetSupports( pNtk ); Kit_DsdNtkForEachObj( pNtk, pObj, i ) { @@ -1531,7 +1531,7 @@ unsigned Kit_DsdGetSupports( Kit_DsdNtk_t * p ) Kit_DsdObj_t * pRoot; unsigned uSupport; assert( p->pSupps == NULL ); - p->pSupps = ALLOC( unsigned, p->nNodes ); + p->pSupps = ABC_ALLOC( unsigned, p->nNodes ); // consider simple special cases pRoot = Kit_DsdNtkRoot(p); if ( pRoot->Type == KIT_DSD_CONST1 ) @@ -2377,7 +2377,7 @@ int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit // allocate storage for cofactors nMemSize = Kit_TruthWordNum(nVars); - ppCofs[0][0] = ALLOC( unsigned, 80 * nMemSize ); + ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize ); nSize = 0; for ( i = 0; i < 5; i++ ) for ( k = 0; k < 16; k++ ) @@ -2422,7 +2422,7 @@ int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit // compute the sum total of supports nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+0], nVars ); nSuppSizeMax += Kit_TruthSupportSize( ppCofs[nStep+1][2*i+1], nVars ); - // free the networks + // ABC_FREE the networks Kit_DsdNtkFree( ppNtks[nStep+1][2*i+0] ); Kit_DsdNtkFree( ppNtks[nStep+1][2*i+1] ); } @@ -2460,12 +2460,12 @@ int Kit_DsdCofactoring( unsigned * pTruth, int nVars, int * pCofVars, int nLimit } } - // free the networks + // ABC_FREE the networks for ( i = 0; i < 5; i++ ) for ( k = 0; k < 16; k++ ) if ( ppNtks[i][k] ) Kit_DsdNtkFree( ppNtks[i][k] ); - free( ppCofs[0][0] ); + ABC_FREE( ppCofs[0][0] ); assert( nStep <= nLimit ); return nStep; @@ -2502,7 +2502,7 @@ void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVe // allocate storage for cofactors nMemSize = Kit_TruthWordNum(nVars); - ppCofs[0][0] = ALLOC( unsigned, 80 * nMemSize ); + ppCofs[0][0] = ABC_ALLOC( unsigned, 80 * nMemSize ); nSize = 0; for ( i = 0; i < 5; i++ ) for ( k = 0; k < 16; k++ ) @@ -2713,7 +2713,7 @@ void Kit_DsdPrintCofactors( unsigned * pTruth, int nVars, int nCofLevel, int fVe } - free( ppCofs[0][0] ); + ABC_FREE( ppCofs[0][0] ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/kit/kitFactor.c b/src/aig/kit/kitFactor.c index f596d9a8..273d4821 100644 --- a/src/aig/kit/kitFactor.c +++ b/src/aig/kit/kitFactor.c @@ -123,7 +123,7 @@ Kit_Edge_t Kit_SopFactor_rec( Kit_Graph_t * pFForm, Kit_Sop_t * cSop, int nLits, if ( Kit_SopCubeNum(cQuo) == 1 ) return Kit_SopFactorLF_rec( pFForm, cSop, cQuo, nLits, vMemory ); - // make the quotient cube free + // make the quotient cube ABC_FREE Kit_SopMakeCubeFree( cQuo ); // divide the cover by the quotient diff --git a/src/aig/kit/kitGraph.c b/src/aig/kit/kitGraph.c index 80dcbdc0..565c000b 100644 --- a/src/aig/kit/kitGraph.c +++ b/src/aig/kit/kitGraph.c @@ -42,12 +42,12 @@ Kit_Graph_t * Kit_GraphCreate( int nLeaves ) { Kit_Graph_t * pGraph; - pGraph = ALLOC( Kit_Graph_t, 1 ); + pGraph = ABC_ALLOC( Kit_Graph_t, 1 ); memset( pGraph, 0, sizeof(Kit_Graph_t) ); pGraph->nLeaves = nLeaves; pGraph->nSize = nLeaves; pGraph->nCap = 2 * nLeaves + 50; - pGraph->pNodes = ALLOC( Kit_Node_t, pGraph->nCap ); + pGraph->pNodes = ABC_ALLOC( Kit_Node_t, pGraph->nCap ); memset( pGraph->pNodes, 0, sizeof(Kit_Node_t) * pGraph->nSize ); return pGraph; } @@ -66,7 +66,7 @@ Kit_Graph_t * Kit_GraphCreate( int nLeaves ) Kit_Graph_t * Kit_GraphCreateConst0() { Kit_Graph_t * pGraph; - pGraph = ALLOC( Kit_Graph_t, 1 ); + pGraph = ABC_ALLOC( Kit_Graph_t, 1 ); memset( pGraph, 0, sizeof(Kit_Graph_t) ); pGraph->fConst = 1; pGraph->eRoot.fCompl = 1; @@ -87,7 +87,7 @@ Kit_Graph_t * Kit_GraphCreateConst0() Kit_Graph_t * Kit_GraphCreateConst1() { Kit_Graph_t * pGraph; - pGraph = ALLOC( Kit_Graph_t, 1 ); + pGraph = ABC_ALLOC( Kit_Graph_t, 1 ); memset( pGraph, 0, sizeof(Kit_Graph_t) ); pGraph->fConst = 1; return pGraph; @@ -127,8 +127,8 @@ Kit_Graph_t * Kit_GraphCreateLeaf( int iLeaf, int nLeaves, int fCompl ) ***********************************************************************/ void Kit_GraphFree( Kit_Graph_t * pGraph ) { - FREE( pGraph->pNodes ); - free( pGraph ); + ABC_FREE( pGraph->pNodes ); + ABC_FREE( pGraph ); } /**Function************************************************************* @@ -147,7 +147,7 @@ Kit_Node_t * Kit_GraphAppendNode( Kit_Graph_t * pGraph ) Kit_Node_t * pNode; if ( pGraph->nSize == pGraph->nCap ) { - pGraph->pNodes = REALLOC( Kit_Node_t, pGraph->pNodes, 2 * pGraph->nCap ); + pGraph->pNodes = ABC_REALLOC( Kit_Node_t, pGraph->pNodes, 2 * pGraph->nCap ); pGraph->nCap = 2 * pGraph->nCap; } pNode = pGraph->pNodes + pGraph->nSize++; diff --git a/src/aig/kit/kitSop.c b/src/aig/kit/kitSop.c index 8e175dac..0d1b9e2c 100644 --- a/src/aig/kit/kitSop.c +++ b/src/aig/kit/kitSop.c @@ -296,7 +296,7 @@ static inline unsigned Kit_SopCommonCube( Kit_Sop_t * cSop ) /**Function************************************************************* - Synopsis [Makes the cover cube-free.] + Synopsis [Makes the cover cube-ABC_FREE.] Description [] @@ -319,7 +319,7 @@ void Kit_SopMakeCubeFree( Kit_Sop_t * cSop ) /**Function************************************************************* - Synopsis [Checks if the cover is cube-free.] + Synopsis [Checks if the cover is cube-ABC_FREE.] Description [] @@ -510,7 +510,7 @@ void Kit_SopDivisorZeroKernel_rec( Kit_Sop_t * cSop, int nLits ) iLit = Kit_SopWorstLiteral( cSop, nLits ); if ( iLit == -1 ) return; - // derive the cube-free quotient + // derive the cube-ABC_FREE quotient Kit_SopDivideByLiteralQuo( cSop, iLit ); // the same cover Kit_SopMakeCubeFree( cSop ); // the same cover // call recursively diff --git a/src/aig/mem/mem.c b/src/aig/mem/mem.c index 911ceffb..99d918e9 100644 --- a/src/aig/mem/mem.c +++ b/src/aig/mem/mem.c @@ -22,6 +22,7 @@ #include #include #include +#include "abc_global.h" #include "mem.h" //////////////////////////////////////////////////////////////////////// @@ -35,7 +36,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 free entries + char * pEntriesFree; // the linked list of ABC_FREE entries // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -52,8 +53,8 @@ struct Mem_Flex_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 + char * pCurrent; // the current pointer to ABC_FREE memory + char * pEnd; // the first entry outside the ABC_FREE memory // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -74,12 +75,6 @@ struct Mem_Step_t_ Mem_Fixed_t ** pMap; // maps the number of bytes into its memory manager }; -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) - //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -100,7 +95,7 @@ Mem_Fixed_t * Mem_FixedStart( int nEntrySize ) { Mem_Fixed_t * p; - p = ALLOC( Mem_Fixed_t, 1 ); + p = ABC_ALLOC( Mem_Fixed_t, 1 ); memset( p, 0, sizeof(Mem_Fixed_t) ); p->nEntrySize = nEntrySize; @@ -117,7 +112,7 @@ Mem_Fixed_t * Mem_FixedStart( int nEntrySize ) p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -148,9 +143,9 @@ void Mem_FixedStop( Mem_Fixed_t * p, int fVerbose ) p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -169,16 +164,16 @@ char * Mem_FixedEntryFetch( Mem_Fixed_t * p ) char * pTemp; int i; - // check if there are still free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize ); + 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; @@ -198,7 +193,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 free entry list + // return the first entry in the ABC_FREE entry list pTemp = p->pEntriesFree; p->pEntriesFree = *((char **)pTemp); return pTemp; @@ -219,7 +214,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 free entries + // add the entry to the linked list of ABC_FREE entries *((char **)pEntry) = p->pEntriesFree; p->pEntriesFree = pEntry; } @@ -242,7 +237,7 @@ void Mem_FixedRestart( Mem_Fixed_t * p ) // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; // transform these entries into a linked list pTemp = p->pChunks[0]; @@ -253,7 +248,7 @@ void Mem_FixedRestart( Mem_Fixed_t * p ) } // set the last link *((char **)pTemp) = NULL; - // set the free entry list + // set the ABC_FREE entry list p->pEntriesFree = p->pChunks[0]; // set the correct statistics p->nMemoryAlloc = p->nEntrySize * p->nChunkSize; @@ -311,7 +306,7 @@ Mem_Flex_t * Mem_FlexStart() { Mem_Flex_t * p; - p = ALLOC( Mem_Flex_t, 1 ); + p = ABC_ALLOC( Mem_Flex_t, 1 ); memset( p, 0, sizeof(Mem_Flex_t) ); p->nEntriesUsed = 0; @@ -321,7 +316,7 @@ Mem_Flex_t * Mem_FlexStart() p->nChunkSize = (1 << 14); p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -352,9 +347,9 @@ void Mem_FlexStop( Mem_Flex_t * p, int fVerbose ) p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -371,13 +366,13 @@ 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 free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } if ( nBytes > p->nChunkSize ) { @@ -385,7 +380,7 @@ char * Mem_FlexEntryFetch( Mem_Flex_t * p, int nBytes ) // (ideally, this should never happen) p->nChunkSize = 2 * nBytes; } - p->pCurrent = ALLOC( char, p->nChunkSize ); + p->pCurrent = ABC_ALLOC( char, p->nChunkSize ); p->pEnd = p->pCurrent + p->nChunkSize; p->nMemoryAlloc += p->nChunkSize; // add the chunk to the chunk storage @@ -420,7 +415,7 @@ void Mem_FlexRestart( Mem_Flex_t * p ) return; // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; p->nMemoryAlloc = p->nChunkSize; // transform these entries into a linked list @@ -463,7 +458,7 @@ int Mem_FlexReadMemUsage( Mem_Flex_t * p ) 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 free()ed.] + entries are handed over to malloc() and then ABC_FREE()ed.] SideEffects [] @@ -474,16 +469,16 @@ Mem_Step_t * Mem_StepStart( int nSteps ) { Mem_Step_t * p; int i, k; - p = ALLOC( Mem_Step_t, 1 ); + p = ABC_ALLOC( Mem_Step_t, 1 ); memset( p, 0, sizeof(Mem_Step_t) ); p->nMems = nSteps; // start the fixed memory managers - p->pMems = ALLOC( Mem_Fixed_t *, p->nMems ); + p->pMems = ABC_ALLOC( Mem_Fixed_t *, p->nMems ); for ( i = 0; i < p->nMems; i++ ) p->pMems[i] = Mem_FixedStart( (8<nMapSize = (4<nMems); - p->pMap = ALLOC( Mem_Fixed_t *, p->nMapSize+1 ); + p->pMap = ABC_ALLOC( Mem_Fixed_t *, p->nMapSize+1 ); p->pMap[0] = NULL; for ( k = 1; k <= 4; k++ ) p->pMap[k] = p->pMems[0]; @@ -514,12 +509,12 @@ void Mem_StepStop( Mem_Step_t * p, int fVerbose ) // if ( p->pLargeChunks ) // { // for ( i = 0; i < p->nLargeChunks; i++ ) -// free( p->pLargeChunks[i] ); -// free( p->pLargeChunks ); +// ABC_FREE( p->pLargeChunks[i] ); +// ABC_FREE( p->pLargeChunks ); // } - free( p->pMems ); - free( p->pMap ); - free( p ); + ABC_FREE( p->pMems ); + ABC_FREE( p->pMap ); + ABC_FREE( p ); } /**Function************************************************************* @@ -546,12 +541,12 @@ char * Mem_StepEntryFetch( Mem_Step_t * p, int nBytes ) if ( p->nLargeChunksAlloc == 0 ) p->nLargeChunksAlloc = 5; p->nLargeChunksAlloc *= 2; - p->pLargeChunks = REALLOC( char *, p->pLargeChunks, p->nLargeChunksAlloc ); + p->pLargeChunks = ABC_REALLOC( char *, p->pLargeChunks, p->nLargeChunksAlloc ); } - p->pLargeChunks[ p->nLargeChunks++ ] = ALLOC( char, nBytes ); + p->pLargeChunks[ p->nLargeChunks++ ] = ABC_ALLOC( char, nBytes ); return p->pLargeChunks[ p->nLargeChunks - 1 ]; */ - return ALLOC( char, nBytes ); + return ABC_ALLOC( char, nBytes ); } return Mem_FixedEntryFetch( p->pMap[nBytes] ); } @@ -574,7 +569,7 @@ void Mem_StepEntryRecycle( Mem_Step_t * p, char * pEntry, int nBytes ) return; if ( nBytes > p->nMapSize ) { -// free( pEntry ); +// ABC_FREE( pEntry ); return; } Mem_FixedEntryRecycle( p->pMap[nBytes], pEntry ); diff --git a/src/aig/mfx/mfx.h b/src/aig/mfx/mfx.h index aae9e625..09c4f039 100644 --- a/src/aig/mfx/mfx.h +++ b/src/aig/mfx/mfx.h @@ -21,10 +21,6 @@ #ifndef __MFX_H__ #define __MFX_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/mfx/mfxCore.c b/src/aig/mfx/mfxCore.c index f67fb520..c0d3b650 100644 --- a/src/aig/mfx/mfxCore.c +++ b/src/aig/mfx/mfxCore.c @@ -355,7 +355,7 @@ int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib ) 1.0*p->nNodesGainedLevel/Vec_PtrSize(vNodes), 1.0*p->nTotConfLevel/Vec_PtrSize(vNodes), 100.0*p->nTimeOutsLevel/Vec_PtrSize(vNodes) ); - PRT( "Time", clock() - clk2 ); + ABC_PRT( "Time", clock() - clk2 ); } } @@ -371,7 +371,7 @@ int Mfx_Perform( Nwk_Man_t * pNtk, Mfx_Par_t * pPars, If_Lib_t * pLutLib ) if ( pPars->fPower ) printf( "Total switching after = %7.2f.\n", Nwl_ManComputeTotalSwitching(pNtk) ); - // free the manager + // ABC_FREE the manager p->timeTotal = clock() - clk; Mfx_ManStop( p ); diff --git a/src/aig/mfx/mfxInt.h b/src/aig/mfx/mfxInt.h index 9095c8ce..4263724c 100644 --- a/src/aig/mfx/mfxInt.h +++ b/src/aig/mfx/mfxInt.h @@ -21,10 +21,6 @@ #ifndef __MFX_INT_H__ #define __MFX_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -41,6 +37,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define MFX_FANIN_MAX 12 typedef struct Mfx_Man_t_ Mfx_Man_t; diff --git a/src/aig/mfx/mfxInter.c b/src/aig/mfx/mfxInter.c index a42e02fe..3e1e3de2 100644 --- a/src/aig/mfx/mfxInter.c +++ b/src/aig/mfx/mfxInter.c @@ -222,7 +222,7 @@ unsigned * Mfx_InterplateTruth( Mfx_Man_t * p, int * pCands, int nCands, int fIn pSat = Mfx_CreateSolverResub( p, pCands, nCands, fInvert ); // solve the problem - status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status != l_False ) { p->nTimeOuts++; @@ -322,7 +322,7 @@ Hop_Obj_t * Mfx_Interplate( Mfx_Man_t * p, int * pCands, int nCands ) pSat = Mfx_CreateSolverResub( p, pCands, nCands, 0 ); // solve the problem - status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status != l_False ) { p->nTimeOuts++; diff --git a/src/aig/mfx/mfxMan.c b/src/aig/mfx/mfxMan.c index b8361a20..2af3d573 100644 --- a/src/aig/mfx/mfxMan.c +++ b/src/aig/mfx/mfxMan.c @@ -43,7 +43,7 @@ Mfx_Man_t * Mfx_ManAlloc( Mfx_Par_t * pPars ) { Mfx_Man_t * p; // start the manager - p = ALLOC( Mfx_Man_t, 1 ); + p = ABC_ALLOC( Mfx_Man_t, 1 ); memset( p, 0, sizeof(Mfx_Man_t) ); p->pPars = pPars; p->vProjVars = Vec_IntAlloc( 100 ); @@ -135,13 +135,13 @@ void Mfx_ManPrint( Mfx_Man_t * p ) p->nNodesDec, 1.0 * p->nNodesDec / p->nNodesTried, p->nNodesGained, p->nTimeOuts ); } /* - PRTP( "Win", p->timeWin , p->timeTotal ); - PRTP( "Div", p->timeDiv , p->timeTotal ); - PRTP( "Aig", p->timeAig , p->timeTotal ); - PRTP( "Cnf", p->timeCnf , p->timeTotal ); - PRTP( "Sat", p->timeSat-p->timeInt , p->timeTotal ); - PRTP( "Int", p->timeInt , p->timeTotal ); - PRTP( "ALL", p->timeTotal , p->timeTotal ); + ABC_PRTP( "Win", p->timeWin , p->timeTotal ); + ABC_PRTP( "Div", p->timeDiv , p->timeTotal ); + ABC_PRTP( "Aig", p->timeAig , p->timeTotal ); + ABC_PRTP( "Cnf", p->timeCnf , p->timeTotal ); + ABC_PRTP( "Sat", p->timeSat-p->timeInt , p->timeTotal ); + ABC_PRTP( "Int", p->timeInt , p->timeTotal ); + ABC_PRTP( "ALL", p->timeTotal , p->timeTotal ); */ } @@ -178,7 +178,7 @@ void Mfx_ManStop( Mfx_Man_t * p ) Vec_IntFree( p->vProjVars ); Vec_IntFree( p->vDivLits ); Vec_PtrFree( p->vDivCexes ); - free( p ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/mfx/mfxResub.c b/src/aig/mfx/mfxResub.c index 312ae226..a9ed23a0 100644 --- a/src/aig/mfx/mfxResub.c +++ b/src/aig/mfx/mfxResub.c @@ -97,7 +97,7 @@ int Mfx_TryResubOnce( Mfx_Man_t * p, int * pCands, int nCands ) unsigned * pData; int RetValue, iVar, i; p->nSatCalls++; - RetValue = sat_solver_solve( p->pSat, pCands, pCands + nCands, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSat, pCands, pCands + nCands, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); // assert( RetValue == l_False || RetValue == l_True ); if ( RetValue == l_False ) return 1; diff --git a/src/aig/mfx/mfxSat.c b/src/aig/mfx/mfxSat.c index 9dd42e8c..ce8d580b 100644 --- a/src/aig/mfx/mfxSat.c +++ b/src/aig/mfx/mfxSat.c @@ -46,7 +46,7 @@ int Mfx_SolveSat_iter( Mfx_Man_t * p ) if ( p->nTotConfLim && p->nTotConfLim <= p->pSat->stats.conflicts ) return -1; nBTLimit = p->nTotConfLim? p->nTotConfLim - p->pSat->stats.conflicts : 0; - RetValue = sat_solver_solve( p->pSat, NULL, NULL, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSat, NULL, NULL, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); assert( RetValue == l_Undef || RetValue == l_True || RetValue == l_False ); if ( RetValue == l_Undef ) return -1; diff --git a/src/aig/ntl/ntl.h b/src/aig/ntl/ntl.h index ac266ca5..0a44d2dc 100644 --- a/src/aig/ntl/ntl.h +++ b/src/aig/ntl/ntl.h @@ -21,10 +21,6 @@ #ifndef __NTL_H__ #define __NTL_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -185,17 +185,6 @@ struct Ntl_Lut_t_ /// INLINED FUNCTIONS /// //////////////////////////////////////////////////////////////////////// -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - static inline Ntl_Mod_t * Ntl_ManRootModel( Ntl_Man_t * p ) { return (Ntl_Mod_t *)Vec_PtrEntry( p->vModels, 0 ); } static inline int Ntl_ModelPiNum( Ntl_Mod_t * p ) { return p->nObjs[NTL_OBJ_PI]; } diff --git a/src/aig/ntl/ntlFraig.c b/src/aig/ntl/ntlFraig.c index d2ae4204..405ec83f 100644 --- a/src/aig/ntl/ntlFraig.c +++ b/src/aig/ntl/ntlFraig.c @@ -52,7 +52,7 @@ void Ntl_ManUpdateNoMergeReprs( Aig_Man_t * pAig, Aig_Obj_t ** pReprs ) int i; // allocate room for the new representative - pReprsNew = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) ); + pReprsNew = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) ); memset( pReprsNew, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) ); Aig_ManForEachObj( pAig, pObj, i ) { @@ -105,7 +105,7 @@ void Ntl_ManUpdateNoMergeReprs( Aig_Man_t * pAig, Aig_Obj_t ** pReprs ) else pReprs[ pObj->Id ] = NULL; } - free( pReprsNew ); + ABC_FREE( pReprsNew ); } /**Function************************************************************* @@ -148,7 +148,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_ // (each node in the collapsed manager may have more than one equivalent node // in the original manager; this procedure finds the first node in the original // manager that is equivalent to the given node in the collapsed manager) - pMapBack = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAigCol) ); + pMapBack = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAigCol) ); memset( pMapBack, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAigCol) ); Aig_ManForEachObj( pAig, pObj, i ) { @@ -162,7 +162,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_ } // create the equivalence classes for the original manager - pReprs = ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) ); + pReprs = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pAig) ); memset( pReprs, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pAig) ); Aig_ManForEachObj( pAig, pObj, i ) { @@ -186,7 +186,7 @@ Aig_Obj_t ** Ntl_ManFraigDeriveClasses( Aig_Man_t * pAig, Ntl_Man_t * pNew, Aig_ else pReprs[pCorresp->Id] = pObj; } - free( pMapBack ); + ABC_FREE( pMapBack ); // recall pointers to the nets of pNew Aig_ManForEachObj( pAig, pObj, i ) diff --git a/src/aig/ntl/ntlMan.c b/src/aig/ntl/ntlMan.c index 8b26e405..552d5c15 100644 --- a/src/aig/ntl/ntlMan.c +++ b/src/aig/ntl/ntlMan.c @@ -43,7 +43,7 @@ Ntl_Man_t * Ntl_ManAlloc() { Ntl_Man_t * p; // start the manager - p = ALLOC( Ntl_Man_t, 1 ); + p = ABC_ALLOC( Ntl_Man_t, 1 ); memset( p, 0, sizeof(Ntl_Man_t) ); p->vModels = Vec_PtrAlloc( 1000 ); p->vCis = Vec_PtrAlloc( 1000 ); @@ -56,7 +56,7 @@ Ntl_Man_t * Ntl_ManAlloc() p->pMemSops = Aig_MmFlexStart(); // allocate model table p->nModTableSize = Aig_PrimeCudd( 100 ); - p->pModTable = ALLOC( Ntl_Mod_t *, p->nModTableSize ); + p->pModTable = ABC_ALLOC( Ntl_Mod_t *, p->nModTableSize ); memset( p->pModTable, 0, sizeof(Ntl_Mod_t *) * p->nModTableSize ); return p; } @@ -203,8 +203,8 @@ void Ntl_ManFree( Ntl_Man_t * p ) if ( p->pAig ) Aig_ManStop( p->pAig ); if ( p->pManTime ) Tim_ManStop( p->pManTime ); if ( p->pNal ) p->pNalF( p->pNal ); - FREE( p->pModTable ); - free( p ); + ABC_FREE( p->pModTable ); + ABC_FREE( p ); } /**Function************************************************************* @@ -266,7 +266,7 @@ void Nwk_ManPrintStatsShort( Ntl_Man_t * p, Aig_Man_t * pAig, Nwk_Man_t * pNtk ) printf( "ff =%5d ", Counter ); if ( pAig != NULL ) { - Counter = Aig_ManCountChoices( pAig ); + Counter = Aig_ManChoiceNum( pAig ); if ( Counter ) printf( "cho =%7d ", Counter ); else @@ -392,7 +392,7 @@ Ntl_Mod_t * Ntl_ModelAlloc( Ntl_Man_t * pMan, char * pName ) { Ntl_Mod_t * p; // start the manager - p = ALLOC( Ntl_Mod_t, 1 ); + p = ABC_ALLOC( Ntl_Mod_t, 1 ); memset( p, 0, sizeof(Ntl_Mod_t) ); p->attrBox = 1; p->attrComb = 1; @@ -407,7 +407,7 @@ Ntl_Mod_t * Ntl_ModelAlloc( Ntl_Man_t * pMan, char * pName ) p->vNets = Vec_PtrAlloc( 100 ); // start the table p->nTableSize = Aig_PrimeCudd( 100 ); - p->pTable = ALLOC( Ntl_Net_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Ntl_Net_t *, p->nTableSize ); memset( p->pTable, 0, sizeof(Ntl_Net_t *) * p->nTableSize ); // add model to the table if ( !Ntl_ManAddModel( pMan, p ) ) @@ -562,8 +562,8 @@ void Ntl_ModelFree( Ntl_Mod_t * p ) Vec_PtrFree( p->vObjs ); Vec_PtrFree( p->vPis ); Vec_PtrFree( p->vPos ); - free( p->pTable ); - free( p ); + ABC_FREE( p->pTable ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/ntl/ntlMap.c b/src/aig/ntl/ntlMap.c index c6e80e75..10e7dd17 100644 --- a/src/aig/ntl/ntlMap.c +++ b/src/aig/ntl/ntlMap.c @@ -47,7 +47,7 @@ Vec_Ptr_t * Ntl_MappingAlloc( int nLuts, int nVars ) Ntl_Lut_t ** pArray; int nEntrySize, i; nEntrySize = sizeof(Ntl_Lut_t) + sizeof(int) * nVars + sizeof(unsigned) * Aig_TruthWordNum(nVars); - pArray = (Ntl_Lut_t **)malloc( (sizeof(Ntl_Lut_t *) + nEntrySize) * nLuts ); + pArray = (Ntl_Lut_t **)ABC_ALLOC( char, (sizeof(Ntl_Lut_t *) + nEntrySize) * nLuts ); pMemory = (char *)(pArray + nLuts); memset( pMemory, 0, nEntrySize * nLuts ); for ( i = 0; i < nLuts; i++ ) @@ -312,7 +312,7 @@ Vec_Ptr_t * Ntl_MappingIf( Ntl_Man_t * pMan, Aig_Man_t * p ) // perform FPGA mapping Ntl_ManSetIfParsDefault( pPars ); // set the arrival times - pPars->pTimesArr = ALLOC( float, Aig_ManPiNum(p) ); + pPars->pTimesArr = ABC_ALLOC( float, Aig_ManPiNum(p) ); memset( pPars->pTimesArr, 0, sizeof(float) * Aig_ManPiNum(p) ); // translate into the mapper pIfMan = Ntl_ManToIf( p, pPars ); diff --git a/src/aig/ntl/ntlReadBlif.c b/src/aig/ntl/ntlReadBlif.c index 3021d556..f94595b8 100644 --- a/src/aig/ntl/ntlReadBlif.c +++ b/src/aig/ntl/ntlReadBlif.c @@ -213,7 +213,7 @@ Ntl_Man_t * Ioa_ReadBlif( char * pFileName, int fCheck ) static Ioa_ReadMan_t * Ioa_ReadAlloc() { Ioa_ReadMan_t * p; - p = ALLOC( Ioa_ReadMan_t, 1 ); + p = ABC_ALLOC( Ioa_ReadMan_t, 1 ); memset( p, 0, sizeof(Ioa_ReadMan_t) ); p->vLines = Vec_PtrAlloc( 512 ); p->vModels = Vec_PtrAlloc( 512 ); @@ -241,7 +241,7 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p ) if ( p->pDesign ) Ntl_ManFree( p->pDesign ); if ( p->pBuffer ) - free( p->pBuffer ); + ABC_FREE( p->pBuffer ); if ( p->vLines ) Vec_PtrFree( p->vLines ); if ( p->vModels ) @@ -253,7 +253,7 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p ) Vec_PtrFree( p->vTokens ); Vec_PtrFree( p->vTokens2 ); Vec_StrFree( p->vFunc ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -270,7 +270,7 @@ static void Ioa_ReadFree( Ioa_ReadMan_t * p ) static Ioa_ReadMod_t * Ioa_ReadModAlloc() { Ioa_ReadMod_t * p; - p = ALLOC( Ioa_ReadMod_t, 1 ); + p = ABC_ALLOC( Ioa_ReadMod_t, 1 ); memset( p, 0, sizeof(Ioa_ReadMod_t) ); p->vInputs = Vec_PtrAlloc( 8 ); p->vOutputs = Vec_PtrAlloc( 8 ); @@ -304,7 +304,7 @@ static void Ioa_ReadModFree( Ioa_ReadMod_t * p ) Vec_PtrFree( p->vDelays ); Vec_PtrFree( p->vTimeInputs ); Vec_PtrFree( p->vTimeOutputs ); - free( p ); + ABC_FREE( p ); } @@ -448,7 +448,7 @@ static char * Ioa_ReadLoadFile( char * pFileName ) printf( "Ioa_ReadLoadFile(): The file is empty.\n" ); return NULL; } - pContents = ALLOC( char, nFileSize + 10 ); + pContents = ABC_ALLOC( char, nFileSize + 10 ); rewind( pFile ); fread( pContents, nFileSize, 1, pFile ); fclose( pFile ); @@ -498,9 +498,9 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName ) } do { if (!bufHead) - buf = bufHead = ALLOC( buflist, 1 ); + buf = bufHead = ABC_ALLOC( buflist, 1 ); else - buf = buf->next = ALLOC( buflist, 1 ); + buf = buf->next = ABC_ALLOC( buflist, 1 ); nFileSize += buf->nBuf = BZ2_bzRead(&bzError,b,buf->buf,1<<20); buf->next = NULL; } while (bzError == BZ_OK); @@ -509,14 +509,14 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName ) char * p; int nBytes = 0; BZ2_bzReadClose(&bzError,b); - p = pContents = ALLOC( char, nFileSize + 10 ); + p = pContents = ABC_ALLOC( char, nFileSize + 10 ); buf = bufHead; do { memcpy(p+nBytes,buf->buf,buf->nBuf); nBytes += buf->nBuf; // } while((buf = buf->next)); pNext = buf->next; - free( buf ); + ABC_FREE( buf ); } while((buf = pNext)); } else if (bzError == BZ_DATA_ERROR_MAGIC) { // not a BZIP2 file @@ -528,7 +528,7 @@ static char * Ioa_ReadLoadFileBz2( char * pFileName ) printf( "Ioa_ReadLoadFileBz2(): The file is empty.\n" ); return NULL; } - pContents = ALLOC( char, nFileSize + 10 ); + pContents = ABC_ALLOC( char, nFileSize + 10 ); rewind( pFile ); fread( pContents, nFileSize, 1, pFile ); } else { @@ -561,12 +561,12 @@ static char * Ioa_ReadLoadFileGz( char * pFileName ) 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 - pContents = ALLOC( char, nFileSize ); + pContents = ABC_ALLOC( char, nFileSize ); readBlock = 0; while ((amtRead = gzread(pFile, pContents + readBlock * READ_BLOCK_SIZE, READ_BLOCK_SIZE)) == READ_BLOCK_SIZE) { //printf("%d: read %d bytes\n", readBlock, amtRead); nFileSize += READ_BLOCK_SIZE; - pContents = REALLOC(char, pContents, nFileSize); + pContents = ABC_REALLOC(char, pContents, nFileSize); ++readBlock; } //printf("%d: read %d bytes\n", readBlock, amtRead); diff --git a/src/aig/ntl/ntlTable.c b/src/aig/ntl/ntlTable.c index 62f65d6c..d227b1b9 100644 --- a/src/aig/ntl/ntlTable.c +++ b/src/aig/ntl/ntlTable.c @@ -82,7 +82,7 @@ clk = clock(); // get the new table size nTableSizeNew = Aig_PrimeCudd( 3 * p->nTableSize ); // allocate a new array - pTableNew = ALLOC( Ntl_Net_t *, nTableSizeNew ); + pTableNew = ABC_ALLOC( Ntl_Net_t *, nTableSizeNew ); memset( pTableNew, 0, sizeof(Ntl_Net_t *) * nTableSizeNew ); // rehash entries Counter = 0; @@ -97,9 +97,9 @@ clk = clock(); } assert( Counter == p->nEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", p->nTableSize, nTableSizeNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( p->pTable ); + ABC_FREE( p->pTable ); p->pTable = pTableNew; p->nTableSize = nTableSizeNew; } @@ -447,7 +447,7 @@ clk = clock(); // get the new table size nModTableSizeNew = Aig_PrimeCudd( 3 * p->nModTableSize ); // allocate a new array - pModTableNew = ALLOC( Ntl_Mod_t *, nModTableSizeNew ); + pModTableNew = ABC_ALLOC( Ntl_Mod_t *, nModTableSizeNew ); memset( pModTableNew, 0, sizeof(Ntl_Mod_t *) * nModTableSizeNew ); // rehash entries Counter = 0; @@ -462,9 +462,9 @@ clk = clock(); } assert( Counter == p->nModEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", p->nTableSize, nTableSizeNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( p->pModTable ); + ABC_FREE( p->pModTable ); p->pModTable = pModTableNew; p->nModTableSize = nModTableSizeNew; } diff --git a/src/aig/ntl/ntlTime.c b/src/aig/ntl/ntlTime.c index 121fb8ea..f9fadaa8 100644 --- a/src/aig/ntl/ntlTime.c +++ b/src/aig/ntl/ntlTime.c @@ -44,7 +44,7 @@ float * Ntl_ManCreateDelayTable( Vec_Int_t * vDelays, int nIns, int nOuts ) float * pDelayTable, Delay; int iIn, iOut, i, k; assert( Vec_IntSize(vDelays) % 3 == 0 ); - pDelayTable = ALLOC( float, nIns * nOuts ); + pDelayTable = ABC_ALLOC( float, nIns * nOuts ); memset( pDelayTable, 0, sizeof(float) * nIns * nOuts ); Vec_IntForEachEntry( vDelays, iIn, i ) { diff --git a/src/aig/ntl/ntlUtil.c b/src/aig/ntl/ntlUtil.c index 6e797590..9c3d4e42 100644 --- a/src/aig/ntl/ntlUtil.c +++ b/src/aig/ntl/ntlUtil.c @@ -390,7 +390,7 @@ Vec_Vec_t * Ntl_ManTransformRegClasses( Ntl_Man_t * pMan, int nSizeMax, int fVer return NULL; } // count the number of classes - pClassNums = CALLOC( int, ClassMax + 1 ); + pClassNums = ABC_CALLOC( int, ClassMax + 1 ); Vec_IntForEachEntry( pMan->vRegClasses, Class, k ) pClassNums[Class]++; // count the number of classes @@ -417,7 +417,7 @@ Vec_Vec_t * Ntl_ManTransformRegClasses( Ntl_Man_t * pMan, int nSizeMax, int fVer Vec_PtrPush( vParts, vPart ); } printf( "There is only one class with %d registers.\n", Vec_IntSize(pMan->vRegClasses) ); - free( pClassNums ); + ABC_FREE( pClassNums ); return (Vec_Vec_t *)vParts; } // create classes @@ -433,7 +433,7 @@ Vec_Vec_t * Ntl_ManTransformRegClasses( Ntl_Man_t * pMan, int nSizeMax, int fVer assert( Vec_IntSize(vPart) == pClassNums[i] ); Vec_PtrPush( vParts, vPart ); } - free( pClassNums ); + ABC_FREE( pClassNums ); Vec_VecSort( (Vec_Vec_t *)vParts, 1 ); // report the selected classes if ( fVerbose ) diff --git a/src/aig/ntl/ntlWriteBlif.c b/src/aig/ntl/ntlWriteBlif.c index 3df49270..4099d738 100644 --- a/src/aig/ntl/ntlWriteBlif.c +++ b/src/aig/ntl/ntlWriteBlif.c @@ -270,7 +270,7 @@ int fprintfBz2(bz2file * b, char * fmt, ...) { b->nBytesMax = b->nBytes + 1; else b->nBytesMax *= 2; - if ((newBuf = REALLOC( char,b->buf,b->nBytesMax )) == NULL) + if ((newBuf = ABC_REALLOC( char,b->buf,b->nBytesMax )) == NULL) return -1; else b->buf = newBuf; @@ -645,14 +645,14 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName ) memset(&b,0,sizeof(b)); b.nBytesMax = (1<<12); - b.buf = ALLOC( char,b.nBytesMax ); + b.buf = ABC_ALLOC( char,b.nBytesMax ); // start the output stream b.f = fopen( pFileName, "wb" ); if ( b.f == NULL ) { fprintf( stdout, "Ioa_WriteBlif(): Cannot open the output file \"%s\".\n", pFileName ); - FREE(b.buf); + ABC_FREE(b.buf); return; } if (!strncmp(pFileName+strlen(pFileName)-4,".bz2",4)) { @@ -661,7 +661,7 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName ) BZ2_bzWriteClose( &bzError, b.b, 0, NULL, NULL ); fprintf( stdout, "Ioa_WriteBlif(): Cannot start compressed stream.\n" ); fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); return; } } @@ -676,12 +676,12 @@ void Ioa_WriteBlif( Ntl_Man_t * p, char * pFileName ) if (bzError == BZ_IO_ERROR) { fprintf( stdout, "Ioa_WriteBlif(): I/O error closing compressed stream.\n" ); fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); return; } } fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); } diff --git a/src/aig/nwk/nwk.h b/src/aig/nwk/nwk.h index 0ea8241b..c8cc91cb 100644 --- a/src/aig/nwk/nwk.h +++ b/src/aig/nwk/nwk.h @@ -20,10 +20,6 @@ #ifndef __NWK_H__ #define __NWK_H__ - -#ifdef __cplusplus -extern "C" { -#endif //////////////////////////////////////////////////////////////////////// /// INCLUDES /// @@ -39,6 +35,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -120,19 +120,6 @@ struct Nwk_Obj_t_ /// INLINED FUNCTIONS /// //////////////////////////////////////////////////////////////////////// -//#pragma warning( disable : 4273 ) - -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - 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]; } diff --git a/src/aig/nwk/nwkBidec.c b/src/aig/nwk/nwkBidec.c index 2b60d779..13abf81f 100644 --- a/src/aig/nwk/nwkBidec.c +++ b/src/aig/nwk/nwkBidec.c @@ -160,7 +160,7 @@ void Nwk_ManBidecResyn( Nwk_Man_t * pNtk, int fVerbose ) if ( fVerbose ) { printf( "Total gain in AIG nodes = %d. ", nGainTotal ); - PRT( "Total runtime", clock() - clk ); + ABC_PRT( "Total runtime", clock() - clk ); } } diff --git a/src/aig/nwk/nwkFlow.c b/src/aig/nwk/nwkFlow.c index b6155056..5efd0233 100644 --- a/src/aig/nwk/nwkFlow.c +++ b/src/aig/nwk/nwkFlow.c @@ -501,7 +501,7 @@ Vec_Ptr_t * Nwk_ManRetimeCutForward( Nwk_Man_t * pMan, int nLatches, int fVerbos if ( fVerbose ) { printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } return vNodes; } @@ -588,7 +588,7 @@ Vec_Ptr_t * Nwk_ManRetimeCutBackward( Nwk_Man_t * pMan, int nLatches, int fVerbo if ( fVerbose ) { printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } return vNodes; } diff --git a/src/aig/nwk/nwkMan.c b/src/aig/nwk/nwkMan.c index 6b67d3c1..d6e20672 100644 --- a/src/aig/nwk/nwkMan.c +++ b/src/aig/nwk/nwkMan.c @@ -42,7 +42,7 @@ Nwk_Man_t * Nwk_ManAlloc() { Nwk_Man_t * p; - p = ALLOC( Nwk_Man_t, 1 ); + p = ABC_ALLOC( Nwk_Man_t, 1 ); memset( p, 0, sizeof(Nwk_Man_t) ); p->vCis = Vec_PtrAlloc( 1000 ); p->vCos = Vec_PtrAlloc( 1000 ); @@ -68,8 +68,8 @@ Nwk_Man_t * Nwk_ManAlloc() 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->pName ) ABC_FREE( p->pName ); + if ( p->pSpec ) ABC_FREE( p->pSpec ); if ( p->vCis ) Vec_PtrFree( p->vCis ); if ( p->vCos ) Vec_PtrFree( p->vCos ); if ( p->vObjs ) Vec_PtrFree( p->vObjs ); @@ -77,7 +77,7 @@ void Nwk_ManFree( Nwk_Man_t * p ) if ( p->pManTime ) Tim_ManStop( p->pManTime ); if ( p->pMemObjs ) Aig_MmFlexStop( p->pMemObjs, 0 ); if ( p->pManHop ) Hop_ManStop( p->pManHop ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -127,10 +127,10 @@ int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl ) int nPis; // the number of primary inputs int nPos; // the number of primary outputs } ParsNew, ParsBest = { 0 }; - // free storage for the name + // ABC_FREE storage for the name if ( pNtk == NULL ) { - FREE( ParsBest.pName ); + ABC_FREE( ParsBest.pName ); return 0; } // get the parameters @@ -146,7 +146,7 @@ int Nwk_ManCompareAndSaveBest( Nwk_Man_t * pNtk, void * pNtl ) (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops) || (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes > ParsNew.Nodes) ) { - FREE( ParsBest.pName ); + ABC_FREE( ParsBest.pName ); ParsBest.pName = Aig_UtilStrsav( pNtk->pName ); ParsBest.Depth = ParsNew.Depth; ParsBest.Flops = ParsNew.Flops; @@ -242,7 +242,7 @@ void Nwk_ManPrintStats( Nwk_Man_t * pNtk, If_Lib_t * pLutLib, int fSaveBest, int Ioa_WriteBlifLogic( pNtk, pNtl, Buffer ); // sprintf( Buffer, "%s_dump_map.blif", pNameGen ); // Nwk_ManDumpBlif( pNtk, Buffer, NULL, NULL ); - if ( pNtk->pSpec ) free( pNameGen ); + if ( pNtk->pSpec ) ABC_FREE( pNameGen ); } pNtk->pLutLib = pLutLib; diff --git a/src/aig/nwk/nwkMap.c b/src/aig/nwk/nwkMap.c index a70bb9b1..e6865840 100644 --- a/src/aig/nwk/nwkMap.c +++ b/src/aig/nwk/nwkMap.c @@ -113,7 +113,7 @@ If_Man_t * Nwk_ManToIf( Aig_Man_t * p, If_Par_t * pPars, Vec_Ptr_t * vAigToIf ) vSwitching = Saig_ManComputeSwitchProbs( p, 48, 16, 0 ); if ( pPars->fVerbose ) { - PRT( "Computing switching activity", clock() - clk ); + ABC_PRT( "Computing switching activity", clock() - clk ); } pSwitching = (float *)vSwitching->pArray; vSwitching2 = Vec_IntStart( Aig_ManObjNumMax(p) ); @@ -355,7 +355,7 @@ Nwk_Man_t * Nwk_MappingIf( Aig_Man_t * p, Tim_Man_t * pManTime, If_Par_t * pPars If_Man_t * pIfMan; Vec_Ptr_t * vAigToIf; // set the arrival times - pPars->pTimesArr = ALLOC( float, Aig_ManPiNum(p) ); + pPars->pTimesArr = ABC_ALLOC( float, Aig_ManPiNum(p) ); memset( pPars->pTimesArr, 0, sizeof(float) * Aig_ManPiNum(p) ); // translate into the mapper vAigToIf = Vec_PtrStart( Aig_ManObjNumMax(p) ); diff --git a/src/aig/nwk/nwkMerge.c b/src/aig/nwk/nwkMerge.c index 3aec4faa..bc7826e1 100644 --- a/src/aig/nwk/nwkMerge.c +++ b/src/aig/nwk/nwkMerge.c @@ -43,11 +43,11 @@ Nwk_Grf_t * Nwk_ManGraphAlloc( int nVertsMax ) { Nwk_Grf_t * p; - p = ALLOC( Nwk_Grf_t, 1 ); + p = ABC_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->pEdgeHash = ABC_CALLOC( Nwk_Edg_t *, p->nEdgeHash ); p->pMemEdges = Aig_MmFixedStart( sizeof(Nwk_Edg_t), p->nEdgeHash ); p->vPairs = Vec_IntAlloc( 1000 ); return p; @@ -69,11 +69,11 @@ 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 ); + ABC_FREE( p->pVerts ); + ABC_FREE( p->pEdgeHash ); + ABC_FREE( p->pMapLut2Id ); + ABC_FREE( p->pMapId2Lut ); + ABC_FREE( p ); } /**Function************************************************************* @@ -276,8 +276,8 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p ) 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 ); + p->pMapLut2Id = ABC_ALLOC( int, p->nObjs+1 ); + p->pMapId2Lut = ABC_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 @@ -299,7 +299,7 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p ) } } // count the edges and mark present objects - pnEdges = CALLOC( int, p->nVerts+1 ); + pnEdges = ABC_CALLOC( int, p->nVerts+1 ); Nwk_GraphForEachEdge( p, pEntry, i ) { // translate into vertices @@ -315,7 +315,7 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p ) } // allocate the real graph p->pMemVerts = Aig_MmFlexStart(); - p->pVerts = ALLOC( Nwk_Vrt_t *, p->nVerts + 1 ); + p->pVerts = ABC_ALLOC( Nwk_Vrt_t *, p->nVerts + 1 ); p->pVerts[0] = NULL; for ( i = 1; i <= p->nVerts; i++ ) { @@ -341,9 +341,9 @@ void Nwk_ManGraphPrepare( Nwk_Grf_t * p ) } // clean up Aig_MmFixedStop( p->pMemEdges, 0 ); p->pMemEdges = NULL; - FREE( p->pEdgeHash ); + ABC_FREE( p->pEdgeHash ); // p->nEdgeHash = 0; - free( pnEdges ); + ABC_FREE( pnEdges ); } /**Function************************************************************* @@ -362,7 +362,7 @@ void Nwk_ManGraphSortPairs( Nwk_Grf_t * p ) int nSize = Vec_IntSize(p->vPairs); int * pIdToPair, i; // allocate storage - pIdToPair = ALLOC( int, p->nObjs+1 ); + pIdToPair = ABC_ALLOC( int, p->nObjs+1 ); for ( i = 0; i <= p->nObjs; i++ ) pIdToPair[i] = -1; // create mapping @@ -381,7 +381,7 @@ void Nwk_ManGraphSortPairs( Nwk_Grf_t * p ) Vec_IntPush( p->vPairs, pIdToPair[i] ); } assert( nSize == Vec_IntSize(p->vPairs) ); - free( pIdToPair ); + ABC_FREE( pIdToPair ); } @@ -702,12 +702,12 @@ int Nwk_ManLutMergeGraphTest( char * pFileName ) Nwk_Grf_t * p; int clk = clock(); p = Nwk_ManLutMergeReadGraph( pFileName ); - PRT( "Reading", clock() - clk ); + ABC_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 ); + ABC_PRT( "Solving", clock() - clk ); nPairs = Vec_IntSize(p->vPairs)/2; Nwk_ManGraphReportMemoryUsage( p ); Nwk_ManGraphFree( p ); @@ -1009,7 +1009,7 @@ Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars ) if ( pPars->fVerbose ) { printf( "Mergable LUTs = %6d. Total cands = %6d. ", p->nVertsMax, nCands ); - PRT( "Deriving graph", clock() - clk ); + ABC_PRT( "Deriving graph", clock() - clk ); } // solve the graph problem clk = clock(); @@ -1018,7 +1018,7 @@ Vec_Int_t * Nwk_ManLutMerge( Nwk_Man_t * pNtk, Nwk_LMPars_t * pPars ) { printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ", p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 ); - PRT( "Solving", clock() - clk ); + ABC_PRT( "Solving", clock() - clk ); Nwk_ManGraphReportMemoryUsage( p ); } vResult = p->vPairs; p->vPairs = NULL; diff --git a/src/aig/nwk/nwkMerge.h b/src/aig/nwk/nwkMerge.h index 3763e4b2..ab39ec39 100644 --- a/src/aig/nwk/nwkMerge.h +++ b/src/aig/nwk/nwkMerge.h @@ -21,10 +21,6 @@ #ifndef __NWK_MERGE_H__ #define __NWK_MERGE_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define NWK_MAX_LIST 16 //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/nwk/nwkSpeedup.c b/src/aig/nwk/nwkSpeedup.c index 469e9b71..54e4d414 100644 --- a/src/aig/nwk/nwkSpeedup.c +++ b/src/aig/nwk/nwkSpeedup.c @@ -221,7 +221,7 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in printf( "\n" ); } // mark the timing critical nodes and edges - puTCEdges = ALLOC( unsigned, Nwk_ManObjNumMax(pNtk) ); + puTCEdges = ABC_ALLOC( unsigned, Nwk_ManObjNumMax(pNtk) ); memset( puTCEdges, 0, sizeof(unsigned) * Nwk_ManObjNumMax(pNtk) ); Nwk_ManForEachNode( pNtk, pNode, i ) { @@ -244,7 +244,7 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in } // start the resulting network pAig = Nwk_ManStrash( pNtk ); - pAig->pEquivs = ALLOC( Aig_Obj_t *, 3 * Aig_ManObjNumMax(pAig) ); + pAig->pEquivs = ABC_ALLOC( Aig_Obj_t *, 3 * Aig_ManObjNumMax(pAig) ); memset( pAig->pEquivs, 0, sizeof(Aig_Obj_t *) * 3 * Aig_ManObjNumMax(pAig) ); // collect nodes to be used for resynthesis @@ -332,7 +332,7 @@ Aig_Man_t * Nwk_ManSpeedup( Nwk_Man_t * pNtk, int fUseLutLib, int Percentage, in } Vec_PtrFree( vTimeCries ); Vec_PtrFree( vTimeFanins ); - free( puTCEdges ); + ABC_FREE( puTCEdges ); if ( fVerbose ) printf( "Nodes: Total = %7d. 0-slack = %7d. Workable = %7d. Ratio = %4.2f\n", Nwk_ManNodeNum(pNtk), Counter, CounterRes, Counter? 1.0*CounterRes/Counter : 0.0 ); diff --git a/src/aig/nwk/nwkTiming.c b/src/aig/nwk/nwkTiming.c index fc56b387..80391c66 100644 --- a/src/aig/nwk/nwkTiming.c +++ b/src/aig/nwk/nwkTiming.c @@ -468,7 +468,7 @@ void Nwk_ManDelayTracePrint( Nwk_Man_t * pNtk ) } // decide how many steps nSteps = pLutLib ? 20 : Nwk_ManLevelMax(pNtk); - pCounters = ALLOC( int, nSteps + 1 ); + pCounters = ABC_ALLOC( int, nSteps + 1 ); memset( pCounters, 0, sizeof(int)*(nSteps + 1) ); // perform delay trace tArrival = Nwk_ManDelayTraceLut( pNtk ); @@ -493,7 +493,7 @@ void Nwk_ManDelayTracePrint( Nwk_Man_t * pNtk ) printf( "%3d %s : %5d (%6.2f %%)\n", pLutLib? 5*(i+1) : i+1, pLutLib? "%":"lev", Nodes, 100.0*Nodes/Nwk_ManNodeNum(pNtk) ); } - free( pCounters ); + ABC_FREE( pCounters ); } diff --git a/src/aig/nwk2/nwk.h b/src/aig/nwk2/nwk.h index bef16284..36d483fc 100644 --- a/src/aig/nwk2/nwk.h +++ b/src/aig/nwk2/nwk.h @@ -21,10 +21,6 @@ #ifndef __NWK_H__ #define __NWK_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/nwk2/nwkMerge.h b/src/aig/nwk2/nwkMerge.h index df426681..f5697f6e 100644 --- a/src/aig/nwk2/nwkMerge.h +++ b/src/aig/nwk2/nwkMerge.h @@ -21,10 +21,6 @@ #ifndef __NWK_MERGE_H__ #define __NWK_MERGE_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define NWK_MAX_LIST 16 //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/rwt/rwt.h b/src/aig/rwt/rwt.h index 56f66f34..9efdc421 100644 --- a/src/aig/rwt/rwt.h +++ b/src/aig/rwt/rwt.h @@ -21,10 +21,6 @@ #ifndef __RWT_H__ #define __RWT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -112,10 +112,10 @@ struct Rwt_Node_t_ // 24 bytes }; // manipulation of complemented attributes -static inline int Rwt_IsComplement( Rwt_Node_t * p ) { return (int)(((PORT_PTRUINT_T)p) & 01); } -static inline Rwt_Node_t * Rwt_Regular( Rwt_Node_t * p ) { return (Rwt_Node_t *)((PORT_PTRUINT_T)(p) & ~01); } -static inline Rwt_Node_t * Rwt_Not( Rwt_Node_t * p ) { return (Rwt_Node_t *)((PORT_PTRUINT_T)(p) ^ 01); } -static inline Rwt_Node_t * Rwt_NotCond( Rwt_Node_t * p, int c ) { return (Rwt_Node_t *)((PORT_PTRUINT_T)(p) ^ (c)); } +static inline int Rwt_IsComplement( Rwt_Node_t * p ) { return (int)(((ABC_PTRUINT_T)p) & 01); } +static inline Rwt_Node_t * Rwt_Regular( Rwt_Node_t * p ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) & ~01); } +static inline Rwt_Node_t * Rwt_Not( Rwt_Node_t * p ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) ^ 01); } +static inline Rwt_Node_t * Rwt_NotCond( Rwt_Node_t * p, int c ) { return (Rwt_Node_t *)((ABC_PTRUINT_T)(p) ^ (c)); } //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// diff --git a/src/aig/rwt/rwtDec.c b/src/aig/rwt/rwtDec.c index df6209cd..2f183913 100644 --- a/src/aig/rwt/rwtDec.c +++ b/src/aig/rwt/rwtDec.c @@ -49,7 +49,7 @@ void Rwt_ManPreprocess( Rwt_Man_t * p ) Rwt_Node_t * pNode; int i, k; // put the nodes into the structure - p->pMapInv = ALLOC( unsigned short, 222 ); + p->pMapInv = ABC_ALLOC( unsigned short, 222 ); memset( p->pMapInv, 0, sizeof(unsigned short) * 222 ); p->vClasses = Vec_VecStart( 222 ); for ( i = 0; i < p->nFuncs; i++ ) diff --git a/src/aig/rwt/rwtMan.c b/src/aig/rwt/rwtMan.c index 869043a4..87074e6e 100644 --- a/src/aig/rwt/rwtMan.c +++ b/src/aig/rwt/rwtMan.c @@ -64,10 +64,10 @@ void Rwt_ManGlobalStart() ***********************************************************************/ void Rwt_ManGlobalStop() { - FREE( s_puCanons ); - FREE( s_pPhases ); - FREE( s_pPerms ); - FREE( s_pMap ); + ABC_FREE( s_puCanons ); + ABC_FREE( s_pPhases ); + ABC_FREE( s_pPerms ); + ABC_FREE( s_pMap ); } /**Function************************************************************* @@ -86,7 +86,7 @@ Rwt_Man_t * Rwt_ManStart( int fPrecompute ) Rwt_Man_t * p; int clk = clock(); clk = clock(); - p = ALLOC( Rwt_Man_t, 1 ); + p = ABC_ALLOC( Rwt_Man_t, 1 ); memset( p, 0, sizeof(Rwt_Man_t) ); p->nFuncs = (1<<16); // copy the global tables @@ -98,7 +98,7 @@ clk = clock(); // initialize practical NPN classes p->pPractical = Rwt_ManGetPractical( p ); // create the table - p->pTable = ALLOC( Rwt_Node_t *, p->nFuncs ); + p->pTable = ABC_ALLOC( Rwt_Node_t *, p->nFuncs ); memset( p->pTable, 0, sizeof(Rwt_Node_t *) * p->nFuncs ); // create the elementary nodes p->pMmNode = Mem_FixedStart( sizeof(Rwt_Node_t) ); @@ -159,11 +159,11 @@ void Rwt_ManStop( Rwt_Man_t * p ) Vec_PtrFree( p->vFanins ); Vec_PtrFree( p->vFaninsCur ); Mem_FixedStop( p->pMmNode, 0 ); - FREE( p->pMapInv ); - free( p->pTable ); - free( p->pPractical ); - free( p->pPerms4 ); - free( p ); + ABC_FREE( p->pMapInv ); + ABC_FREE( p->pTable ); + ABC_FREE( p->pPractical ); + ABC_FREE( p->pPerms4 ); + ABC_FREE( p ); } /**Function************************************************************* @@ -191,14 +191,14 @@ void Rwt_ManPrintStats( Rwt_Man_t * p ) printf( "Nodes considered = %8d.\n", p->nNodesConsidered ); printf( "Nodes rewritten = %8d.\n", p->nNodesRewritten ); printf( "Calculated gain = %8d.\n", p->nNodesGained ); - PRT( "Start ", p->timeStart ); - PRT( "Cuts ", p->timeCut ); - PRT( "Truth ", p->timeTruth ); - PRT( "Resynthesis ", p->timeRes ); - PRT( " Mffc ", p->timeMffc ); - PRT( " Eval ", p->timeEval ); - PRT( "Update ", p->timeUpdate ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Start ", p->timeStart ); + ABC_PRT( "Cuts ", p->timeCut ); + ABC_PRT( "Truth ", p->timeTruth ); + ABC_PRT( "Resynthesis ", p->timeRes ); + ABC_PRT( " Mffc ", p->timeMffc ); + ABC_PRT( " Eval ", p->timeEval ); + ABC_PRT( "Update ", p->timeUpdate ); + ABC_PRT( "TOTAL ", p->timeTotal ); /* printf( "The scores are:\n" ); diff --git a/src/aig/rwt/rwtUtil.c b/src/aig/rwt/rwtUtil.c index af3e1893..b0b653bd 100644 --- a/src/aig/rwt/rwtUtil.c +++ b/src/aig/rwt/rwtUtil.c @@ -247,7 +247,7 @@ void Rwt_ManLoadFromArray( Rwt_Man_t * p, int fVerbose ) if ( fVerbose ) { printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded ); - printf( "The number of nodes loaded = %d. ", nEntries ); PRT( "Loading", clock() - clk ); + printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", clock() - clk ); } } @@ -266,7 +266,7 @@ char * Rwt_ManGetPractical( Rwt_Man_t * p ) { char * pPractical; int i; - pPractical = ALLOC( char, p->nFuncs ); + pPractical = ABC_ALLOC( char, p->nFuncs ); memset( pPractical, 0, sizeof(char) * p->nFuncs ); pPractical[0] = 1; for ( i = 1; ; i++ ) diff --git a/src/aig/saig/saig.h b/src/aig/saig/saig.h index 84ff272a..3db3e396 100644 --- a/src/aig/saig/saig.h +++ b/src/aig/saig/saig.h @@ -21,10 +21,6 @@ #ifndef __SAIG_H__ #define __SAIG_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -35,6 +31,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -134,7 +134,7 @@ extern int Saig_MvManSimulate( Aig_Man_t * pAig, int fVerbose ); /*=== saigStrSim.c ==========================================================*/ extern Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDist, int fVerbose, Aig_Man_t ** ppMiter ); /*=== saigSwitch.c ==========================================================*/ -extern Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ); +extern Vec_Int_t * Saig_ManComputeSwitchProb2s( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ); /*=== saigSynch.c ==========================================================*/ extern Aig_Man_t * Saig_ManDupInitZero( Aig_Man_t * p ); /*=== saigTrans.c ==========================================================*/ diff --git a/src/aig/saig/saigAbs.c b/src/aig/saig/saigAbs.c index d2a45b4e..c9e76626 100644 --- a/src/aig/saig/saigAbs.c +++ b/src/aig/saig/saigAbs.c @@ -54,7 +54,7 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo Intp_Man_t * pManProof; int RetValue, clk = clock(); // solve the problem - RetValue = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfMax, (sint64)0, (sint64)0, (sint64)0 ); + 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" ); @@ -68,7 +68,7 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo if ( fVerbose ) { printf( "SAT solver returned UNSAT after %d conflicts. ", pSat->stats.conflicts ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } assert( RetValue == l_False ); pSatCnf = sat_solver_store_release( pSat ); @@ -81,7 +81,7 @@ Vec_Int_t * Saig_AbsSolverUnsatCore( sat_solver * pSat, int nConfMax, int fVerbo if ( fVerbose ) { printf( "SAT core contains %d clauses (out of %d). ", Vec_IntSize(vCore), pSat->stats.clauses ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } return vCore; } @@ -458,7 +458,7 @@ Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec Vec_PtrForEachEntry( vFrames, pCnf, f ) nSatVars += pCnf->nVars; // mark register variables - pVars = ALLOC( int, nSatVars ); + pVars = ABC_ALLOC( int, nSatVars ); for ( i = 0; i < nSatVars; i++ ) pVars[i] = -1; Vec_PtrForEachEntry( vFrames, pCnf, f ) @@ -485,7 +485,7 @@ Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec } } // mark used registers - pFlops = CALLOC( int, Aig_ManRegNum(p) ); + pFlops = ABC_CALLOC( int, Aig_ManRegNum(p) ); Vec_IntForEachEntry( vCore, iClause, i ) { nSatClauses = 0; @@ -513,8 +513,8 @@ Vec_Int_t * Saig_AbsCollectRegistersDyn( Aig_Man_t * p, Vec_Ptr_t * vFrames, Vec for ( i = 0; i < Aig_ManRegNum(p); i++ ) if ( pFlops[i] ) Vec_IntPush( vFlops, i ); - free( pFlops ); - free( pVars ); + ABC_FREE( pFlops ); + ABC_FREE( pVars ); return vFlops; } @@ -536,7 +536,7 @@ Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t * int * pVars, * pFlops; int i, iClause, iReg, * piLit; // mark register variables - pVars = ALLOC( int, pCnf->nVars ); + pVars = ABC_ALLOC( int, pCnf->nVars ); for ( i = 0; i < pCnf->nVars; i++ ) pVars[i] = -1; Saig_ManForEachLi( pCnf->pMan, pObj, i ) @@ -544,7 +544,7 @@ Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t * Saig_ManForEachLo( pCnf->pMan, pObj, i ) pVars[ pCnf->pVarNums[pObj->Id] ] = i; // mark used registers - pFlops = CALLOC( int, Aig_ManRegNum(pCnf->pMan) ); + pFlops = ABC_CALLOC( int, Aig_ManRegNum(pCnf->pMan) ); Vec_IntForEachEntry( vCore, iClause, i ) { // skip auxiliary clauses @@ -564,8 +564,8 @@ Vec_Int_t * Saig_AbsCollectRegisters( Cnf_Dat_t * pCnf, int nFrames, Vec_Int_t * for ( i = 0; i < Aig_ManRegNum(pCnf->pMan); i++ ) if ( pFlops[i] ) Vec_IntPush( vFlops, i ); - free( pFlops ); - free( pVars ); + ABC_FREE( pFlops ); + ABC_FREE( pVars ); return vFlops; } @@ -806,7 +806,7 @@ Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, int nFrames, int nConfMax, if ( fVerbose ) { printf( "SAT solver: Vars = %7d. Clauses = %7d. ", pSat->size, pSat->stats.clauses ); - PRT( "Time", clock() - clk2 ); + ABC_PRT( "Time", clock() - clk2 ); } // compute UNSAT core vCore = Saig_AbsSolverUnsatCore( pSat, nConfMax, fVerbose ); @@ -831,7 +831,7 @@ Aig_Man_t * Saig_ManProofAbstraction( Aig_Man_t * p, int nFrames, int nConfMax, if ( fVerbose ) { printf( "The number of relevant registers is %d (out of %d). ", Vec_IntSize(vFlops), Aig_ManRegNum(p) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } } /* diff --git a/src/aig/saig/saigBmc.c b/src/aig/saig/saigBmc.c index 7cccce96..d56d97a9 100644 --- a/src/aig/saig/saigBmc.c +++ b/src/aig/saig/saigBmc.c @@ -27,7 +27,7 @@ /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -#define AIG_VISITED ((Aig_Obj_t *)(PORT_PTRUINT_T)1) +#define AIG_VISITED ((Aig_Obj_t *)(ABC_PTRUINT_T)1) typedef struct Saig_Bmc_t_ Saig_Bmc_t; struct Saig_Bmc_t_ @@ -88,7 +88,7 @@ Saig_Bmc_t * Saig_BmcManStart( Aig_Man_t * pAig, int nFramesMax, int nNodesMax, Aig_Obj_t * pObj; int i, Lit; assert( Aig_ManRegNum(pAig) > 0 ); - p = (Saig_Bmc_t *)malloc( sizeof(Saig_Bmc_t) ); + p = (Saig_Bmc_t *)ABC_ALLOC( char, sizeof(Saig_Bmc_t) ); memset( p, 0, sizeof(Saig_Bmc_t) ); // set parameters p->nFramesMax = nFramesMax; @@ -141,7 +141,7 @@ void Saig_BmcManStop( Saig_Bmc_t * p ) sat_solver_delete( p->pSat ); Vec_PtrFree( p->vTargets ); Vec_PtrFree( p->vVisited ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -311,7 +311,7 @@ void Saig_BmcInterval( Saig_Bmc_t * p ) // check if the node is gone Vec_PtrForEachEntry( p->vVisited, pObj, i ) { - iFrame = (int)(PORT_PTRINT_T)Vec_PtrEntry( p->vVisited, 1+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 ); @@ -524,7 +524,7 @@ int Saig_BmcSolveTargets( Saig_Bmc_t * p ) 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, (sint64)p->nConfMaxOne, (sint64)0, (sint64)0, (sint64)0 ); + 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 @@ -614,7 +614,7 @@ void Saig_BmcPerform( Aig_Man_t * pAig, int nFramesMax, int nNodesMax, int nConf { 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 ); - PRT( "Time", clock() - clk2 ); + ABC_PRT( "Time", clock() - clk2 ); } if ( RetValue != l_False ) break; @@ -624,7 +624,7 @@ void Saig_BmcPerform( Aig_Man_t * pAig, int nFramesMax, int nNodesMax, int nConf p->iOutputFail, p->iFrameFail ); else // if ( RetValue == l_False || RetValue == l_Undef ) printf( "No output was asserted in %d frames. ", p->iFramePrev-1 ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); if ( RetValue != l_True ) { if ( p->iFrameLast >= p->nFramesMax ) diff --git a/src/aig/saig/saigBmc2.c b/src/aig/saig/saigBmc2.c index 5776cd4a..8ba02528 100644 --- a/src/aig/saig/saigBmc2.c +++ b/src/aig/saig/saigBmc2.c @@ -199,7 +199,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim 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) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); fflush( stdout ); } // rewrite the timeframes @@ -213,7 +213,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim { printf( "Time-frames after rewriting: Node = %6d. Lev = %5d. ", Aig_ManNodeNum(pFrames), Aig_ManLevelNum(pFrames) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); fflush( stdout ); } } @@ -230,7 +230,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim if ( fVerbose ) { printf( "CNF: Variables = %6d. Clauses = %7d. Literals = %8d. ", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); fflush( stdout ); } status = sat_solver_simplify(pSat); @@ -254,13 +254,13 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim i % Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) ); } clk = clock(); - status = sat_solver_solve( pSat, &Lit, &Lit + 1, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 ); + 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 ); - PRT( "T", clock() - clkPart ); + ABC_PRT( "T", clock() - clkPart ); clkPart = clock(); fflush( stdout ); } @@ -284,7 +284,7 @@ int Saig_ManBmcSimple( Aig_Man_t * pAig, int nFrames, int nSizeMax, int nConfLim int * pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize ); pModel[Aig_ManPiNum(pFrames)] = pObj->Id; pAig->pSeqModel = Fra_SmlCopyCounterExample( pAig, pFrames, pModel ); - free( pModel ); + ABC_FREE( pModel ); Vec_IntFree( vCiIds ); // if ( piFrame ) diff --git a/src/aig/saig/saigHaig.c b/src/aig/saig/saigHaig.c index 8a75ae1f..1c7aa025 100644 --- a/src/aig/saig/saigHaig.c +++ b/src/aig/saig/saigHaig.c @@ -273,7 +273,7 @@ clk = clock(); return 0; } } -PRT( "Preparation", clock() - clk ); +ABC_PRT( "Preparation", clock() - clk ); // check in the second timeframe @@ -291,7 +291,7 @@ clk = clock(); Lits[0] = toLitCond( pCnf->pVarNums[pObj1->Id], 0 ); Lits[1] = toLitCond( pCnf->pVarNums[pObj2->Id], 1 ); - RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( RetValue1 == l_False ) { Lits[0] = lit_neg( Lits[0] ); @@ -303,7 +303,7 @@ clk = clock(); Lits[0]++; Lits[1]--; - RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( RetValue2 == l_False ) { Lits[0] = lit_neg( Lits[0] ); @@ -323,7 +323,7 @@ clk = clock(); // break; } printf( " \r" ); -PRT( "Solving ", clock() - clk ); +ABC_PRT( "Solving ", clock() - clk ); clkVerif = clock() - clk; if ( Counter ) printf( "Verification failed for %d out of %d assertions.\n", Counter, pFrames->nAsserts/2 ); @@ -479,7 +479,7 @@ clk = clock(); return 0; } } -PRT( "Preparation", clock() - clk ); +ABC_PRT( "Preparation", clock() - clk ); // check in the second timeframe @@ -496,12 +496,12 @@ clk = clock(); Lits[0] = toLitCond( pCnf->pVarNums[pObj1->Id]+Delta, 0 ); Lits[1] = toLitCond( pCnf->pVarNums[pObj2->Id]+Delta, 0 ); - RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); Lits[0]++; Lits[1]++; - RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( RetValue1 != l_False || RetValue2 != l_False ) Counter++; @@ -511,12 +511,12 @@ clk = clock(); Lits[0] = toLitCond( pCnf->pVarNums[pObj1->Id]+Delta, 0 ); Lits[1] = toLitCond( pCnf->pVarNums[pObj2->Id]+Delta, 1 ); - RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue1 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); Lits[0]++; Lits[1]--; - RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue2 = sat_solver_solve( pSat, Lits, Lits + 2, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( RetValue1 != l_False || RetValue2 != l_False ) Counter++; @@ -527,7 +527,7 @@ clk = clock(); // if ( i / 2 > 1000 ) // break; } -PRT( "Solving ", clock() - clk ); +ABC_PRT( "Solving ", clock() - clk ); if ( Counter ) printf( "Verification failed for %d out of %d classes.\n", Counter, Vec_IntSize(pHaig->vEquPairs)/2 ); else @@ -634,7 +634,7 @@ clk = clock(); // remove structural hashing table Aig_TableClear( pNew->pManHaig ); pNew->pManHaig->vEquPairs = Vec_IntAlloc( 10000 ); -PRT( "HAIG setup time", clock() - clk ); +ABC_PRT( "HAIG setup time", clock() - clk ); clk = clock(); if ( fSeqHaig ) @@ -682,7 +682,7 @@ clk = clock(); Aig_ManStop( pTemp ); } } -PRT( "Synthesis time ", clock() - clk ); +ABC_PRT( "Synthesis time ", clock() - clk ); clkSynth = clock() - clk; // use the haig for verification diff --git a/src/aig/saig/saigInd.c b/src/aig/saig/saigInd.c index 69c250f6..1c26e5df 100644 --- a/src/aig/saig/saigInd.c +++ b/src/aig/saig/saigInd.c @@ -121,13 +121,13 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fVerbose } // run the SAT solver nConfPrev = pSat->stats.conflicts; - status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfMax, 0, 0, 0 ); + 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 ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } if ( status == l_Undef ) break; diff --git a/src/aig/saig/saigIoa.c b/src/aig/saig/saigIoa.c index 70870fe9..d049489e 100644 --- a/src/aig/saig/saigIoa.c +++ b/src/aig/saig/saigIoa.c @@ -348,7 +348,7 @@ Aig_Man_t * Saig_ManReadBlif( char * pFileName ) { extern double pow( double x, double y ); int Size = (int)pow(10.0, (double)(strlen(pToken) - 1)); - pNum2Id = CALLOC( int, Size ); + pNum2Id = ABC_CALLOC( int, Size ); } // other tokens @@ -383,7 +383,7 @@ Aig_Man_t * Saig_ManReadBlif( char * pFileName ) // add non-node objects to the mapping Aig_ManForEachPi( p, pNode, i ) pNum2Id[pNode->Id] = pNode->Id; -// FREE( pNum2Id ); +// ABC_FREE( pNum2Id ); p->pData = pNum2Id; // check the new manager Aig_ManSetRegNum( p, nRegs ); diff --git a/src/aig/saig/saigMiter.c b/src/aig/saig/saigMiter.c index 6c4b3af0..174a3e97 100644 --- a/src/aig/saig/saigMiter.c +++ b/src/aig/saig/saigMiter.c @@ -526,13 +526,13 @@ int Saig_ManDemiterSimple( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAi if ( ppAig0 ) { *ppAig0 = Aig_ManDupNodesHalf( p, vSet0, 0 ); - FREE( (*ppAig0)->pName ); + ABC_FREE( (*ppAig0)->pName ); (*ppAig0)->pName = Aig_UtilStrsav( "part0" ); } if ( ppAig1 ) { *ppAig1 = Aig_ManDupNodesHalf( p, vSet1, 1 ); - FREE( (*ppAig1)->pName ); + ABC_FREE( (*ppAig1)->pName ); (*ppAig1)->pName = Aig_UtilStrsav( "part1" ); } Vec_PtrFree( vSet0 ); @@ -596,13 +596,13 @@ int Saig_ManDemiterSimpleDiff( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** if ( ppAig0 ) { *ppAig0 = Aig_ManDupNodesAll( p, vSet0 ); - FREE( (*ppAig0)->pName ); + ABC_FREE( (*ppAig0)->pName ); (*ppAig0)->pName = Aig_UtilStrsav( "part0" ); } if ( ppAig1 ) { *ppAig1 = Aig_ManDupNodesAll( p, vSet1 ); - FREE( (*ppAig1)->pName ); + ABC_FREE( (*ppAig1)->pName ); (*ppAig1)->pName = Aig_UtilStrsav( "part1" ); } Vec_PtrFree( vSet0 ); @@ -768,14 +768,14 @@ int Saig_ManDemiter( Aig_Man_t * p, Aig_Man_t ** ppAig0, Aig_Man_t ** ppAig1 ) { assert( 0 ); *ppAig0 = Aig_ManDupNodesHalf( p, vSet0, 0 ); // not ready - FREE( (*ppAig0)->pName ); + ABC_FREE( (*ppAig0)->pName ); (*ppAig0)->pName = Aig_UtilStrsav( "part0" ); } if ( ppAig1 ) { assert( 0 ); *ppAig1 = Aig_ManDupNodesHalf( p, vSet1, 1 ); // not ready - FREE( (*ppAig1)->pName ); + ABC_FREE( (*ppAig1)->pName ); (*ppAig1)->pName = Aig_UtilStrsav( "part1" ); } Vec_PtrFree( vSet0 ); @@ -891,12 +891,12 @@ int Ssw_SecSpecial( Aig_Man_t * pPart0, Aig_Man_t * pPart1, int nFrames, int fVe if ( RetValue == 1 ) { printf( "Networks are equivalent. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else if ( RetValue == 0 ) { printf( "Networks are NOT EQUIVALENT. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); if ( pMiterCec->pData == NULL ) printf( "Counter-example is not available.\n" ); else @@ -919,7 +919,7 @@ PRT( "Time", clock() - clkTotal ); else { printf( "Networks are UNDECIDED. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } fflush( stdout ); Aig_ManStop( pMiterCec ); diff --git a/src/aig/saig/saigPhase.c b/src/aig/saig/saigPhase.c index c6d84066..9b09598c 100644 --- a/src/aig/saig/saigPhase.c +++ b/src/aig/saig/saigPhase.c @@ -139,14 +139,14 @@ static inline void Saig_TsiSetNext( unsigned * pState, int nWords, unsigne Saig_Tsim_t * Saig_TsiStart( Aig_Man_t * pAig ) { Saig_Tsim_t * p; - p = (Saig_Tsim_t *)malloc( sizeof(Saig_Tsim_t) ); + p = (Saig_Tsim_t *)ABC_ALLOC( char, sizeof(Saig_Tsim_t) ); memset( p, 0, sizeof(Saig_Tsim_t) ); p->pAig = pAig; p->nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) ); p->vStates = Vec_PtrAlloc( 1000 ); p->pMem = Aig_MmFixedStart( sizeof(unsigned) * p->nWords + sizeof(unsigned *), 10000 ); p->nBins = Aig_PrimeCudd(TSIM_MAX_ROUNDS/2); - p->pBins = ALLOC( unsigned *, p->nBins ); + p->pBins = ABC_ALLOC( unsigned *, p->nBins ); memset( p->pBins, 0, sizeof(unsigned *) * p->nBins ); return p; } @@ -168,8 +168,8 @@ void Saig_TsiStop( Saig_Tsim_t * p ) Vec_IntFree( p->vNonXRegs ); Aig_MmFixedStop( p->pMem, 0 ); Vec_PtrFree( p->vStates ); - free( p->pBins ); - free( p ); + ABC_FREE( p->pBins ); + ABC_FREE( p ); } /**Function************************************************************* @@ -696,7 +696,7 @@ Aig_Man_t * Saig_ManPerformAbstraction( Saig_Tsim_t * pTsi, int nFrames, int fVe assert( Vec_IntSize(pTsi->vNonXRegs) > 0 ); // create mapping for the frames nodes - pObjMap = ALLOC( Aig_Obj_t *, nFrames * Aig_ManObjNumMax(pAig) ); + pObjMap = ABC_ALLOC( Aig_Obj_t *, nFrames * Aig_ManObjNumMax(pAig) ); memset( pObjMap, 0, sizeof(Aig_Obj_t *) * nFrames * Aig_ManObjNumMax(pAig) ); // start the fraig package @@ -762,7 +762,7 @@ Aig_Man_t * Saig_ManPerformAbstraction( Saig_Tsim_t * pTsi, int nFrames, int fVe //Aig_ManPrintStats( pFrames ); // Aig_ManPiCleanup( pFrames ); //Aig_ManPrintStats( pFrames ); - free( pObjMap ); + ABC_FREE( pObjMap ); return pFrames; } diff --git a/src/aig/saig/saigRetFwd.c b/src/aig/saig/saigRetFwd.c index b6321da6..8178d26e 100644 --- a/src/aig/saig/saigRetFwd.c +++ b/src/aig/saig/saigRetFwd.c @@ -51,7 +51,7 @@ Aig_Obj_t ** Aig_ManStaticFanoutStart( Aig_Man_t * p ) int i, nFanouts, nFanoutsAlloc; // allocate fanouts nFanoutsAlloc = 2 * Aig_ManObjNumMax(p) - Aig_ManPiNum(p) - Aig_ManPoNum(p); - ppFanouts = ALLOC( Aig_Obj_t *, nFanoutsAlloc ); + ppFanouts = ABC_ALLOC( Aig_Obj_t *, nFanoutsAlloc ); // mark up storage nFanouts = 0; Aig_ManForEachObj( p, pObj, i ) @@ -122,7 +122,7 @@ void Saig_ManMarkAutonomous( Aig_Man_t * p ) Aig_ManMarkAutonomous_rec( p, Aig_ManConst1(p) ); Saig_ManForEachPi( p, pObj, i ) Aig_ManMarkAutonomous_rec( p, pObj ); - free( ppFanouts ); + ABC_FREE( ppFanouts ); // disconnect LIs/LOs and label unreachable registers Saig_ManForEachLiLo( p, pObjLi, pObjLo, i ) { @@ -220,7 +220,7 @@ Aig_Man_t * Saig_ManRetimeForward( Aig_Man_t * p, int nMaxIters, int fVerbose ) { printf( "%2d : And = %6d. Reg = %5d. Unret = %5d. Move = %6d. ", i + 1, Aig_ManNodeNum(pTemp), Aig_ManRegNum(pTemp), nRegFixed, nRegMoves ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } if ( pTemp != p ) Aig_ManStop( pTemp ); @@ -229,7 +229,7 @@ Aig_Man_t * Saig_ManRetimeForward( Aig_Man_t * p, int nMaxIters, int fVerbose ) pNew = Aig_ManReduceLaches( pNew, fVerbose ); if ( fVerbose ) { - PRT( "Register sharing time", clock() - clk ); + ABC_PRT( "Register sharing time", clock() - clk ); } return pNew; } diff --git a/src/aig/saig/saigRetMin.c b/src/aig/saig/saigRetMin.c index 1820ae9a..b9204f44 100644 --- a/src/aig/saig/saigRetMin.c +++ b/src/aig/saig/saigRetMin.c @@ -61,7 +61,7 @@ Vec_Int_t * Saig_ManRetimeInitState( Aig_Man_t * p ) Cnf_DataFree( pCnf ); return NULL; } - RetValue = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); assert( RetValue != l_Undef ); // create counter-example if ( RetValue == l_True ) @@ -119,7 +119,7 @@ int Saig_ManRetimeUnsatCore( Aig_Man_t * p, int fVerbose ) } sat_solver_store_mark_roots( pSat ); // solve the problem - RetValue = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); assert( RetValue != l_Undef ); assert( RetValue == l_False ); pSatCnf = sat_solver_store_release( pSat ); @@ -132,7 +132,7 @@ int Saig_ManRetimeUnsatCore( Aig_Man_t * p, int fVerbose ) // derive the set of variables on which the core depends // collect the variable numbers nVars = 0; - pVars = ALLOC( int, pCnf->nVars ); + pVars = ABC_ALLOC( int, pCnf->nVars ); memset( pVars, 0, sizeof(int) * pCnf->nVars ); Vec_IntForEachEntry( vCore, iClause, i ) { @@ -170,7 +170,7 @@ int Saig_ManRetimeUnsatCore( Aig_Man_t * p, int fVerbose ) } if ( fVerbose ) printf( "UNSAT core: %d clauses, %d variables, %d POs. ", Vec_IntSize(vCore), nVars, nPos ); - free( pVars ); + ABC_FREE( pVars ); Vec_IntFree( vCore ); Cnf_DataFree( pCnf ); return iBadPo; diff --git a/src/aig/saig/saigSimExt.c b/src/aig/saig/saigSimExt.c index 49c85ff4..ead0ece5 100644 --- a/src/aig/saig/saigSimExt.c +++ b/src/aig/saig/saigSimExt.c @@ -309,7 +309,7 @@ clk = clock(); if ( fVerbose ) { printf( "Total new PIs = %3d. Non-removable PIs = %3d. ", Saig_ManPiNum(p)-iFirstPi, Vec_IntSize(vRes) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } Vec_PtrFree( vSimInfo ); Aig_ManFanoutStop( p ); diff --git a/src/aig/saig/saigSimFast.c b/src/aig/saig/saigSimFast.c index 09bb6a06..05f77f8a 100644 --- a/src/aig/saig/saigSimFast.c +++ b/src/aig/saig/saigSimFast.c @@ -108,7 +108,7 @@ Faig_Man_t * Faig_ManAlloc( Aig_Man_t * pAig ) int nWords; // assert( Faig_ManIsCorrect(pAig) ); nWords = 2 * Aig_ManNodeNum(pAig) + Aig_ManPoNum(pAig); - p = (Faig_Man_t *)ALLOC( char, sizeof(Faig_Man_t) + sizeof(int) * nWords ); + p = (Faig_Man_t *)ABC_ALLOC( char, sizeof(Faig_Man_t) + sizeof(int) * nWords ); //printf( "Allocating %7.2f Mb.\n", 1.0 * (sizeof(Faig_Man_t) + sizeof(int) * nWords)/(1<<20) ); memset( p, 0, sizeof(Faig_Man_t) ); p->nPis = Aig_ManPiNum(pAig) - Aig_ManRegNum(pAig); @@ -247,8 +247,8 @@ static inline unsigned Faig_SimulateTransferShift( unsigned uOld, unsigned uNew ***********************************************************************/ int * Faig_ManSimulateFrames( Faig_Man_t * p, int nFrames, int nPref, int fTrans ) { - int * pNumOnes = CALLOC( unsigned, p->nObjs ); - unsigned * pSimInfo = ALLOC( unsigned, p->nObjs ); + int * pNumOnes = ABC_CALLOC( unsigned, 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) ); //printf( "Allocating %7.2f Mb.\n", 1.0 * 4 * p->nObjs/(1<<20) ); @@ -287,7 +287,7 @@ int * Faig_ManSimulateFrames( Faig_Man_t * p, int nFrames, int nPref, int fTrans pNumOnes[i] += Aig_WordCountOnes( pSimInfo[i] ); } } - free( pSimInfo ); + ABC_FREE( pSimInfo ); return pNumOnes; } @@ -336,7 +336,7 @@ float Faig_ManComputeProbOne( int nOnes, int nSimWords ) SeeAlso [] ***********************************************************************/ -Vec_Int_t * Faig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ) +Vec_Int_t * Faig_ManComputeSwitchProbs4( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ) { extern char * Abc_FrameReadFlag( char * pFlag ); int fTrans = 1; @@ -351,7 +351,7 @@ Vec_Int_t * Faig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, i pSwitching = (float *)vSwitching->pArray; clk = clock(); pAig = Faig_ManCreate( p ); -//PRT( "\nCreation ", clock() - clk ); +//ABC_PRT( "\nCreation ", clock() - clk ); Aig_ManRandom( 1 ); // get the number of frames to simulate // if the parameter "seqsimframes" is defined, use it @@ -368,7 +368,7 @@ clk = clock(); //printf( "Simulating %d frames.\n", nFramesReal ); clk = clock(); pProbs = Faig_ManSimulateFrames( pAig, nFramesReal, nPref, fTrans ); -//PRT( "Simulation", clock() - clk ); +//ABC_PRT( "Simulation", clock() - clk ); clk = clock(); if ( fTrans ) { @@ -412,10 +412,10 @@ clk = clock(); pSwitching[pObj->Id] = Faig_ManComputeSwitching( pProbs[Counter++], nFramesReal - nPref ); assert( Counter == pAig->nObjs ); } - free( pProbs ); - free( pAig ); -//PRT( "Switch ", clock() - clk ); -//PRT( "TOTAL ", clock() - clkTotal ); + ABC_FREE( pProbs ); + ABC_FREE( pAig ); +//ABC_PRT( "Switch ", clock() - clk ); +//ABC_PRT( "TOTAL ", clock() - clkTotal ); return vSwitching; } @@ -430,9 +430,10 @@ clk = clock(); SeeAlso [] ***********************************************************************/ -Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ) +Vec_Int_t * Saig_ManComputeSwitchProb3s( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ) { - return Faig_ManComputeSwitchProbs( p, nFrames, nPref, fProbOne ); +// return Faig_ManComputeSwitchProbs( p, nFrames, nPref, fProbOne ); + return NULL; } diff --git a/src/aig/saig/saigSimMv.c b/src/aig/saig/saigSimMv.c index 0e250a74..9bc6416b 100644 --- a/src/aig/saig/saigSimMv.c +++ b/src/aig/saig/saigSimMv.c @@ -129,7 +129,7 @@ Saig_MvObj_t * Saig_ManCreateReducedAig( Aig_Man_t * p, Vec_Ptr_t ** pvFlops ) Aig_Obj_t * pObj; int i; *pvFlops = Vec_PtrAlloc( Aig_ManRegNum(p) ); - pAig = CALLOC( Saig_MvObj_t, Aig_ManObjNumMax(p)+1 ); + pAig = ABC_CALLOC( Saig_MvObj_t, Aig_ManObjNumMax(p)+1 ); Aig_ManForEachObj( p, pObj, i ) { pEntry = pAig + i; @@ -171,8 +171,8 @@ static inline int Saig_MvCreateObj( Saig_MvMan_t * p, int iFan0, int iFan1 ) Saig_MvAnd_t * pNode; if ( p->nObjs == p->nObjsAlloc ) { - p->pAigNew = REALLOC( Saig_MvAnd_t, p->pAigNew, 2*p->nObjsAlloc ); - p->pLevels = REALLOC( unsigned char, p->pLevels, 2*p->nObjsAlloc ); + p->pAigNew = ABC_REALLOC( Saig_MvAnd_t, p->pAigNew, 2*p->nObjsAlloc ); + p->pLevels = ABC_REALLOC( unsigned char, p->pLevels, 2*p->nObjsAlloc ); p->nObjsAlloc *= 2; } pNode = p->pAigNew + p->nObjs; @@ -202,7 +202,7 @@ Saig_MvMan_t * Saig_MvManStart( Aig_Man_t * pAig ) Saig_MvMan_t * p; int i; assert( Aig_ManRegNum(pAig) > 0 ); - p = (Saig_MvMan_t *)ALLOC( Saig_MvMan_t, 1 ); + p = (Saig_MvMan_t *)ABC_ALLOC( Saig_MvMan_t, 1 ); memset( p, 0, sizeof(Saig_MvMan_t) ); // set parameters p->pAig = pAig; @@ -213,23 +213,23 @@ 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 = CALLOC( int, p->nTStatesSize ); + p->pTStates = ABC_CALLOC( int, p->nTStatesSize ); p->pMemStates = Aig_MmFixedStart( sizeof(int) * (p->nFlops+1), p->nStatesMax ); p->vStates = Vec_PtrAlloc( p->nStatesMax ); Vec_PtrPush( p->vStates, NULL ); - p->pRegsUndef = CALLOC( int, p->nFlops ); - p->pRegsValues = ALLOC( int *, p->nFlops ); - p->pRegsValues[0] = ALLOC( int, p->nValuesMax * p->nFlops ); + p->pRegsUndef = ABC_CALLOC( int, p->nFlops ); + p->pRegsValues = ABC_ALLOC( int *, p->nFlops ); + p->pRegsValues[0] = ABC_ALLOC( int, p->nValuesMax * p->nFlops ); for ( i = 1; i < p->nFlops; i++ ) p->pRegsValues[i] = p->pRegsValues[i-1] + p->nValuesMax; - p->nRegsValues = CALLOC( int, p->nFlops ); + p->nRegsValues = ABC_CALLOC( int, p->nFlops ); p->vTired = Vec_PtrAlloc( 100 ); // internal AIG p->nObjsAlloc = 1000000; - p->pAigNew = ALLOC( Saig_MvAnd_t, p->nObjsAlloc ); + p->pAigNew = ABC_ALLOC( Saig_MvAnd_t, p->nObjsAlloc ); p->nTNodesSize = Aig_PrimeCudd( p->nObjsAlloc / 3 ); - p->pTNodes = CALLOC( int, p->nTNodesSize ); - p->pLevels = ALLOC( unsigned char, p->nObjsAlloc ); + p->pTNodes = ABC_CALLOC( int, p->nTNodesSize ); + p->pLevels = ABC_ALLOC( unsigned char, p->nObjsAlloc ); Saig_MvCreateObj( p, 0, 0 ); return p; } @@ -251,16 +251,16 @@ void Saig_MvManStop( Saig_MvMan_t * p ) Vec_PtrFree( p->vStates ); Vec_PtrFree( p->vFlops ); Vec_PtrFree( p->vTired ); - free( p->pRegsValues[0] ); - free( p->pRegsValues ); - free( p->nRegsValues ); - free( p->pRegsUndef ); - free( p->pAigOld ); - free( p->pTStates ); - free( p->pAigNew ); - free( p->pTNodes ); - free( p->pLevels ); - free( p ); + ABC_FREE( p->pRegsValues[0] ); + ABC_FREE( p->pRegsValues ); + ABC_FREE( p->nRegsValues ); + ABC_FREE( p->pRegsUndef ); + ABC_FREE( p->pAigOld ); + ABC_FREE( p->pTStates ); + ABC_FREE( p->pAigNew ); + ABC_FREE( p->pTNodes ); + ABC_FREE( p->pLevels ); + ABC_FREE( p ); } /**Function************************************************************* @@ -661,7 +661,7 @@ int Saig_MvManSimulate( Aig_Man_t * pAig, int fVerbose ) int f, i, k, iRegMax, iState, clk = clock(); // start the manager p = Saig_MvManStart( pAig ); -PRT( "Constructing the problem", clock() - clk ); +ABC_PRT( "Constructing the problem", clock() - clk ); clk = clock(); // initiliaze registers Vec_PtrForEachEntry( p->vFlops, pEntry, i ) @@ -710,7 +710,7 @@ PRT( "Constructing the problem", clock() - clk ); pEntry->Value = Saig_MvUndef(); } } -PRT( "Multi-value simulation", clock() - clk ); +ABC_PRT( "Multi-value simulation", clock() - clk ); // implement equivalences Saig_MvManPostProcess( p, iState-1 ); Saig_MvManStop( p ); diff --git a/src/aig/saig/saigSimSeq.c b/src/aig/saig/saigSimSeq.c index 26783346..c527b152 100644 --- a/src/aig/saig/saigSimSeq.c +++ b/src/aig/saig/saigSimSeq.c @@ -52,7 +52,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 free entry + int MemFree; // next ABC_FREE entry }; static inline int Raig_Var2Lit( int Var, int fCompl ) { return Var + Var + fCompl; } @@ -146,7 +146,7 @@ Raig_Man_t * Raig_ManCreate( Aig_Man_t * pAig ) Aig_Obj_t * pObj; int i, nObjs; Aig_ManCleanData( pAig ); - p = (Raig_Man_t *)ALLOC( Raig_Man_t, 1 ); + p = (Raig_Man_t *)ABC_ALLOC( Raig_Man_t, 1 ); memset( p, 0, sizeof(Raig_Man_t) ); p->pAig = pAig; p->nPis = Saig_ManPiNum(pAig); @@ -155,10 +155,10 @@ Raig_Man_t * Raig_ManCreate( Aig_Man_t * pAig ) p->nCos = Aig_ManPoNum(pAig); p->nNodes = Aig_ManNodeNum(pAig); nObjs = p->nCis + p->nCos + p->nNodes + 2; - p->pFans0 = ALLOC( int, nObjs ); - p->pFans1 = ALLOC( int, nObjs ); - p->pRefs = ALLOC( int, nObjs ); - p->pSims = CALLOC( unsigned, nObjs ); + p->pFans0 = ABC_ALLOC( int, nObjs ); + p->pFans1 = ABC_ALLOC( int, nObjs ); + p->pRefs = ABC_ALLOC( int, nObjs ); + p->pSims = ABC_CALLOC( unsigned, nObjs ); p->vCis2Ids = Vec_IntAlloc( Aig_ManPiNum(pAig) ); // add objects (0=unused; 1=const1) p->nObjs = 2; @@ -202,12 +202,12 @@ void Raig_ManDelete( Raig_Man_t * p ) Vec_IntFree( p->vCis2Ids ); Vec_IntFree( p->vLos ); Vec_IntFree( p->vLis ); - FREE( p->pFans0 ); - FREE( p->pFans1 ); - FREE( p->pRefs ); - FREE( p->pSims ); - FREE( p->pMems ); - FREE( p ); + ABC_FREE( p->pFans0 ); + ABC_FREE( p->pFans1 ); + ABC_FREE( p->pRefs ); + ABC_FREE( p->pSims ); + ABC_FREE( p->pMems ); + ABC_FREE( p ); } /**Function************************************************************* @@ -236,7 +236,7 @@ unsigned * Raig_ManSimRef( Raig_Man_t * p, int i ) p->nMems = 1; } p->nWordsAlloc *= 2; - p->pMems = REALLOC( unsigned, p->pMems, p->nWordsAlloc ); + p->pMems = ABC_REALLOC( unsigned, p->pMems, p->nWordsAlloc ); memset( p->pMems, 0xff, sizeof(unsigned) * (p->nWords + 1) ); pPlace = &p->MemFree; for ( Ent = p->nMems * (p->nWords + 1); @@ -421,7 +421,7 @@ Ssw_Cex_t * Raig_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int // fill in the binary data Aig_ManRandom( 1 ); Counter = p->nRegs; - pData = ALLOC( unsigned, nWords ); + pData = ABC_ALLOC( unsigned, nWords ); for ( f = 0; f <= iFrame; f++, Counter += p->nPis ) for ( i = 0; i < Aig_ManPiNum(pAig); i++ ) { @@ -433,7 +433,7 @@ Ssw_Cex_t * Raig_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int if ( Aig_InfoHasBit( pData, iPat ) ) Aig_InfoSetBit( p->pData, Counter + iPioId ); } - free( pData ); + ABC_FREE( pData ); return p; } @@ -500,7 +500,7 @@ int Raig_ManSimulate( Aig_Man_t * pAig, int nWords, int nIters, int TimeLimit, i p->nMemsMax, 1.0*(p->nObjs * 16)/(1<<20), 1.0*(p->nMemsMax * 4 * (nWords+1))/(1<<20) ); - PRT( "Total time", clock() - clkTotal ); + ABC_PRT( "Total time", clock() - clkTotal ); } Raig_ManDelete( p ); return RetValue > 0; diff --git a/src/aig/saig/saigStrSim.c b/src/aig/saig/saigStrSim.c index ce4b8e05..9e50c9b6 100644 --- a/src/aig/saig/saigStrSim.c +++ b/src/aig/saig/saigStrSim.c @@ -396,9 +396,9 @@ int Saig_StrSimDetectUnique( Aig_Man_t * p0, Aig_Man_t * p1 ) // allocate the hash table hashing simulation info into nodes nTableSize = Aig_PrimeCudd( Aig_ManObjNum(p0)/2 ); - ppTable = CALLOC( Aig_Obj_t *, nTableSize ); - ppNexts = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) ); - ppCands = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) ); + ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize ); + ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) ); + ppCands = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p0) ); // hash nodes of the first AIG Aig_ManForEachObj( p0, pObj, i ) @@ -453,9 +453,9 @@ int Saig_StrSimDetectUnique( Aig_Man_t * p0, Aig_Man_t * p1 ) // cleanup Aig_ManCleanMarkA( p0 ); - free( ppTable ); - free( ppNexts ); - free( ppCands ); + ABC_FREE( ppTable ); + ABC_FREE( ppNexts ); + ABC_FREE( ppCands ); return Counter; } @@ -926,7 +926,7 @@ Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDis i, nMatches, nFlops, 100.0*nFlops/Aig_ManRegNum(pPart0), nNodes, 100.0*nNodes/Aig_ManNodeNum(pPart0) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } if ( i == 20 ) break; @@ -959,7 +959,7 @@ Vec_Int_t * Saig_StrSimPerformMatching( Aig_Man_t * p0, Aig_Man_t * p1, int nDis Aig_ManFanoutStop( pPart1 ); Aig_ManStop( pPart0 ); Aig_ManStop( pPart1 ); - PRT( "Total runtime", clock() - clkTotal ); + ABC_PRT( "Total runtime", clock() - clkTotal ); return vPairs; } diff --git a/src/aig/saig/saigSwitch.c b/src/aig/saig/saigSwitch.c index 684551be..122483d2 100644 --- a/src/aig/saig/saigSwitch.c +++ b/src/aig/saig/saigSwitch.c @@ -63,7 +63,7 @@ Saig_SimObj_t * Saig_ManCreateMan( Aig_Man_t * p ) Saig_SimObj_t * pAig, * pEntry; Aig_Obj_t * pObj; int i; - pAig = CALLOC( Saig_SimObj_t, Aig_ManObjNumMax(p)+1 ); + pAig = ABC_CALLOC( Saig_SimObj_t, Aig_ManObjNumMax(p)+1 ); // printf( "Allocating %7.2f Mb.\n", 1.0 * sizeof(Saig_SimObj_t) * (Aig_ManObjNumMax(p)+1)/(1<<20) ); Aig_ManForEachObj( p, pObj, i ) { @@ -258,7 +258,7 @@ float Saig_ManComputeProbOnePlus( int nOnes, int nSimWords, int fCompl ) SeeAlso [] ***********************************************************************/ -Vec_Int_t * Saig_ManComputeSwitchProbs_old( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ) +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; @@ -269,7 +269,7 @@ Vec_Int_t * Saig_ManComputeSwitchProbs_old( Aig_Man_t * p, int nFrames, int nPre pSwitching = (float *)vSwitching->pArray; clk = clock(); pAig = Saig_ManCreateMan( p ); -//PRT( "\nCreation ", clock() - clk ); +//ABC_PRT( "\nCreation ", clock() - clk ); Aig_ManRandom( 1 ); // get the number of frames to simulate @@ -287,7 +287,7 @@ clk = clock(); //printf( "Simulating %d frames.\n", nFramesReal ); clk = clock(); Saig_ManSimulateFrames( pAig, nFramesReal, nPref ); -//PRT( "Simulation", clock() - clk ); +//ABC_PRT( "Simulation", clock() - clk ); clk = clock(); for ( pEntry = pAig; pEntry->Type != AIG_OBJ_VOID; pEntry++ ) { @@ -312,9 +312,9 @@ clk = clock(); pSwitching[pEntry-pAig] = Saig_ManComputeSwitching( pEntry->Number, nFramesReal - nPref ); //printf( "%3d : %7.2f\n", pEntry-pAig, pSwitching[pEntry-pAig] ); } - free( pAig ); -//PRT( "Switch ", clock() - clk ); -//PRT( "TOTAL ", clock() - clkTotal ); + ABC_FREE( pAig ); +//ABC_PRT( "Switch ", clock() - clk ); +//ABC_PRT( "TOTAL ", clock() - clkTotal ); // Aig_CManCreate( p ); return vSwitching; @@ -356,7 +356,7 @@ struct Aig_CMan_t_ Aig_CMan_t * Aig_CManStart( int nIns, int nNodes, int nOuts ) { Aig_CMan_t * p; - p = (Aig_CMan_t *)ALLOC( char, sizeof(Aig_CMan_t) + 2*(2*nNodes + nOuts) ); + p = (Aig_CMan_t *)ABC_ALLOC( char, sizeof(Aig_CMan_t) + 2*(2*nNodes + nOuts) ); memset( p, 0, sizeof(Aig_CMan_t) ); // set parameters p->nIns = nIns; @@ -383,7 +383,7 @@ Aig_CMan_t * Aig_CManStart( int nIns, int nNodes, int nOuts ) ***********************************************************************/ void Aig_CManStop( Aig_CMan_t * p ) { - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -559,22 +559,6 @@ Aig_CMan_t * Aig_CManCreate( Aig_Man_t * p ) return pCMan; } -/**Function************************************************************* - - Synopsis [Compute switching probabilities of all nodes.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Vec_Int_t * Saig_ManComputeSwitchProbs2( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ) -{ - return NULL; -} - //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/saig/saigSynch.c b/src/aig/saig/saigSynch.c index c52f2f48..ff46634e 100644 --- a/src/aig/saig/saigSynch.c +++ b/src/aig/saig/saigSynch.c @@ -280,7 +280,7 @@ int Saig_SynchCountX( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords, int * int * pCounters, i, w, b; int iPatBest, iTernMin; // count the number of ternary values in each pattern - pCounters = CALLOC( int, nWords * 16 ); + pCounters = ABC_CALLOC( int, nWords * 16 ); Saig_ManForEachLi( pAig, pObj, i ) { pSim = Vec_PtrEntry( vSimInfo, pObj->Id ); @@ -300,7 +300,7 @@ int Saig_SynchCountX( Aig_Man_t * pAig, Vec_Ptr_t * vSimInfo, int nWords, int * if ( iTernMin == 0 ) break; } - free( pCounters ); + ABC_FREE( pCounters ); *piPat = iPatBest; return iTernMin; } @@ -512,7 +512,7 @@ clk = clock(); printf( "Design 1: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSequence) / Saig_ManPiNum(pAig) ); if ( fVerbose ) { - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } else printf( "\n" ); @@ -588,7 +588,7 @@ Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords, printf( "Design 1: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSeq1) / Saig_ManPiNum(pAig1) ); if ( fVerbose ) { - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } else printf( "\n" ); @@ -602,7 +602,7 @@ Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords, printf( "Design 2: Synchronizing sequence of length %4d is found. ", Vec_StrSize(vSeq2) / Saig_ManPiNum(pAig2) ); if ( fVerbose ) { - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } else printf( "\n" ); @@ -646,7 +646,7 @@ Aig_Man_t * Saig_Synchronize( Aig_Man_t * pAig1, Aig_Man_t * pAig2, int nWords, if ( fVerbose ) { printf( "Miter of the synchronized designs is constructed. " ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } return pMiter; } diff --git a/src/aig/saig/saigTrans.c b/src/aig/saig/saigTrans.c index c1c2d8e9..f50af285 100644 --- a/src/aig/saig/saigTrans.c +++ b/src/aig/saig/saigTrans.c @@ -386,7 +386,7 @@ clk = clock(); { Aig_ManPrintStats( pFrames ); Aig_ManPrintStats( pFraig ); -PRT( "Fraiging", clock() - clk ); +ABC_PRT( "Fraiging", clock() - clk ); } Aig_ManStop( pFraig ); assert( pFrames->pReprs != NULL ); @@ -397,12 +397,12 @@ PRT( "Fraiging", clock() - clk ); // create reduced initialized timeframes clk = clock(); pRes2 = Saig_ManFramesInitialMapped( pAig, nFrames, nFramesMax, fInit ); -PRT( "Mapped", clock() - clk ); - // free mapping +ABC_PRT( "Mapped", clock() - clk ); + // ABC_FREE mapping Saig_ManStopMap2( pAig ); clk = clock(); pRes1 = Saig_ManFramesInitialMapped( pAig, nFrames, nFramesMax, fInit ); -PRT( "Normal", clock() - clk ); +ABC_PRT( "Normal", clock() - clk ); // report the results if ( fVerbose ) { diff --git a/src/aig/saig/saigWnd.c b/src/aig/saig/saigWnd.c index 5524e19f..10202f1b 100644 --- a/src/aig/saig/saigWnd.c +++ b/src/aig/saig/saigWnd.c @@ -99,7 +99,7 @@ Vec_Ptr_t * Saig_ManWindowOutline( Aig_Man_t * p, Aig_Obj_t * pObj, int nDist ) Vec_Ptr_t * vNodes; Aig_Obj_t * pObjLi, * pObjLo; int * pDists, i; - pDists = CALLOC( int, Aig_ManObjNumMax(p) ); + pDists = ABC_CALLOC( int, Aig_ManObjNumMax(p) ); vNodes = Vec_PtrAlloc( 1000 ); Aig_ManIncrementTravId( p ); Saig_ManWindowOutline_rec( p, pObj, nDist, vNodes, pDists ); @@ -108,7 +108,7 @@ Vec_Ptr_t * Saig_ManWindowOutline( Aig_Man_t * p, Aig_Obj_t * pObj, int nDist ) Saig_ManForEachLiLo( p, pObjLi, pObjLo, i ) assert( Aig_ObjIsTravIdCurrent(p, pObjLi) == Aig_ObjIsTravIdCurrent(p, pObjLo) ); - free( pDists ); + ABC_FREE( pDists ); return vNodes; } diff --git a/src/aig/ssw/ssw.h b/src/aig/ssw/ssw.h index b3222fca..adb98401 100644 --- a/src/aig/ssw/ssw.h +++ b/src/aig/ssw/ssw.h @@ -21,10 +21,6 @@ #ifndef __SSW_H__ #define __SSW_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/ssw/sswAig.c b/src/aig/ssw/sswAig.c index 97f0a755..62e93d2d 100644 --- a/src/aig/ssw/sswAig.c +++ b/src/aig/ssw/sswAig.c @@ -42,7 +42,7 @@ Ssw_Frm_t * Ssw_FrmStart( Aig_Man_t * pAig ) { Ssw_Frm_t * p; - p = ALLOC( Ssw_Frm_t, 1 ); + p = ABC_ALLOC( Ssw_Frm_t, 1 ); memset( p, 0, sizeof(Ssw_Frm_t) ); p->pAig = pAig; p->nObjs = Aig_ManObjNumMax( pAig ); @@ -69,7 +69,7 @@ void Ssw_FrmStop( Ssw_Frm_t * p ) if ( p->pFrames ) Aig_ManStop( p->pFrames ); Vec_PtrFree( p->vAig2Frm ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/ssw/sswBmc.c b/src/aig/ssw/sswBmc.c index 93859c01..86d04424 100644 --- a/src/aig/ssw/sswBmc.c +++ b/src/aig/ssw/sswBmc.c @@ -161,7 +161,7 @@ int Ssw_BmcDynamic( Aig_Man_t * pAig, int nFramesMax, int nConfLimit, int fVerbo printf( "Solving output %2d of frame %3d ... \r", i % Saig_ManPoNum(pAig), i / Saig_ManPoNum(pAig) ); } - status = sat_solver_solve( pSat->pSat, &Lit, &Lit + 1, (sint64)nConfLimit, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat->pSat, &Lit, &Lit + 1, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status == l_False ) { /* @@ -199,7 +199,7 @@ int Ssw_BmcDynamic( Aig_Man_t * pAig, int nFramesMax, int nConfLimit, int fVerbo printf( "Conf =%8.0f. Var =%8d. AIG=%9d. ", (double)pSat->pSat->stats.conflicts, pSat->nSatVars, Aig_ManNodeNum(pFrm->pFrames) ); - PRT( "T", clock() - clkPart ); + ABC_PRT( "T", clock() - clkPart ); clkPart = clock(); fflush( stdout ); } diff --git a/src/aig/ssw/sswClass.c b/src/aig/ssw/sswClass.c index 3528ae27..5d0be217 100644 --- a/src/aig/ssw/sswClass.c +++ b/src/aig/ssw/sswClass.c @@ -136,11 +136,11 @@ static inline Aig_Obj_t ** Ssw_ObjRemoveClass( Ssw_Cla_t * p, Aig_Obj_t * pRepr Ssw_Cla_t * Ssw_ClassesStart( Aig_Man_t * pAig ) { Ssw_Cla_t * p; - p = ALLOC( Ssw_Cla_t, 1 ); + p = ABC_ALLOC( Ssw_Cla_t, 1 ); memset( p, 0, sizeof(Ssw_Cla_t) ); p->pAig = pAig; - p->pId2Class = CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) ); - p->pClassSizes = CALLOC( int, Aig_ManObjNumMax(pAig) ); + p->pId2Class = ABC_CALLOC( Aig_Obj_t **, Aig_ManObjNumMax(pAig) ); + p->pClassSizes = ABC_CALLOC( int, Aig_ManObjNumMax(pAig) ); p->vClassOld = Vec_PtrAlloc( 100 ); p->vClassNew = Vec_PtrAlloc( 100 ); p->vRefined = Vec_PtrAlloc( 1000 ); @@ -187,10 +187,10 @@ void Ssw_ClassesStop( Ssw_Cla_t * p ) if ( p->vClassNew ) Vec_PtrFree( p->vClassNew ); if ( p->vClassOld ) Vec_PtrFree( p->vClassOld ); Vec_PtrFree( p->vRefined ); - FREE( p->pId2Class ); - FREE( p->pClassSizes ); - FREE( p->pMemClasses ); - free( p ); + ABC_FREE( p->pId2Class ); + ABC_FREE( p->pClassSizes ); + ABC_FREE( p->pMemClasses ); + ABC_FREE( p ); } /**Function************************************************************* @@ -500,8 +500,8 @@ int Ssw_ClassesPrepareRehash( Ssw_Cla_t * p, Vec_Ptr_t * vCands ) // allocate the hash table hashing simulation info into nodes nTableSize = Aig_PrimeCudd( Vec_PtrSize(vCands)/2 ); - ppTable = CALLOC( Aig_Obj_t *, nTableSize ); - ppNexts = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) ); + ppTable = ABC_CALLOC( Aig_Obj_t *, nTableSize ); + ppNexts = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) ); // sort through the candidates nEntries = 0; @@ -568,8 +568,8 @@ int Ssw_ClassesPrepareRehash( Ssw_Cla_t * p, Vec_Ptr_t * vCands ) } p->pMemClassesFree += nEntries2; assert( nEntries == nEntries2 ); - free( ppTable ); - free( ppNexts ); + ABC_FREE( ppTable ); + ABC_FREE( ppNexts ); // now it is time to refine the classes return Ssw_ClassesRefine( p, 1 ); } @@ -615,7 +615,7 @@ if ( fVerbose ) printf( "Allocated %.2f Mb to store simulation information.\n", 1.0*(sizeof(unsigned) * Aig_ManObjNumMax(pAig) * nFrames * nWords)/(1<<20) ); printf( "Initial simulation of %d frames with %d words. ", nFrames, nWords ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // set comparison procedures @@ -643,7 +643,7 @@ clk = clock(); } // allocate room for classes - p->pMemClasses = ALLOC( Aig_Obj_t *, Vec_PtrSize(vCands) ); + p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, Vec_PtrSize(vCands) ); p->pMemClassesFree = p->pMemClasses; // now it is time to refine the classes @@ -651,7 +651,7 @@ clk = clock(); if ( fVerbose ) { printf( "Collecting candidate equivalence classes. " ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } clk = clock(); @@ -677,7 +677,7 @@ if ( fVerbose ) { printf( "Simulation of %d frames with %d words (%2d rounds). ", nFrames, nWords, i-1 ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } Ssw_ClassesCheck( p ); // Ssw_ClassesPrint( p, 0 ); @@ -723,7 +723,7 @@ Ssw_Cla_t * Ssw_ClassesPrepareSimple( Aig_Man_t * pAig, int fLatchCorr, int nMax p->nCands1++; } // allocate room for classes - p->pMemClassesFree = p->pMemClasses = ALLOC( Aig_Obj_t *, p->nCands1 ); + p->pMemClassesFree = p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, p->nCands1 ); // Ssw_ClassesPrint( p, 0 ); return p; } @@ -754,7 +754,7 @@ Ssw_Cla_t * Ssw_ClassesPrepareTargets( Aig_Man_t * pAig ) p->nCands1++; } // allocate room for classes - p->pMemClassesFree = p->pMemClasses = ALLOC( Aig_Obj_t *, p->nCands1 ); + p->pMemClassesFree = p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, p->nCands1 ); // Ssw_ClassesPrint( p, 0 ); return p; } @@ -783,7 +783,7 @@ Ssw_Cla_t * Ssw_ClassesPreparePairs( Aig_Man_t * pAig, Vec_Int_t ** pvClasses ) for ( i = 0; i < Aig_ManObjNumMax(pAig); i++ ) nTotalObjs += pvClasses[i] ? Vec_IntSize(pvClasses[i]) : 0; // allocate memory for classes - p->pMemClasses = ALLOC( Aig_Obj_t *, nTotalObjs ); + p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, nTotalObjs ); // create constant-1 class if ( pvClasses[0] ) Vec_IntForEachEntry( pvClasses[0], Entry, i ) @@ -845,7 +845,7 @@ Ssw_Cla_t * Ssw_ClassesPreparePairsSimple( Aig_Man_t * pMiter, Vec_Int_t * vPair // start the classes p = Ssw_ClassesStart( pMiter ); // allocate memory for classes - p->pMemClasses = ALLOC( Aig_Obj_t *, Vec_IntSize(vPairs) ); + p->pMemClasses = ABC_ALLOC( Aig_Obj_t *, Vec_IntSize(vPairs) ); // create classes for ( i = 0; i < Vec_IntSize(vPairs); i += 2 ) { diff --git a/src/aig/ssw/sswCnf.c b/src/aig/ssw/sswCnf.c index c5ea9b28..73fa0b02 100644 --- a/src/aig/ssw/sswCnf.c +++ b/src/aig/ssw/sswCnf.c @@ -43,7 +43,7 @@ Ssw_Sat_t * Ssw_SatStart( int fPolarFlip ) { Ssw_Sat_t * p; int Lit; - p = ALLOC( Ssw_Sat_t, 1 ); + p = ABC_ALLOC( Ssw_Sat_t, 1 ); memset( p, 0, sizeof(Ssw_Sat_t) ); p->pAig = NULL; p->fPolarFlip = fPolarFlip; @@ -84,7 +84,7 @@ void Ssw_SatStop( Ssw_Sat_t * p ) Vec_IntFree( p->vSatVars ); Vec_PtrFree( p->vFanins ); Vec_PtrFree( p->vUsedPis ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -225,7 +225,7 @@ void Ssw_AddClausesSuper( Ssw_Sat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) assert( Aig_ObjIsNode( pNode ) ); // create storage for literals nLits = Vec_PtrSize(vSuper) + 1; - pLits = ALLOC( int, nLits ); + pLits = ABC_ALLOC( int, nLits ); // suppose AND-gate is A & B = C // add !A => !C or A + !C Vec_PtrForEachEntry( vSuper, pFanin, i ) @@ -256,7 +256,7 @@ void Ssw_AddClausesSuper( Ssw_Sat_t * p, Aig_Obj_t * pNode, Vec_Ptr_t * vSuper ) } RetValue = sat_solver_addclause( p->pSat, pLits, pLits + nLits ); assert( RetValue ); - free( pLits ); + ABC_FREE( pLits ); } /**Function************************************************************* diff --git a/src/aig/ssw/sswCore.c b/src/aig/ssw/sswCore.c index 38a36022..485a5146 100644 --- a/src/aig/ssw/sswCore.c +++ b/src/aig/ssw/sswCore.c @@ -157,7 +157,7 @@ clk = clock(); nIter, Ssw_ClassesCand1Num(p->ppClasses), Ssw_ClassesClassNum(p->ppClasses), p->nSatProof-nSatProof, p->nSatCallsSat-nSatCallsSat, p->nRecycles-nRecycles, p->nSatFailsReal-nSatFailsReal ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); } } else @@ -180,7 +180,7 @@ clk = clock(); printf( "R =%4d. ", p->nRecycles-nRecycles ); } printf( "F =%5d. ", p->nSatFailsReal-nSatFailsReal ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); } // if ( p->pPars->fDynamic && p->nSatCallsSat-nSatCallsSat < 100 ) // p->pPars->nBTLimit = 10000; @@ -299,7 +299,7 @@ Aig_Man_t * Ssw_SignalCorrespondence( Aig_Man_t * pAig, Ssw_Pars_t * pPars ) Ssw_ClassesSetData( p->ppClasses, NULL, NULL, Ssw_SmlObjIsConstBit, Ssw_SmlObjsAreEqualBit ); } if ( p->pPars->fLocalSim ) - p->pVisited = CALLOC( int, Ssw_SmlNumFrames( p->pSml ) * Aig_ManObjNumMax(p->pAig) ); + p->pVisited = ABC_CALLOC( int, Ssw_SmlNumFrames( p->pSml ) * Aig_ManObjNumMax(p->pAig) ); // perform refinement of classes pAigNew = Ssw_SignalCorrespondenceRefine( p ); if ( pPars->fUniqueness ) diff --git a/src/aig/ssw/sswInt.h b/src/aig/ssw/sswInt.h index 930796fc..269bdad7 100644 --- a/src/aig/ssw/sswInt.h +++ b/src/aig/ssw/sswInt.h @@ -21,10 +21,6 @@ #ifndef __SSW_INT_H__ #define __SSW_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/ssw/sswIslands.c b/src/aig/ssw/sswIslands.c index 64515f3e..8913116c 100644 --- a/src/aig/ssw/sswIslands.c +++ b/src/aig/ssw/sswIslands.c @@ -491,7 +491,7 @@ int Ssw_SecWithSimilarityPairs( Aig_Man_t * p0, Aig_Man_t * p1, Vec_Int_t * vPai else printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ", Aig_ManRegNum(pAigRes), Aig_ManRegNum(p0)+Aig_ManRegNum(p1) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); Aig_ManStop( pAigRes ); return RetValue; } diff --git a/src/aig/ssw/sswMan.c b/src/aig/ssw/sswMan.c index 7e6e4473..90cc9028 100644 --- a/src/aig/ssw/sswMan.c +++ b/src/aig/ssw/sswMan.c @@ -47,17 +47,17 @@ Ssw_Man_t * Ssw_ManCreate( Aig_Man_t * pAig, Ssw_Pars_t * pPars ) Aig_ManFanoutStart( pAig ); Aig_ManSetPioNumbers( pAig ); // create interpolation manager - p = ALLOC( Ssw_Man_t, 1 ); + p = ABC_ALLOC( Ssw_Man_t, 1 ); memset( p, 0, sizeof(Ssw_Man_t) ); p->pPars = pPars; p->pAig = pAig; p->nFrames = pPars->nFramesK + 1; - p->pNodeToFrames = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) * p->nFrames ); + p->pNodeToFrames = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pAig) * p->nFrames ); p->vCommon = Vec_PtrAlloc( 100 ); p->iOutputLit = -1; // allocate storage for sim pattern p->nPatWords = Aig_BitWordNum( Saig_ManPiNum(pAig) * p->nFrames + Saig_ManRegNum(pAig) ); - p->pPatWords = ALLOC( unsigned, p->nPatWords ); + p->pPatWords = ABC_ALLOC( unsigned, p->nPatWords ); // other p->vNewLos = Vec_PtrAlloc( 100 ); p->vNewPos = Vec_IntAlloc( 100 ); @@ -117,16 +117,16 @@ void Ssw_ManPrintStats( Ssw_Man_t * p ) p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/(p->nRegsBeg?p->nRegsBeg:1) ); p->timeOther = p->timeTotal-p->timeBmc-p->timeReduce-p->timeMarkCones-p->timeSimSat-p->timeSat; - PRTP( "BMC ", p->timeBmc, p->timeTotal ); - PRTP( "Spec reduce", p->timeReduce, p->timeTotal ); - PRTP( "Mark cones ", p->timeMarkCones, p->timeTotal ); - PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal ); - PRTP( "SAT solving", p->timeSat, p->timeTotal ); - PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); - PRTP( " sat ", p->timeSatSat, p->timeTotal ); - PRTP( " undecided", p->timeSatUndec, p->timeTotal ); - PRTP( "Other ", p->timeOther, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + ABC_PRTP( "BMC ", p->timeBmc, p->timeTotal ); + ABC_PRTP( "Spec reduce", p->timeReduce, p->timeTotal ); + ABC_PRTP( "Mark cones ", p->timeMarkCones, p->timeTotal ); + ABC_PRTP( "Sim SAT ", p->timeSimSat, p->timeTotal ); + ABC_PRTP( "SAT solving", p->timeSat, p->timeTotal ); + ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); + ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal ); + ABC_PRTP( " undecided", p->timeSatUndec, p->timeTotal ); + ABC_PRTP( "Other ", p->timeOther, p->timeTotal ); + ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); } /**Function************************************************************* @@ -173,7 +173,7 @@ void Ssw_ManCleanup( Ssw_Man_t * p ) ***********************************************************************/ void Ssw_ManStop( Ssw_Man_t * p ) { - FREE( p->pVisited ); + ABC_FREE( p->pVisited ); if ( p->pPars->fVerbose ) Ssw_ManPrintStats( p ); if ( p->ppClasses ) @@ -187,9 +187,9 @@ void Ssw_ManStop( Ssw_Man_t * p ) Vec_PtrFree( p->vNewLos ); Vec_IntFree( p->vNewPos ); Vec_PtrFree( p->vCommon ); - FREE( p->pNodeToFrames ); - FREE( p->pPatWords ); - free( p ); + ABC_FREE( p->pNodeToFrames ); + ABC_FREE( p->pPatWords ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/ssw/sswPairs.c b/src/aig/ssw/sswPairs.c index 1af357f9..3c079922 100644 --- a/src/aig/ssw/sswPairs.c +++ b/src/aig/ssw/sswPairs.c @@ -149,8 +149,8 @@ Vec_Int_t ** Ssw_TransformPairsIntoTempClasses( Vec_Int_t * vPairs, int nObjNumM int * pReprs; // mapping nodes into their representatives int Entry, idObj, idRepr, idReprObj, idReprRepr, i; // allocate data-structures - pvClasses = CALLOC( Vec_Int_t *, nObjNumMax ); - pReprs = ALLOC( int, nObjNumMax ); + pvClasses = ABC_CALLOC( Vec_Int_t *, nObjNumMax ); + pReprs = ABC_ALLOC( int, nObjNumMax ); for ( i = 0; i < nObjNumMax; i++ ) pReprs[i] = -1; // consider pairs @@ -231,7 +231,7 @@ Vec_Int_t ** Ssw_TransformPairsIntoTempClasses( Vec_Int_t * vPairs, int nObjNumM } } } - free( pReprs ); + ABC_FREE( pReprs ); return pvClasses; } @@ -252,7 +252,7 @@ void Ssw_FreeTempClasses( Vec_Int_t ** pvClasses, int nObjNumMax ) for ( i = 0; i < nObjNumMax; i++ ) if ( pvClasses[i] ) Vec_IntFree( pvClasses[i] ); - free( pvClasses ); + ABC_FREE( pvClasses ); } /**Function************************************************************* @@ -356,7 +356,7 @@ Aig_Man_t * Ssw_SignalCorrespondeceTestPairs( Aig_Man_t * pAig ) else printf( "Verification UNDECIDED. Remaining registers %d (total %d). ", Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig) + Aig_ManRegNum(pAigNew) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); // cleanup Aig_ManStop( pAigNew ); return pAigRes; @@ -390,7 +390,7 @@ int Ssw_SecWithPairs( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Vec_Int_t * vIds1, V else printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ", Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig1) + Aig_ManRegNum(pAig2) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); // cleanup Aig_ManStop( pAigRes ); return RetValue; @@ -426,7 +426,7 @@ int Ssw_SecGeneral( Aig_Man_t * pAig1, Aig_Man_t * pAig2, Ssw_Pars_t * pPars ) else printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ", Aig_ManRegNum(pAigRes), Aig_ManRegNum(pAig1) + Aig_ManRegNum(pAig2) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); // cleanup Aig_ManStop( pAigRes ); return RetValue; @@ -459,7 +459,7 @@ int Ssw_SecGeneralMiter( Aig_Man_t * pMiter, Ssw_Pars_t * pPars ) else printf( "Verification UNDECIDED. The number of remaining regs = %d (total = %d). ", Aig_ManRegNum(pAigRes), Aig_ManRegNum(pMiter) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); // cleanup Aig_ManStop( pAigRes ); return RetValue; diff --git a/src/aig/ssw/sswPart.c b/src/aig/ssw/sswPart.c index 9d2ec34e..f481b457 100644 --- a/src/aig/ssw/sswPart.c +++ b/src/aig/ssw/sswPart.c @@ -106,7 +106,7 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars ) Aig_ManStop( pNew ); } Aig_ManStop( pTemp ); - free( pMapBack ); + ABC_FREE( pMapBack ); } // remap the AIG pNew = Aig_ManDupRepr( pAig, 0 ); @@ -118,7 +118,7 @@ Aig_Man_t * Ssw_SignalCorrespondencePart( Aig_Man_t * pAig, Ssw_Pars_t * pPars ) pPars->fVerbose = fVerbose; if ( fVerbose ) { - PRT( "Total time", clock() - clk ); + ABC_PRT( "Total time", clock() - clk ); } return pNew; } diff --git a/src/aig/ssw/sswSat.c b/src/aig/ssw/sswSat.c index 2fd0fba3..21c5c1f1 100644 --- a/src/aig/ssw/sswSat.c +++ b/src/aig/ssw/sswSat.c @@ -81,7 +81,7 @@ int Ssw_NodesAreEquiv( Ssw_Man_t * p, Aig_Obj_t * pOld, Aig_Obj_t * pNew ) clk = clock(); RetValue1 = sat_solver_solve( p->pMSat->pSat, pLits, pLits + nLits, - (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) { @@ -143,7 +143,7 @@ p->timeSatUndec += clock() - clk; clk = clock(); RetValue1 = sat_solver_solve( p->pMSat->pSat, pLits, pLits + nLits, - (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); p->timeSat += clock() - clk; if ( RetValue1 == l_False ) { diff --git a/src/aig/ssw/sswSemi.c b/src/aig/ssw/sswSemi.c index 572ab076..5f426093 100644 --- a/src/aig/ssw/sswSemi.c +++ b/src/aig/ssw/sswSemi.c @@ -64,7 +64,7 @@ Ssw_Sem_t * Ssw_SemManStart( Ssw_Man_t * pMan, int nConfMax, int fVerbose ) Aig_Obj_t * pObj; int i; // create interpolation manager - p = ALLOC( Ssw_Sem_t, 1 ); + p = ABC_ALLOC( Ssw_Sem_t, 1 ); memset( p, 0, sizeof(Ssw_Sem_t) ); p->nConfMaxStart = nConfMax; p->nConfMax = nConfMax; @@ -85,9 +85,9 @@ Ssw_Sem_t * Ssw_SemManStart( Ssw_Man_t * pMan, int nConfMax, int fVerbose ) // update arrays of the manager assert( 0 ); /* - free( p->pMan->pNodeToFrames ); + ABC_FREE( p->pMan->pNodeToFrames ); Vec_IntFree( p->pMan->vSatVars ); - p->pMan->pNodeToFrames = CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pMan->pAig) * p->nFramesSweep ); + p->pMan->pNodeToFrames = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(p->pMan->pAig) * p->nFramesSweep ); p->pMan->vSatVars = Vec_IntStart( Aig_ManObjNumMax(p->pMan->pAig) * (p->nFramesSweep+1) ); */ return p; @@ -109,7 +109,7 @@ void Ssw_SemManStop( Ssw_Sem_t * p ) Vec_PtrFree( p->vTargets ); Vec_PtrFree( p->vPatterns ); Vec_IntFree( p->vHistory ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -283,7 +283,7 @@ clk = clock(); Iter, Ssw_ClassesCand1Num(p->pMan->ppClasses), Ssw_ClassesClassNum(p->pMan->ppClasses), Aig_ManNodeNum(p->pMan->pFrames), Frames, (int)p->pMan->pMSat->pSat->stats.conflicts, p->nPatterns, p->pMan->nSatFailsReal? "f" : " " ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); } Ssw_ManCleanup( p->pMan ); if ( fCheckTargets && Ssw_SemCheckTargets( p ) ) diff --git a/src/aig/ssw/sswSim.c b/src/aig/ssw/sswSim.c index a860199e..7a2f4664 100644 --- a/src/aig/ssw/sswSim.c +++ b/src/aig/ssw/sswSim.c @@ -437,7 +437,7 @@ int * Ssw_SmlCheckOutputSavePattern( Ssw_Sml_t * p, Aig_Obj_t * pObjPo ) // determine the best pattern BestPat = i * 32 + k; // fill in the counter-example data - pModel = ALLOC( int, Aig_ManPiNum(p->pAig)+1 ); + pModel = ABC_ALLOC( int, Aig_ManPiNum(p->pAig)+1 ); Aig_ManForEachPi( p->pAig, pObjPi, i ) { pModel[i] = Aig_InfoHasBit(Ssw_ObjSim(p, pObjPi->Id), BestPat); @@ -1074,7 +1074,7 @@ p->nSimRounds++; Ssw_Sml_t * Ssw_SmlStart( Aig_Man_t * pAig, int nPref, int nFrames, int nWordsFrame ) { Ssw_Sml_t * p; - p = (Ssw_Sml_t *)malloc( sizeof(Ssw_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame ); + p = (Ssw_Sml_t *)ABC_ALLOC( char, sizeof(Ssw_Sml_t) + sizeof(unsigned) * Aig_ManObjNumMax(pAig) * (nPref + nFrames) * nWordsFrame ); memset( p, 0, sizeof(Ssw_Sml_t) + sizeof(unsigned) * (nPref + nFrames) * nWordsFrame ); p->pAig = pAig; p->nPref = nPref; @@ -1114,7 +1114,7 @@ void Ssw_SmlClean( Ssw_Sml_t * p ) ***********************************************************************/ void Ssw_SmlStop( Ssw_Sml_t * p ) { - free( p ); + ABC_FREE( p ); } @@ -1244,7 +1244,7 @@ Ssw_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames ) { Ssw_Cex_t * pCex; int nWords = Aig_BitWordNum( nRegs + nRealPis * nFrames ); - pCex = (Ssw_Cex_t *)malloc( sizeof(Ssw_Cex_t) + sizeof(unsigned) * nWords ); + 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->nRegs = nRegs; pCex->nPis = nRealPis; @@ -1265,7 +1265,7 @@ Ssw_Cex_t * Ssw_SmlAllocCounterExample( int nRegs, int nRealPis, int nFrames ) ***********************************************************************/ void Ssw_SmlFreeCounterExample( Ssw_Cex_t * pCex ) { - free( pCex ); + ABC_FREE( pCex ); } /**Function************************************************************* diff --git a/src/aig/tim/tim.c b/src/aig/tim/tim.c index 9d5c8f7f..7327606e 100644 --- a/src/aig/tim/tim.c +++ b/src/aig/tim/tim.c @@ -118,15 +118,15 @@ Tim_Man_t * Tim_ManStart( int nCis, int nCos ) { Tim_Man_t * p; int i; - p = ALLOC( Tim_Man_t, 1 ); + p = ABC_ALLOC( Tim_Man_t, 1 ); memset( p, 0, sizeof(Tim_Man_t) ); p->pMemObj = Mem_FlexStart(); p->vBoxes = Vec_PtrAlloc( 100 ); p->nCis = nCis; p->nCos = nCos; - p->pCis = ALLOC( Tim_Obj_t, nCis ); + p->pCis = ABC_ALLOC( Tim_Obj_t, nCis ); memset( p->pCis, 0, sizeof(Tim_Obj_t) * nCis ); - p->pCos = ALLOC( Tim_Obj_t, nCos ); + p->pCos = ABC_ALLOC( Tim_Obj_t, nCos ); memset( p->pCos, 0, sizeof(Tim_Obj_t) * nCos ); for ( i = 0; i < nCis; i++ ) { @@ -182,7 +182,7 @@ Tim_Man_t * Tim_ManDup( Tim_Man_t * p, int fDiscrete ) pNew->vDelayTables = Vec_PtrAlloc( 100 ); Tim_ManForEachBox( p, pBox, i ) { - pDelayTableNew = ALLOC( float, pBox->nInputs * pBox->nOutputs ); + pDelayTableNew = ABC_ALLOC( float, pBox->nInputs * pBox->nOutputs ); Vec_PtrPush( pNew->vDelayTables, pDelayTableNew ); if ( fDiscrete ) { @@ -228,7 +228,7 @@ Tim_Man_t * Tim_ManDupUnit( Tim_Man_t * p ) pNew->vDelayTables = Vec_PtrAlloc( 100 ); Tim_ManForEachBox( p, pBox, i ) { - pDelayTableNew = ALLOC( float, pBox->nInputs * pBox->nOutputs ); + pDelayTableNew = ABC_ALLOC( float, pBox->nInputs * pBox->nOutputs ); Vec_PtrPush( pNew->vDelayTables, pDelayTableNew ); for ( k = 0; k < pBox->nInputs * pBox->nOutputs; k++ ) pDelayTableNew[k] = 1.0; @@ -283,14 +283,14 @@ void Tim_ManStop( Tim_Man_t * p ) if ( p->vDelayTables ) { Vec_PtrForEachEntry( p->vDelayTables, pTable, i ) - FREE( pTable ); + ABC_FREE( pTable ); Vec_PtrFree( p->vDelayTables ); } Vec_PtrFree( p->vBoxes ); Mem_FlexStop( p->pMemObj, 0 ); - free( p->pCis ); - free( p->pCos ); - free( p ); + ABC_FREE( p->pCis ); + ABC_FREE( p->pCos ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/aig/tim/tim.h b/src/aig/tim/tim.h index 7c6e33f1..bdb8e61e 100644 --- a/src/aig/tim/tim.h +++ b/src/aig/tim/tim.h @@ -21,10 +21,6 @@ #ifndef __TIM_H__ #define __TIM_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/abc/abc.h b/src/base/abc/abc.h index 987adaad..b7fe6316 100644 --- a/src/base/abc/abc.h +++ b/src/base/abc/abc.h @@ -21,10 +21,6 @@ #ifndef __ABC_H__ #define __ABC_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -46,6 +42,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + // network types typedef enum { ABC_NTK_NONE = 0, // 0: unknown @@ -160,7 +160,7 @@ struct Abc_Obj_t_ // 12 words int iTemp; float dTemp; }; - Hop_Obj_t * pEquiv; // pointer to the HAIG node +// Hop_Obj_t * pEquiv; // pointer to the HAIG node }; struct Abc_Ntk_t_ @@ -229,25 +229,6 @@ struct Abc_Lib_t_ /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -//#pragma warning( disable : 4273 ) - -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - -// maximum/minimum operators -#define ABC_MIN(a,b) (((a) < (b))? (a) : (b)) -#define ABC_MAX(a,b) (((a) > (b))? (a) : (b)) -#define ABC_ABS(a) (((a) >= 0)? (a) :-(a)) -#define ABC_INFINITY (100000000) - // 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); } @@ -347,10 +328,10 @@ static inline Abc_Obj_t * Abc_NtkAssert( Abc_Ntk_t * pNtk, int i ) { return (A 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)((PORT_PTRUINT_T)p & (PORT_PTRUINT_T)01); } -static inline Abc_Obj_t * Abc_ObjRegular( Abc_Obj_t * p ) { return (Abc_Obj_t *)((PORT_PTRUINT_T)p & ~(PORT_PTRUINT_T)01); } -static inline Abc_Obj_t * Abc_ObjNot( Abc_Obj_t * p ) { return (Abc_Obj_t *)((PORT_PTRUINT_T)p ^ (PORT_PTRUINT_T)01); } -static inline Abc_Obj_t * Abc_ObjNotCond( Abc_Obj_t * p, int c ) { return (Abc_Obj_t *)((PORT_PTRUINT_T)p ^ (PORT_PTRUINT_T)(c!=0)); } +static inline bool Abc_ObjIsComplement( Abc_Obj_t * p ) { return (bool)((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)); } // reading data members of the object static inline unsigned Abc_ObjType( Abc_Obj_t * pObj ) { return pObj->Type; } @@ -362,7 +343,7 @@ static inline Vec_Int_t * Abc_ObjFanoutVec( Abc_Obj_t * pObj ) { return &p static inline Abc_Obj_t * Abc_ObjCopy( Abc_Obj_t * pObj ) { return pObj->pCopy; } static inline Abc_Ntk_t * Abc_ObjNtk( Abc_Obj_t * pObj ) { return pObj->pNtk; } static inline void * Abc_ObjData( Abc_Obj_t * pObj ) { return pObj->pData; } -static inline Hop_Obj_t * Abc_ObjEquiv( Abc_Obj_t * pObj ) { return pObj->pEquiv; } +//static inline Hop_Obj_t * Abc_ObjEquiv( Abc_Obj_t * pObj ) { return pObj->pEquiv; } static inline Abc_Obj_t * Abc_ObjCopyCond( Abc_Obj_t * pObj ) { return Abc_ObjRegular(pObj)->pCopy? Abc_ObjNotCond(Abc_ObjRegular(pObj)->pCopy, Abc_ObjIsComplement(pObj)) : NULL; } // setting data members of the network @@ -415,8 +396,8 @@ static inline Abc_Obj_t * Abc_ObjChild0Copy( Abc_Obj_t * pObj ) { return Ab static inline Abc_Obj_t * Abc_ObjChild1Copy( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC1(pObj) ); } static inline Abc_Obj_t * Abc_ObjChild0Data( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( (Abc_Obj_t *)Abc_ObjFanin0(pObj)->pData, Abc_ObjFaninC0(pObj) ); } static inline Abc_Obj_t * Abc_ObjChild1Data( Abc_Obj_t * pObj ) { return Abc_ObjNotCond( (Abc_Obj_t *)Abc_ObjFanin1(pObj)->pData, Abc_ObjFaninC1(pObj) ); } -static inline Hop_Obj_t * Abc_ObjChild0Equiv( Abc_Obj_t * pObj ) { return Hop_NotCond( Abc_ObjFanin0(pObj)->pEquiv, Abc_ObjFaninC0(pObj) ); } -static inline Hop_Obj_t * Abc_ObjChild1Equiv( Abc_Obj_t * pObj ) { return Hop_NotCond( Abc_ObjFanin1(pObj)->pEquiv, Abc_ObjFaninC1(pObj) ); } +//static inline Hop_Obj_t * Abc_ObjChild0Equiv( Abc_Obj_t * pObj ) { return Hop_NotCond( Abc_ObjFanin0(pObj)->pEquiv, Abc_ObjFaninC0(pObj) ); } +//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; } @@ -444,7 +425,7 @@ static inline bool Abc_LatchIsInitNone( Abc_Obj_t * pLatch ) { assert(Ab 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_LatchInit( Abc_Obj_t * pLatch ) { assert(Abc_ObjIsLatch(pLatch)); return (int)(PORT_PTRINT_T)pLatch->pData; } +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 static inline void * Abc_NtkGlobalBdd( Abc_Ntk_t * pNtk ) { return (void *)Vec_PtrEntry(pNtk->vAttrs, VEC_ATTR_GLOBAL_BDD); } @@ -754,7 +735,7 @@ extern ABC_DLL bool Abc_NodeIsInv( Abc_Obj_t * pNode ); extern ABC_DLL void Abc_NodeComplement( Abc_Obj_t * pNode ); /*=== 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 ); +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_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 ); @@ -805,7 +786,7 @@ extern ABC_DLL int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSi /*=== abcRewrite.c ==========================================================*/ extern ABC_DLL int Abc_NtkRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeros, int fVerbose, int fVeryVerbose, int fPlaceEnable ); /*=== abcSat.c ==========================================================*/ -extern ABC_DLL int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int fVerbose, sint64 * pNumConfs, sint64 * pNumInspects ); +extern ABC_DLL int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T * pNumConfs, ABC_INT64_T * pNumInspects ); extern ABC_DLL void * Abc_NtkMiterSatCreate( Abc_Ntk_t * pNtk, int fAllPrimes ); /*=== abcSop.c ==========================================================*/ extern ABC_DLL char * Abc_SopRegister( Extra_MmFlex_t * pMan, char * pName ); diff --git a/src/base/abc/abcAig.c b/src/base/abc/abcAig.c index 3cc4d59c..289c422d 100644 --- a/src/base/abc/abcAig.c +++ b/src/base/abc/abcAig.c @@ -126,11 +126,11 @@ Abc_Aig_t * Abc_AigAlloc( Abc_Ntk_t * pNtkAig ) { Abc_Aig_t * pMan; // start the manager - pMan = ALLOC( Abc_Aig_t, 1 ); + pMan = ABC_ALLOC( Abc_Aig_t, 1 ); memset( pMan, 0, sizeof(Abc_Aig_t) ); // allocate the table pMan->nBins = Cudd_PrimeCopy( 10000 ); - pMan->pBins = ALLOC( Abc_Obj_t *, pMan->nBins ); + pMan->pBins = ABC_ALLOC( Abc_Obj_t *, pMan->nBins ); memset( pMan->pBins, 0, sizeof(Abc_Obj_t *) * pMan->nBins ); pMan->vNodes = Vec_PtrAlloc( 100 ); pMan->vLevels = Vec_VecAlloc( 100 ); @@ -163,7 +163,7 @@ void Abc_AigFree( Abc_Aig_t * pMan ) { assert( Vec_PtrSize( pMan->vStackReplaceOld ) == 0 ); assert( Vec_PtrSize( pMan->vStackReplaceNew ) == 0 ); - // free the table + // ABC_FREE the table if ( pMan->vAddedCells ) Vec_PtrFree( pMan->vAddedCells ); if ( pMan->vUpdatedNets ) @@ -173,8 +173,8 @@ void Abc_AigFree( Abc_Aig_t * pMan ) Vec_PtrFree( pMan->vStackReplaceOld ); Vec_PtrFree( pMan->vStackReplaceNew ); Vec_PtrFree( pMan->vNodes ); - free( pMan->pBins ); - free( pMan ); + ABC_FREE( pMan->pBins ); + ABC_FREE( pMan ); } /**Function************************************************************* @@ -342,8 +342,8 @@ Abc_Obj_t * Abc_AigAndCreate( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * p1 ) if ( pMan->vAddedCells ) Vec_PtrPush( pMan->vAddedCells, pAnd ); // create HAIG - if ( pAnd->pNtk->pHaig ) - pAnd->pEquiv = Hop_And( pAnd->pNtk->pHaig, Abc_ObjChild0Equiv(pAnd), Abc_ObjChild1Equiv(pAnd) ); +// if ( pAnd->pNtk->pHaig ) +// pAnd->pEquiv = Hop_And( pAnd->pNtk->pHaig, Abc_ObjChild0Equiv(pAnd), Abc_ObjChild1Equiv(pAnd) ); return pAnd; } @@ -385,8 +385,8 @@ Abc_Obj_t * Abc_AigAndCreateFrom( Abc_Aig_t * pMan, Abc_Obj_t * p0, Abc_Obj_t * // if ( pMan->vAddedCells ) // Vec_PtrPush( pMan->vAddedCells, pAnd ); // create HAIG - if ( pAnd->pNtk->pHaig ) - pAnd->pEquiv = Hop_And( pAnd->pNtk->pHaig, Abc_ObjChild0Equiv(pAnd), Abc_ObjChild1Equiv(pAnd) ); +// if ( pAnd->pNtk->pHaig ) +// pAnd->pEquiv = Hop_And( pAnd->pNtk->pHaig, Abc_ObjChild0Equiv(pAnd), Abc_ObjChild1Equiv(pAnd) ); return pAnd; } @@ -593,7 +593,7 @@ clk = clock(); // get the new table size nBinsNew = Cudd_PrimeCopy( 3 * pMan->nBins ); // allocate a new array - pBinsNew = ALLOC( Abc_Obj_t *, nBinsNew ); + pBinsNew = ABC_ALLOC( Abc_Obj_t *, nBinsNew ); memset( pBinsNew, 0, sizeof(Abc_Obj_t *) * nBinsNew ); // rehash the entries from the old table Counter = 0; @@ -607,9 +607,9 @@ clk = clock(); } assert( Counter == pMan->nEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", pMan->nBins, nBinsNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( pMan->pBins ); + ABC_FREE( pMan->pBins ); pMan->pBins = pBinsNew; pMan->nBins = nBinsNew; } @@ -634,7 +634,7 @@ void Abc_AigRehash( Abc_Aig_t * pMan ) int Counter, Temp, i; // allocate a new array - pBinsNew = ALLOC( Abc_Obj_t *, pMan->nBins ); + pBinsNew = ABC_ALLOC( Abc_Obj_t *, pMan->nBins ); memset( pBinsNew, 0, sizeof(Abc_Obj_t *) * pMan->nBins ); // rehash the entries from the old table Counter = 0; @@ -660,7 +660,7 @@ void Abc_AigRehash( Abc_Aig_t * pMan ) } assert( Counter == pMan->nEntries ); // replace the table and the parameters - free( pMan->pBins ); + ABC_FREE( pMan->pBins ); pMan->pBins = pBinsNew; } @@ -855,8 +855,8 @@ void Abc_AigReplace( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, bool Vec_PtrPush( pMan->vStackReplaceNew, pNew ); assert( !Abc_ObjIsComplement(pOld) ); // create HAIG - if ( pOld->pNtk->pHaig ) - Hop_ObjCreateChoice( pOld->pEquiv, Abc_ObjRegular(pNew)->pEquiv ); +// if ( pOld->pNtk->pHaig ) +// Hop_ObjCreateChoice( pOld->pEquiv, Abc_ObjRegular(pNew)->pEquiv ); // process the replacements while ( Vec_PtrSize(pMan->vStackReplaceOld) ) { diff --git a/src/base/abc/abcBlifMv.c b/src/base/abc/abcBlifMv.c index 3d6730e7..d4bbebf0 100644 --- a/src/base/abc/abcBlifMv.c +++ b/src/base/abc/abcBlifMv.c @@ -145,7 +145,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ) assert( Abc_ObjIsNode(pObj) ); pNet = Abc_ObjFanout0(pObj); nValues = Abc_ObjMvVarNum(pNet); - pValues = ALLOC( Abc_Obj_t *, nValues ); + pValues = ABC_ALLOC( Abc_Obj_t *, nValues ); for ( k = 0; k < nValues; k++ ) pValues[k] = Abc_ObjNot( Abc_AigConst1(pNtkNew) ); @@ -170,7 +170,7 @@ int Abc_NodeStrashBlifMv( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj ) Index = Abc_StringGetNumber( &pSop ); assert( Index < nValues ); //////////////////////////////////////////// - // adding free variables for binary ND-constants + // adding ABC_FREE variables for binary ND-constants if ( fAddFreeVars && nValues == 2 && *pSop == '-' ) { pValues[1] = Abc_NtkCreatePi(pNtkNew); @@ -396,7 +396,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk ) nValuesMax = nValues; } nBits = Extra_Base2Log( nValuesMax ); - pBits = ALLOC( Abc_Obj_t *, nBits ); + pBits = ABC_ALLOC( Abc_Obj_t *, nBits ); // clean the node copy fields Abc_NtkCleanCopy( pNtk ); @@ -420,7 +420,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk ) continue; pNet = Abc_ObjFanout0(pObj); nValues = Abc_ObjMvVarNum(pNet); - pValues = ALLOC( Abc_Obj_t *, nValues ); + pValues = ABC_ALLOC( Abc_Obj_t *, nValues ); // create PIs for the values for ( v = 0; v < nValues; v++ ) { @@ -441,7 +441,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk ) continue; pNet = Abc_ObjFanout0(pObj); nValues = Abc_ObjMvVarNum(pNet); - pValues = ALLOC( Abc_Obj_t *, nValues ); + pValues = ABC_ALLOC( Abc_Obj_t *, nValues ); // create PIs for the values for ( v = 0; v < nValues; v++ ) { @@ -466,7 +466,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk ) continue; pNet = Abc_ObjFanout0(pObj); nValues = Abc_ObjMvVarNum(pNet); - pValues = ALLOC( Abc_Obj_t *, nValues ); + pValues = ABC_ALLOC( Abc_Obj_t *, nValues ); // create PIs for the encoding bits nBits = Extra_Base2Log( nValues ); for ( k = 0; k < nBits; k++ ) @@ -498,7 +498,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk ) continue; pNet = Abc_ObjFanout0(pObj); nValues = Abc_ObjMvVarNum(pNet); - pValues = ALLOC( Abc_Obj_t *, nValues ); + pValues = ABC_ALLOC( Abc_Obj_t *, nValues ); // create PIs for the encoding bits nBits = Extra_Base2Log( nValues ); for ( k = 0; k < nBits; k++ ) @@ -645,7 +645,7 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk ) Vec_Ptr_t * vTemp; Abc_Obj_t * pLatch, * pObjLi, * pObjLo; int i; - // move free vars to the front among the PIs + // move ABC_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 +656,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 free vars to the front among the CIs + // move ABC_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 ) @@ -684,10 +684,10 @@ Abc_Ntk_t * Abc_NtkStrashBlifMv( Abc_Ntk_t * pNtk ) } // cleanup - free( pBits ); + ABC_FREE( pBits ); Abc_NtkForEachObj( pNtk, pObj, i ) if ( pObj->pCopy ) - free( pObj->pCopy ); + ABC_FREE( pObj->pCopy ); // remove dangling nodes i = Abc_AigCleanup(pNtkNew->pManFunc); @@ -1028,7 +1028,7 @@ char * Abc_NodeConvertSopToMvSop( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop if ( Vec_IntSize(vSop0) == 0 || Vec_IntSize(vSop1) == 0 ) { // (temporary) create a tautology cube - pMvSop = ALLOC( char, nVars + 3 ); + pMvSop = ABC_ALLOC( char, nVars + 3 ); for ( k = 0; k < nVars; k++ ) pMvSop[k] = '-'; pMvSop[nVars] = '0' + (int)(Vec_IntSize(vSop1) > 0); @@ -1043,7 +1043,7 @@ char * Abc_NodeConvertSopToMvSop( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop // and the string is zero-terminated) nSize = nCubes * (nVars + 2) + 1; // allocate memory - pMvSop = pCur = ALLOC( char, nSize ); + pMvSop = pCur = ABC_ALLOC( char, nSize ); // fill in the negative polarity cubes Vec_IntForEachEntry( vSop0, uCube, i ) { @@ -1132,7 +1132,7 @@ int Abc_NodeEvalMvCost( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop1 ) int * pVarValues; int i, RetValue; // collect the input and output values (currently, they are binary) - pVarValues = ALLOC( int, nVars + 1 ); + pVarValues = ABC_ALLOC( int, nVars + 1 ); for ( i = 0; i <= nVars; i++ ) pVarValues[i] = 2; // prepare MV-SOP for evaluation @@ -1142,8 +1142,8 @@ int Abc_NodeEvalMvCost( int nVars, Vec_Int_t * vSop0, Vec_Int_t * vSop1 ) // get the result of internal cost evaluation RetValue = Abc_NodeEvalMvCostInternal( nVars, pVarValues, pMvSop ); // cleanup - free( pVarValues ); - free( pMvSop ); + ABC_FREE( pVarValues ); + ABC_FREE( pMvSop ); return RetValue; } diff --git a/src/base/abc/abcCheck.c b/src/base/abc/abcCheck.c index e538bd64..a43cc9eb 100644 --- a/src/base/abc/abcCheck.c +++ b/src/base/abc/abcCheck.c @@ -191,7 +191,7 @@ bool Abc_NtkDoCheck( Abc_Ntk_t * pNtk ) fprintf( stdout, "NetworkCheck: Network contains a combinational loop.\n" ); return 0; } -// PRT( "Acyclic ", clock() - clk ); +// ABC_PRT( "Acyclic ", clock() - clk ); // check the EXDC network if present if ( pNtk->pExdc ) @@ -573,10 +573,10 @@ bool Abc_NtkCheckLatch( Abc_Ntk_t * pNtk, Abc_Obj_t * pLatch ) Value = 0; } // make sure the latch has a reasonable return value - if ( (int)(PORT_PTRINT_T)pLatch->pData < ABC_INIT_ZERO || (int)(PORT_PTRINT_T)pLatch->pData > ABC_INIT_DC ) + if ( (int)(ABC_PTRINT_T)pLatch->pData < ABC_INIT_ZERO || (int)(ABC_PTRINT_T)pLatch->pData > ABC_INIT_DC ) { fprintf( stdout, "NodeCheck: Latch \"%s\" has incorrect reset value (%d).\n", - Abc_ObjName(pLatch), (int)(PORT_PTRINT_T)pLatch->pData ); + Abc_ObjName(pLatch), (int)(ABC_PTRINT_T)pLatch->pData ); Value = 0; } // make sure the latch has only one fanin diff --git a/src/base/abc/abcDfs.c b/src/base/abc/abcDfs.c index fec01ef7..50ebef6d 100644 --- a/src/base/abc/abcDfs.c +++ b/src/base/abc/abcDfs.c @@ -493,7 +493,7 @@ void Abc_NtkDfs_iter( Vec_Ptr_t * vStack, Abc_Obj_t * pRoot, Vec_Ptr_t * vNodes while ( Vec_PtrSize(vStack) > 0 ) { // get the node and its fanin - iFanin = (int)(PORT_PTRINT_T)Vec_PtrPop(vStack); + iFanin = (int)(ABC_PTRINT_T)Vec_PtrPop(vStack); pNode = Vec_PtrPop(vStack); assert( !Abc_ObjIsNet(pNode) ); // add it to the array of nodes if we finished @@ -504,7 +504,7 @@ void Abc_NtkDfs_iter( Vec_Ptr_t * vStack, Abc_Obj_t * pRoot, Vec_Ptr_t * vNodes } // explore the next fanin Vec_PtrPush( vStack, pNode ); - Vec_PtrPush( vStack, (void *)(PORT_PTRINT_T)(iFanin+1) ); + Vec_PtrPush( vStack, (void *)(ABC_PTRINT_T)(iFanin+1) ); // get the fanin pFanin = Abc_ObjFanin0Ntk( Abc_ObjFanin(pNode,iFanin) ); // if this node is already visited, skip @@ -1239,7 +1239,7 @@ int Abc_NodeSetChoiceLevel_rec( Abc_Obj_t * pNode, int fMaximum ) int Level1, Level2, Level, LevelE; // skip the visited node if ( Abc_NodeIsTravIdCurrent( pNode ) ) - return (int)(PORT_PTRINT_T)pNode->pCopy; + return (int)(ABC_PTRINT_T)pNode->pCopy; Abc_NodeSetTravIdCurrent( pNode ); // compute levels of the children nodes Level1 = Abc_NodeSetChoiceLevel_rec( Abc_ObjFanin0(pNode), fMaximum ); @@ -1254,9 +1254,9 @@ int Abc_NodeSetChoiceLevel_rec( Abc_Obj_t * pNode, int fMaximum ) 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 *)(PORT_PTRINT_T)Level; + pTemp->pCopy = (void *)(ABC_PTRINT_T)Level; } - pNode->pCopy = (void *)(PORT_PTRINT_T)Level; + pNode->pCopy = (void *)(ABC_PTRINT_T)Level; return Level; } @@ -1325,7 +1325,7 @@ Vec_Ptr_t * Abc_AigGetLevelizedOrder( Abc_Ntk_t * pNtk, int fCollectCis ) vLevels = Vec_PtrStart( LevelMax + 1 ); Abc_NtkForEachNode( pNtk, pNode, i ) { - ppHead = ((Abc_Obj_t **)vLevels->pArray) + (int)(PORT_PTRINT_T)pNode->pCopy; + ppHead = ((Abc_Obj_t **)vLevels->pArray) + (int)(ABC_PTRINT_T)pNode->pCopy; pNode->pCopy = *ppHead; *ppHead = pNode; } @@ -1338,6 +1338,51 @@ Vec_Ptr_t * Abc_AigGetLevelizedOrder( Abc_Ntk_t * pNtk, int fCollectCis ) return vNodes; } +/**Function************************************************************* + + Synopsis [Count the number of nodes in the subgraph.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_ObjSugraphSize( Abc_Obj_t * pObj ) +{ + if ( Abc_ObjIsCi(pObj) ) + return 0; + if ( Abc_ObjFanoutNum(pObj) > 1 ) + return 0; + return 1 + Abc_ObjSugraphSize(Abc_ObjFanin0(pObj)) + + Abc_ObjSugraphSize(Abc_ObjFanin1(pObj)); +} + +/**Function************************************************************* + + Synopsis [Prints subgraphs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_NtkPrintSubraphSizes( Abc_Ntk_t * pNtk ) +{ + Abc_Obj_t * pObj; + int i; + assert( Abc_NtkIsStrash(pNtk) ); + Abc_NtkForEachNode( pNtk, pObj, i ) + if ( Abc_ObjFanoutNum(pObj) > 1 && !Abc_NodeIsExorType(pObj) ) + printf( "%d(%d) ", 1 + Abc_ObjSugraphSize(Abc_ObjFanin0(pObj)) + + Abc_ObjSugraphSize(Abc_ObjFanin1(pObj)), Abc_ObjFanoutNum(pObj) ); + printf( "\n" ); + return 1; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/abc/abcFanio.c b/src/base/abc/abcFanio.c index 14b2b0c1..fb8dcaae 100644 --- a/src/base/abc/abcFanio.c +++ b/src/base/abc/abcFanio.c @@ -51,7 +51,7 @@ static inline void Vec_IntPushMem( Extra_MmStep_t * pMemMan, Vec_Int_t * p, int if ( pMemMan ) pArray = (int *)Extra_MmStepEntryFetch( pMemMan, p->nCap * 8 ); else - pArray = ALLOC( int, p->nCap * 2 ); + pArray = ABC_ALLOC( int, p->nCap * 2 ); if ( p->pArray ) { for ( i = 0; i < p->nSize; i++ ) @@ -59,7 +59,7 @@ static inline void Vec_IntPushMem( Extra_MmStep_t * pMemMan, Vec_Int_t * p, int if ( pMemMan ) Extra_MmStepEntryRecycle( pMemMan, (char *)p->pArray, p->nCap * 4 ); else - free( p->pArray ); + ABC_FREE( p->pArray ); } p->nCap *= 2; p->pArray = pArray; @@ -90,7 +90,7 @@ void Abc_ObjAddFanin( Abc_Obj_t * pObj, Abc_Obj_t * pFanin ) Abc_ObjSetFaninC( pObj, Abc_ObjFaninNum(pObj)-1 ); if ( Abc_ObjIsNet(pObj) && Abc_ObjFaninNum(pObj) > 1 ) { - printf( "Abc_ObjAddFanin(): Error! Creating net with two fanins.\n" ); + printf( "Abc_ObjAddFanin(): Error! Creating net \"%s\" with two fanins.\n", Abc_ObjName(pObj) ); } } diff --git a/src/base/abc/abcFunc.c b/src/base/abc/abcFunc.c index e99cc88b..758bc1e2 100644 --- a/src/base/abc/abcFunc.c +++ b/src/base/abc/abcFunc.c @@ -290,7 +290,7 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun if ( pMan ) pSop = Extra_MmFlexEntryFetch( pMan, nFanins + 4 ); else - pSop = ALLOC( char, nFanins + 4 ); + pSop = ABC_ALLOC( char, nFanins + 4 ); if ( bFuncOn == Cudd_ReadOne(dd) ) sprintf( pSop, "%s %d\n", vCube->pArray, fMode ); else @@ -385,7 +385,7 @@ char * Abc_ConvertBddToSop( Extra_MmFlex_t * pMan, DdManager * dd, DdNode * bFun if ( pMan ) pSop = Extra_MmFlexEntryFetch( pMan, (nFanins + 3) * nCubes + 1 ); else - pSop = ALLOC( char, (nFanins + 3) * nCubes + 1 ); + pSop = ABC_ALLOC( char, (nFanins + 3) * nCubes + 1 ); pSop[(nFanins + 3) * nCubes] = 0; // create the SOP Vec_StrFill( vCube, nFanins, '-' ); diff --git a/src/base/abc/abcLatch.c b/src/base/abc/abcLatch.c index 79b60cf9..aef44b11 100644 --- a/src/base/abc/abcLatch.c +++ b/src/base/abc/abcLatch.c @@ -208,7 +208,7 @@ void Abc_NtkInsertLatchValues( Abc_Ntk_t * pNtk, Vec_Int_t * vValues ) Abc_Obj_t * pLatch; int i; Abc_NtkForEachLatch( pNtk, pLatch, i ) - pLatch->pData = (void *)(PORT_PTRINT_T)(vValues? (Vec_IntEntry(vValues,i)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC); + pLatch->pData = (void *)(ABC_PTRINT_T)(vValues? (Vec_IntEntry(vValues,i)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC); } /**Function************************************************************* @@ -340,7 +340,7 @@ Vec_Ptr_t * Abc_NtkConverLatchNamesIntoNumbers( Abc_Ntk_t * pNtk ) return NULL; // set register numbers Abc_NtkForEachLatch( pNtk, pObj, i ) - pObj->pNext = (Abc_Obj_t *)(PORT_PTRINT_T)i; + 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 ) @@ -354,7 +354,7 @@ Vec_Ptr_t * Abc_NtkConverLatchNamesIntoNumbers( Abc_Ntk_t * pNtk ) pObj = Abc_NtkObj( pNtk, Num ); if ( Abc_ObjFaninNum(pObj) != 1 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) ) continue; - Vec_IntPush( vNumbers, (int)(PORT_PTRINT_T)pObj->pNext ); + Vec_IntPush( vNumbers, (int)(ABC_PTRINT_T)pObj->pNext ); } if ( Vec_IntSize( vNumbers ) > 1 ) { diff --git a/src/base/abc/abcLib.c b/src/base/abc/abcLib.c index feff1478..850e59e0 100644 --- a/src/base/abc/abcLib.c +++ b/src/base/abc/abcLib.c @@ -42,7 +42,7 @@ Abc_Lib_t * Abc_LibCreate( char * pName ) { Abc_Lib_t * p; - p = ALLOC( Abc_Lib_t, 1 ); + p = ABC_ALLOC( Abc_Lib_t, 1 ); memset( p, 0, sizeof(Abc_Lib_t) ); p->pName = Extra_UtilStrsav( pName ); p->tModules = st_init_table( strcmp, st_strhash ); @@ -69,7 +69,7 @@ void Abc_LibFree( Abc_Lib_t * pLib, Abc_Ntk_t * pNtkSave ) Abc_Ntk_t * pNtk; int i; if ( pLib->pName ) - free( pLib->pName ); + ABC_FREE( pLib->pName ); if ( pLib->pManFunc ) Hop_ManStop( pLib->pManFunc ); if ( pLib->tModules ) @@ -88,7 +88,7 @@ void Abc_LibFree( Abc_Lib_t * pLib, Abc_Ntk_t * pNtkSave ) } if ( pLib->vTops ) Vec_PtrFree( pLib->vTops ); - free( pLib ); + ABC_FREE( pLib ); } /**Function************************************************************* diff --git a/src/base/abc/abcMinBase.c b/src/base/abc/abcMinBase.c index e1c0f4fd..5186c920 100644 --- a/src/base/abc/abcMinBase.c +++ b/src/base/abc/abcMinBase.c @@ -100,7 +100,7 @@ int Abc_NodeMinimumBase( Abc_Obj_t * pNode ) /**Function************************************************************* - Synopsis [Makes nodes of the network fanin-dup-free.] + Synopsis [Makes nodes of the network fanin-dup-ABC_FREE.] Description [Returns the number of pairs of duplicated fanins.] @@ -467,8 +467,8 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose // get the nodes in the given order vNodes = fReverse? Abc_NtkDfsReverse( pNtk ) : Abc_NtkDfs( pNtk, 0 ); // go through the nodes and decide is they can be eliminated - pPermFanin = ALLOC( int, nMaxSize + 100 ); - pPermFanout = ALLOC( int, nMaxSize + 100 ); + pPermFanin = ABC_ALLOC( int, nMaxSize + 100 ); + pPermFanout = ABC_ALLOC( int, nMaxSize + 100 ); vFanins = Vec_PtrAlloc( 100 ); vFanouts = Vec_PtrAlloc( 100 ); Vec_PtrForEachEntry( vNodes, pNode, i ) @@ -494,8 +494,8 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose Vec_PtrFree( vFanins ); Vec_PtrFree( vFanouts ); Vec_PtrFree( vNodes ); - free( pPermFanin ); - free( pPermFanout ); + ABC_FREE( pPermFanin ); + ABC_FREE( pPermFanout ); return 1; } diff --git a/src/base/abc/abcNames.c b/src/base/abc/abcNames.c index 91964dfa..90fcd191 100644 --- a/src/base/abc/abcNames.c +++ b/src/base/abc/abcNames.c @@ -241,7 +241,7 @@ void Abc_NodeFreeNames( Vec_Ptr_t * vNames ) if ( vNames == NULL ) return; for ( i = 0; i < vNames->nSize; i++ ) - free( vNames->pArray[i] ); + ABC_FREE( vNames->pArray[i] ); Vec_PtrFree( vNames ); } @@ -263,13 +263,13 @@ char ** Abc_NtkCollectCioNames( Abc_Ntk_t * pNtk, int fCollectCos ) int i; if ( fCollectCos ) { - ppNames = ALLOC( char *, Abc_NtkCoNum(pNtk) ); + ppNames = ABC_ALLOC( char *, Abc_NtkCoNum(pNtk) ); Abc_NtkForEachCo( pNtk, pObj, i ) ppNames[i] = Abc_ObjName(pObj); } else { - ppNames = ALLOC( char *, Abc_NtkCiNum(pNtk) ); + ppNames = ABC_ALLOC( char *, Abc_NtkCiNum(pNtk) ); Abc_NtkForEachCi( pNtk, pObj, i ) ppNames[i] = Abc_ObjName(pObj); } diff --git a/src/base/abc/abcNtk.c b/src/base/abc/abcNtk.c index 88bcda69..639319d1 100644 --- a/src/base/abc/abcNtk.c +++ b/src/base/abc/abcNtk.c @@ -45,7 +45,7 @@ Abc_Ntk_t * Abc_NtkAlloc( Abc_NtkType_t Type, Abc_NtkFunc_t Func, int fUseMemMan ) { Abc_Ntk_t * pNtk; - pNtk = ALLOC( Abc_Ntk_t, 1 ); + pNtk = ABC_ALLOC( Abc_Ntk_t, 1 ); memset( pNtk, 0, sizeof(Abc_Ntk_t) ); pNtk->ntkType = Type; pNtk->ntkFunc = Func; @@ -230,7 +230,7 @@ Abc_Ntk_t * Abc_NtkStartRead( char * pName ) pNtkNew->pSpec = Extra_UtilStrsav(pName); if ( pNtkNew->pName == NULL || strlen(pNtkNew->pName) == 0 ) { - FREE( pNtkNew->pName ); + ABC_FREE( pNtkNew->pName ); pNtkNew->pName = Extra_UtilStrsav("unknown"); } return pNtkNew; @@ -935,10 +935,10 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) // int LargePiece = (4 << ABC_NUM_STEPS); if ( pNtk == NULL ) return; - // free the HAIG - if ( pNtk->pHaig ) - Abc_NtkHaigStop( pNtk ); - // free EXDC Ntk + // ABC_FREE the HAIG +// if ( pNtk->pHaig ) +// Abc_NtkHaigStop( pNtk ); + // ABC_FREE EXDC Ntk if ( pNtk->pExdc ) Abc_NtkDelete( pNtk->pExdc ); if ( pNtk->pExcare ) @@ -952,31 +952,31 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) // make sure all the marks are clean Abc_NtkForEachObj( pNtk, pObj, i ) { - // free large fanout arrays + // ABC_FREE large fanout arrays // if ( pNtk->pMmObj && pObj->vFanouts.nCap * 4 > LargePiece ) -// FREE( pObj->vFanouts.pArray ); +// ABC_FREE( pObj->vFanouts.pArray ); // these flags should be always zero // if this is not true, something is wrong somewhere assert( pObj->fMarkA == 0 ); assert( pObj->fMarkB == 0 ); assert( pObj->fMarkC == 0 ); } - // free the nodes + // ABC_FREE the nodes if ( pNtk->pMmStep == NULL ) { Abc_NtkForEachObj( pNtk, pObj, i ) { - FREE( pObj->vFanouts.pArray ); - FREE( pObj->vFanins.pArray ); + ABC_FREE( pObj->vFanouts.pArray ); + ABC_FREE( pObj->vFanins.pArray ); } } if ( pNtk->pMmObj == NULL ) { Abc_NtkForEachObj( pNtk, pObj, i ) - free( pObj ); + ABC_FREE( pObj ); } - // free the arrays + // ABC_FREE the arrays Vec_PtrFree( pNtk->vPios ); Vec_PtrFree( pNtk->vPis ); Vec_PtrFree( pNtk->vPos ); @@ -986,20 +986,20 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) Vec_PtrFree( pNtk->vObjs ); Vec_PtrFree( pNtk->vBoxes ); if ( pNtk->vLevelsR ) Vec_IntFree( pNtk->vLevelsR ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); TotalMemory = 0; TotalMemory += pNtk->pMmObj? Extra_MmFixedReadMemUsage(pNtk->pMmObj) : 0; TotalMemory += pNtk->pMmStep? Extra_MmStepReadMemUsage(pNtk->pMmStep) : 0; // fprintf( stdout, "The total memory allocated internally by the network = %0.2f Mb.\n", ((double)TotalMemory)/(1<<20) ); - // free the storage + // ABC_FREE the storage if ( pNtk->pMmObj ) Extra_MmFixedStop( pNtk->pMmObj ); if ( pNtk->pMmStep ) Extra_MmStepStop ( pNtk->pMmStep ); // name manager Nm_ManFree( pNtk->pManName ); - // free the timing manager + // ABC_FREE the timing manager if ( pNtk->pManTime ) Abc_ManTimeStop( pNtk->pManTime ); // start the functionality manager @@ -1015,7 +1015,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) pNtk->pManFunc = NULL; else if ( !Abc_NtkHasBlackbox(pNtk) ) assert( 0 ); - // free the hierarchy + // ABC_FREE the hierarchy if ( pNtk->pDesign ) { Abc_LibFree( pNtk->pDesign, pNtk ); @@ -1023,7 +1023,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) } // if ( pNtk->pBlackBoxes ) // Vec_IntFree( pNtk->pBlackBoxes ); - // free node attributes + // ABC_FREE node attributes Vec_PtrForEachEntry( pNtk->vAttrs, pAttrMan, i ) if ( pAttrMan ) { @@ -1031,12 +1031,12 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk ) Vec_AttFree( pAttrMan, 1 ); } Vec_PtrFree( pNtk->vAttrs ); - FREE( pNtk->pName ); - FREE( pNtk->pSpec ); - FREE( pNtk->pLutTimes ); + ABC_FREE( pNtk->pName ); + ABC_FREE( pNtk->pSpec ); + ABC_FREE( pNtk->pLutTimes ); if ( pNtk->vOnehots ) Vec_VecFree( (Vec_Vec_t *)pNtk->vOnehots ); - free( pNtk ); + ABC_FREE( pNtk ); } /**Function************************************************************* diff --git a/src/base/abc/abcObj.c b/src/base/abc/abcObj.c index a79eb5a7..4b18aa36 100644 --- a/src/base/abc/abcObj.c +++ b/src/base/abc/abcObj.c @@ -48,7 +48,7 @@ Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type ) if ( pNtk->pMmObj ) pObj = (Abc_Obj_t *)Extra_MmFixedEntryFetch( pNtk->pMmObj ); else - pObj = (Abc_Obj_t *)ALLOC( Abc_Obj_t, 1 ); + pObj = (Abc_Obj_t *)ABC_ALLOC( Abc_Obj_t, 1 ); memset( pObj, 0, sizeof(Abc_Obj_t) ); pObj->pNtk = pNtk; pObj->Type = Type; @@ -71,13 +71,13 @@ void Abc_ObjRecycle( Abc_Obj_t * pObj ) { Abc_Ntk_t * pNtk = pObj->pNtk; // int LargePiece = (4 << ABC_NUM_STEPS); - // free large fanout arrays + // ABC_FREE large fanout arrays // if ( pNtk->pMmStep && pObj->vFanouts.nCap * 4 > LargePiece ) -// FREE( pObj->vFanouts.pArray ); +// ABC_FREE( pObj->vFanouts.pArray ); if ( pNtk->pMmStep == NULL ) { - FREE( pObj->vFanouts.pArray ); - FREE( pObj->vFanins.pArray ); + ABC_FREE( pObj->vFanouts.pArray ); + ABC_FREE( pObj->vFanins.pArray ); } // clean the memory to make deleted object distinct from the live one memset( pObj, 0, sizeof(Abc_Obj_t) ); @@ -85,7 +85,7 @@ void Abc_ObjRecycle( Abc_Obj_t * pObj ) if ( pNtk->pMmObj ) Extra_MmFixedEntryRecycle( pNtk->pMmObj, (char *)pObj ); else - free( pObj ); + ABC_FREE( pObj ); } /**Function************************************************************* diff --git a/src/base/abc/abcRefs.c b/src/base/abc/abcRefs.c index 604c5ffa..fadb492a 100644 --- a/src/base/abc/abcRefs.c +++ b/src/base/abc/abcRefs.c @@ -178,18 +178,18 @@ int Abc_NodeRefDerefStop( Abc_Obj_t * pNode, bool fReference ) Counter = 1; if ( fReference ) { - if ( pNode0->vFanouts.nSize++ == 0 && !Abc_ObjFaninC0(pNode) ) + if ( !Abc_ObjFaninC0(pNode) && pNode0->vFanouts.nSize++ == 0 ) Counter += Abc_NodeRefDerefStop( pNode0, fReference ); - if ( pNode1->vFanouts.nSize++ == 0 && !Abc_ObjFaninC1(pNode) ) + if ( !Abc_ObjFaninC1(pNode) && pNode1->vFanouts.nSize++ == 0 ) Counter += Abc_NodeRefDerefStop( pNode1, fReference ); } else { assert( pNode0->vFanouts.nSize > 0 ); assert( pNode1->vFanouts.nSize > 0 ); - if ( --pNode0->vFanouts.nSize == 0 && !Abc_ObjFaninC0(pNode) ) + if ( !Abc_ObjFaninC0(pNode) && --pNode0->vFanouts.nSize == 0 ) Counter += Abc_NodeRefDerefStop( pNode0, fReference ); - if ( --pNode1->vFanouts.nSize == 0 && !Abc_ObjFaninC1(pNode) ) + if ( !Abc_ObjFaninC1(pNode) && --pNode1->vFanouts.nSize == 0 ) Counter += Abc_NodeRefDerefStop( pNode1, fReference ); } return Counter; diff --git a/src/base/abc/abcShow.c b/src/base/abc/abcShow.c index 2b406e81..359f737e 100644 --- a/src/base/abc/abcShow.c +++ b/src/base/abc/abcShow.c @@ -241,7 +241,7 @@ void Abc_ShowFile( char * FileNameDot ) // create the PostScript file name FileGeneric = Extra_FileNameGeneric( FileNameDot ); sprintf( FileNamePs, "%s.ps", FileGeneric ); - free( FileGeneric ); + ABC_FREE( FileGeneric ); // generate the PostScript file using DOT sprintf( CommandDot, "%s -Tps -o %s %s", pDotName, FileNamePs, FileNameDot ); diff --git a/src/base/abc/abcSop.c b/src/base/abc/abcSop.c index d1d1a468..c0ace492 100644 --- a/src/base/abc/abcSop.c +++ b/src/base/abc/abcSop.c @@ -804,7 +804,7 @@ bool Abc_SopCheck( char * pSop, int nFanins ) if ( pCubes - pCubesOld != nFanins ) { fprintf( stdout, "Abc_SopCheck: SOP has a mismatch between its cover size (%d) and its fanin number (%d).\n", - (int)(PORT_PTRDIFF_T)(pCubes - pCubesOld), nFanins ); + (int)(ABC_PTRDIFF_T)(pCubes - pCubesOld), nFanins ); return 0; } // check the output values for this cube @@ -884,7 +884,7 @@ char * Abc_SopFromTruthBin( char * pTruth ) // create the SOP representation of the minterms Length = Vec_IntSize(vMints) * (nVars + 3); - pSopCover = ALLOC( char, Length + 1 ); + pSopCover = ABC_ALLOC( char, Length + 1 ); pSopCover[Length] = 0; Vec_IntForEachEntry( vMints, Mint, i ) { @@ -951,7 +951,7 @@ char * Abc_SopFromTruthHex( char * pTruth ) // create the SOP representation of the minterms Length = Vec_IntSize(vMints) * (nVars + 3); - pSopCover = ALLOC( char, Length + 1 ); + pSopCover = ABC_ALLOC( char, Length + 1 ); pSopCover[Length] = 0; Vec_IntForEachEntry( vMints, Mint, i ) { diff --git a/src/base/abc/abcUtil.c b/src/base/abc/abcUtil.c index 90cf50b0..cdb9b465 100644 --- a/src/base/abc/abcUtil.c +++ b/src/base/abc/abcUtil.c @@ -226,6 +226,28 @@ int Abc_NtkGetLitFactNum( Abc_Ntk_t * pNtk ) return nNodes; } +/**Function************************************************************* + + Synopsis [Counts the number of nodes with more than 1 reference.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_NtkGetMultiRefNum( Abc_Ntk_t * pNtk ) +{ + Abc_Obj_t * pNode; + int nNodes, i; + assert( Abc_NtkIsStrash(pNtk) ); + nNodes = 0; + Abc_NtkForEachNode( pNtk, pNode, i ) + nNodes += (int)(Abc_ObjFanoutNum(pNode) > 1); + return nNodes; +} + /**Function************************************************************* Synopsis [Reads the number of BDD nodes.] @@ -510,7 +532,9 @@ void Abc_NtkCleanEquiv( Abc_Ntk_t * pNtk ) Abc_Obj_t * pObj; int i; Abc_NtkForEachObj( pNtk, pObj, i ) - pObj->pEquiv = NULL; + { +// pObj->pEquiv = NULL; + } } /**Function************************************************************* @@ -1557,9 +1581,9 @@ void Abc_NtkTransferCopy( Abc_Ntk_t * pNtk ) static inline int Abc_ObjCrossCutInc( Abc_Obj_t * pObj ) { // pObj->pCopy = (void *)(((int)pObj->pCopy)++); - int Value = (int)(PORT_PTRINT_T)pObj->pCopy; - pObj->pCopy = (void *)(PORT_PTRINT_T)(Value + 1); - return (int)(PORT_PTRINT_T)pObj->pCopy == Abc_ObjFanoutNum(pObj); + int Value = (int)(ABC_PTRINT_T)pObj->pCopy; + pObj->pCopy = (void *)(ABC_PTRINT_T)(Value + 1); + return (int)(ABC_PTRINT_T)pObj->pCopy == Abc_ObjFanoutNum(pObj); } /**Function************************************************************* @@ -1705,8 +1729,8 @@ void Abc_NtkCompareCones( Abc_Ntk_t * pNtk ) int * pPerms; // sort COs by support size - pPerms = ALLOC( int, Abc_NtkCoNum(pNtk) ); - pSupps = ALLOC( int, Abc_NtkCoNum(pNtk) ); + pPerms = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) ); + pSupps = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) ); Abc_NtkForEachCo( pNtk, pObj, i ) { pPerms[i] = i; @@ -1746,7 +1770,7 @@ void Abc_NtkCompareCones( Abc_Ntk_t * pNtk ) printf( "%4d CO %5d : Supp = %5d. Lev = %3d. Cone = %5d. Rev = %5d. COs = %3d (%3d).\n", Iter, pPerms[i], Vec_PtrSize(vSupp), Abc_ObjLevel(Abc_ObjFanin0(pObj)), Vec_PtrSize(vNodes), Counter, CounterCos, CounterCosNew ); - // free arrays + // ABC_FREE arrays Vec_PtrFree( vSupp ); Vec_PtrFree( vNodes ); Vec_PtrFree( vReverse ); @@ -1757,8 +1781,8 @@ void Abc_NtkCompareCones( Abc_Ntk_t * pNtk ) Abc_NtkForEachCo( pNtk, pObj, i ) pObj->fMarkA = 0; - free( pPerms ); - free( pSupps ); + ABC_FREE( pPerms ); + ABC_FREE( pSupps ); } /**Function************************************************************* diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7aad2eb2..b6a21b5f 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -1,5 +1,5 @@ /**CFile**************************************************************** - + FileName [abc.c] SystemName [ABC: Logic synthesis and verification system.] @@ -39,6 +39,7 @@ #include "ssw.h" #include "cgt.h" #include "amap.h" +#include "gia.h" #include "cec.h" //////////////////////////////////////////////////////////////////////// @@ -63,6 +64,7 @@ static int Abc_CommandPrintSharing ( Abc_Frame_t * pAbc, int argc, char ** arg static int Abc_CommandPrintXCut ( Abc_Frame_t * pAbc, int argc, char ** argv ); 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_CommandShow ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandShowBdd ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -149,12 +151,13 @@ static int Abc_CommandIResyn ( Abc_Frame_t * pAbc, int argc, char ** arg static int Abc_CommandISat ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIFraig ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandDFraig ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandNFraig ( 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_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 ); -static int Abc_CommandHaig ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandHaig ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandMini ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandQbf ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -170,11 +173,11 @@ static int Abc_CommandFraigDress ( Abc_Frame_t * pAbc, int argc, char ** arg //static int Abc_CommandHaigStop ( Abc_Frame_t * pAbc, int argc, char ** argv ); //static int Abc_CommandHaigUse ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandRecStart ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandRecStop ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandRecAdd ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandRecPs ( Abc_Frame_t * pAbc, int argc, char ** argv ); -static int Abc_CommandRecUse ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandRecStart ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandRecStop ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandRecAdd ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandRecPs ( Abc_Frame_t * pAbc, int argc, char ** argv ); +//static int Abc_CommandRecUse ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandMap ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAmap ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -270,6 +273,27 @@ static int Abc_CommandAbc8Zero ( Abc_Frame_t * pAbc, int argc, char ** arg 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 ); +static int Abc_CommandAbc9Write ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Ps ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9PFan ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Status ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Show ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Hash ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Topand ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Cof ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Trim ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Dfs ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Sim ( 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_CommandAbc9Scl ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Sat ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Fraig ( 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 ); //////////////////////////////////////////////////////////////////////// @@ -347,6 +371,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "Printing", "print_xcut", Abc_CommandPrintXCut, 0 ); 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", "show", Abc_CommandShow, 0 ); Cmd_CommandAdd( pAbc, "Printing", "show_bdd", Abc_CommandShowBdd, 0 ); @@ -433,8 +458,9 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "New AIG", "isat", Abc_CommandISat, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "ifraig", Abc_CommandIFraig, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "dfraig", Abc_CommandDFraig, 1 ); + Cmd_CommandAdd( pAbc, "New AIG", "nfraig", Abc_CommandNFraig, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "csweep", Abc_CommandCSweep, 1 ); - Cmd_CommandAdd( pAbc, "New AIG", "haig", Abc_CommandHaig, 1 ); +// Cmd_CommandAdd( pAbc, "New AIG", "haig", Abc_CommandHaig, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "mini", Abc_CommandMini, 1 ); Cmd_CommandAdd( pAbc, "New AIG", "qbf", Abc_CommandQbf, 0 ); @@ -450,11 +476,11 @@ void Abc_Init( Abc_Frame_t * pAbc ) // Cmd_CommandAdd( pAbc, "Choicing", "haig_stop", Abc_CommandHaigStop, 0 ); // Cmd_CommandAdd( pAbc, "Choicing", "haig_use", Abc_CommandHaigUse, 1 ); - Cmd_CommandAdd( pAbc, "Choicing", "rec_start", Abc_CommandRecStart, 0 ); - Cmd_CommandAdd( pAbc, "Choicing", "rec_stop", Abc_CommandRecStop, 0 ); - Cmd_CommandAdd( pAbc, "Choicing", "rec_add", Abc_CommandRecAdd, 0 ); - Cmd_CommandAdd( pAbc, "Choicing", "rec_ps", Abc_CommandRecPs, 0 ); - Cmd_CommandAdd( pAbc, "Choicing", "rec_use", Abc_CommandRecUse, 1 ); +// Cmd_CommandAdd( pAbc, "Choicing", "rec_start", Abc_CommandRecStart, 0 ); +// Cmd_CommandAdd( pAbc, "Choicing", "rec_stop", Abc_CommandRecStop, 0 ); +// Cmd_CommandAdd( pAbc, "Choicing", "rec_add", Abc_CommandRecAdd, 0 ); +// Cmd_CommandAdd( pAbc, "Choicing", "rec_ps", Abc_CommandRecPs, 0 ); +// Cmd_CommandAdd( pAbc, "Choicing", "rec_use", Abc_CommandRecUse, 1 ); Cmd_CommandAdd( pAbc, "SC mapping", "map", Abc_CommandMap, 1 ); Cmd_CommandAdd( pAbc, "SC mapping", "amap", Abc_CommandAmap, 1 ); @@ -547,7 +573,28 @@ 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", "&status", Abc_CommandAbc9Status, 0 ); + Cmd_CommandAdd( pAbc, "AIG", "&show", Abc_CommandAbc9Show, 0 ); + Cmd_CommandAdd( pAbc, "AIG", "&hash", 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", "×", Abc_CommandAbc9Times, 0 ); + Cmd_CommandAdd( pAbc, "AIG", "&frames", Abc_CommandAbc9Frames, 0 ); + Cmd_CommandAdd( pAbc, "AIG", "&scl", Abc_CommandAbc9Scl, 0 ); + Cmd_CommandAdd( pAbc, "AIG", "&sat", Abc_CommandAbc9Sat, 0 ); + Cmd_CommandAdd( pAbc, "AIG", "&fraig", Abc_CommandAbc9Fraig, 0 ); + Cmd_CommandAdd( pAbc, "AIG", "&test", Abc_CommandAbc9Test, 0 ); + Cmd_CommandAdd( pAbc, "Various", "testnew", Abc_CommandAbcTestNew, 0 ); // Cmd_CommandAdd( pAbc, "Verification", "trace_start", Abc_CommandTraceStart, 0 ); @@ -574,10 +621,14 @@ void Abc_Init( Abc_Frame_t * pAbc ) // extern void Aig_ManRandomTest1(); // Aig_ManRandomTest1(); } -// malloc(1001); { extern void Extra_MemTest(); -// Extra_MemTest(); +// Extra_MemTest(); + } + + { + extern void Gia_SortTest(); +// Gia_SortTest(); } } @@ -624,6 +675,8 @@ void Abc_End() Abc_NtkFraigStoreClean(); // Rwt_Man4ExplorePrint(); + if ( Abc_FrameGetGlobalFrame()->pAig ) + Gia_ManStop( Abc_FrameGetGlobalFrame()->pAig ); } /**Function************************************************************* @@ -648,6 +701,7 @@ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv ) int fPrintTime; int fPrintMuxes; int fPower; + int fGlitch; int c; pNtk = Abc_FrameReadNtk(pAbc); @@ -662,8 +716,9 @@ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv ) fPrintTime = 0; fPrintMuxes = 0; fPower = 0; + fGlitch = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "fbdltmph" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "fbdltmpgh" ) ) != EOF ) { switch ( c ) { @@ -688,6 +743,9 @@ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'p': fPower ^= 1; break; + case 'g': + fGlitch ^= 1; + break; case 'h': goto usage; default: @@ -705,7 +763,7 @@ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv ) fprintf( Abc_FrameReadErr(pAbc), "Cannot print LUT delay for a non-logic network.\n" ); return 1; } - Abc_NtkPrintStats( pOut, pNtk, fFactor, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower ); + Abc_NtkPrintStats( pOut, pNtk, fFactor, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch ); if ( fPrintTime ) { pAbc->TimeTotal += pAbc->TimeCommand; @@ -716,7 +774,7 @@ int Abc_CommandPrintStats( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - fprintf( pErr, "usage: print_stats [-fbdltmph]\n" ); + 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" ); @@ -725,6 +783,7 @@ usage: 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"); return 1; } @@ -810,7 +869,7 @@ int Abc_CommandPrintExdc( Abc_Frame_t * pAbc, int argc, char ** argv ) } else printf( "EXDC network statistics: \n" ); - Abc_NtkPrintStats( pOut, pNtk->pExdc, 0, 0, 0, 0, 0, 0 ); + Abc_NtkPrintStats( pOut, pNtk->pExdc, 0, 0, 0, 0, 0, 0, 0 ); return 0; usage: @@ -1303,7 +1362,7 @@ int Abc_CommandPrintSupport( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } vSuppFun = Sim_ComputeFunSupp( pNtk, fVerbose ); - free( vSuppFun->pArray[0] ); + ABC_FREE( vSuppFun->pArray[0] ); Vec_PtrFree( vSuppFun ); return 0; @@ -1987,6 +2046,66 @@ usage: } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandPrintMiter( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + FILE * pOut, * pErr; + Abc_Ntk_t * pNtk; + 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(); + while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF ) + { + switch ( c ) + { + case 'l': + fUseLibrary ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pNtk == NULL ) + { + fprintf( pErr, "Empty network.\n" ); + return 1; + } + if ( !Abc_NtkIsStrash(pNtk) ) + { + fprintf( pErr, "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"); + return 1; +} + /**Function************************************************************* Synopsis [] @@ -3080,7 +3199,7 @@ int Abc_CommandFastExtract( Abc_Frame_t * pAbc, int argc, char ** argv ) pErr = Abc_FrameReadErr(pAbc); // allocate the structure - p = ALLOC( Fxu_Data_t, 1 ); + p = ABC_ALLOC( Fxu_Data_t, 1 ); memset( p, 0, sizeof(Fxu_Data_t) ); // set the defaults p->nSingleMax = 20000; @@ -8039,6 +8158,7 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) // extern void Aig_ProcedureTest(); extern void Abc_NtkDarTest( Abc_Ntk_t * pNtk ); extern Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk ); + extern void Amap_LibertyTest( char * pFileName ); pNtk = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); @@ -8251,7 +8371,9 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); */ - Abc_NtkDarTest( pNtk ); +//Amap_LibertyTest( "bwrc.lib" ); + +// Abc_NtkDarTest( pNtk ); return 0; usage: @@ -8883,7 +9005,7 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv ) // set defaults Dar_ManDefaultRwrParams( pPars ); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "CNflzvwh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "CNflzrvwh" ) ) != EOF ) { switch ( c ) { @@ -8918,6 +9040,9 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'z': pPars->fUseZeros ^= 1; break; + case 'r': + pPars->fRecycle ^= 1; + break; case 'v': pPars->fVerbose ^= 1; break; @@ -8951,13 +9076,14 @@ int Abc_CommandDRewrite( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - fprintf( pErr, "usage: drw [-C num] [-N num] [-lfzvwh]\n" ); + 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"); @@ -9935,6 +10061,152 @@ usage: return 1; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandNFraig( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Cec_ParCsw_t Pars, * p = &Pars; + FILE * pOut, * pErr; + Abc_Ntk_t * pNtk, * pNtkRes; + int c; + extern Abc_Ntk_t * Abc_NtkDarSatSweep( Abc_Ntk_t * pNtk, Cec_ParCsw_t * pPars ); + + pNtk = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set defaults + Cec_ManCswSetDefaultParams( p ); + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "WRCNZLrfvh" ) ) != EOF ) + { + switch ( c ) + { + case 'W': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-W\" should be followed by an integer.\n" ); + goto usage; + } + p->nWords = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( p->nWords < 0 ) + goto usage; + break; + case 'R': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-R\" should be followed by an integer.\n" ); + goto usage; + } + p->nRounds = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( p->nRounds < 0 ) + goto usage; + break; + case 'C': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" ); + goto usage; + } + p->nBTLimit = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( p->nBTLimit < 0 ) + goto usage; + break; + case 'N': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + p->nSatVarMax = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( p->nSatVarMax < 0 ) + goto usage; + break; + case 'Z': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-Z\" should be followed by an integer.\n" ); + goto usage; + } + p->nCallsRecycle = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( p->nCallsRecycle < 0 ) + goto usage; + break; + case 'L': + if ( globalUtilOptind >= argc ) + { + fprintf( pErr, "Command line switch \"-L\" should be followed by an integer.\n" ); + goto usage; + } + p->nLevelMax = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( p->nLevelMax < 0 ) + goto usage; + break; + case 'r': + p->fRewriting ^= 1; + break; + case 'f': + p->fFirstStop ^= 1; + break; + case 'v': + p->fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pNtk == NULL ) + { + fprintf( pErr, "Empty network.\n" ); + return 1; + } + if ( !Abc_NtkIsStrash(pNtk) ) + { + fprintf( pErr, "This command works only for strashed networks.\n" ); + return 1; + } + pNtkRes = Abc_NtkDarSatSweep( pNtk, p ); + if ( pNtkRes == NULL ) + { + fprintf( pErr, "Command has failed.\n" ); + return 0; + } + // replace the current network + Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); + return 0; +usage: + fprintf( pErr, "usage: nfraig [-WRCNZL num] [-rfvh]\n" ); + fprintf( pErr, "\t performs fraiging using a new method\n" ); + fprintf( pErr, "\t-W num : lthe number of simulation words [default = %d]\n", p->nWords ); + fprintf( pErr, "\t-R num : the number of simulation rounds [default = %d]\n", p->nRounds ); + fprintf( pErr, "\t-C num : limit on conflicts at a node [default = %d]\n", p->nBTLimit ); + fprintf( pErr, "\t-N num : the min number of SAT vars before recycling [default = %d]\n", p->nSatVarMax ); + fprintf( pErr, "\t-Z num : the min number of SAT calls before recycling [default = %d]\n", p->nCallsRecycle ); + fprintf( pErr, "\t-L num : the maximum level of the nodes to be swept [default = %d]\n", p->nLevelMax ); + fprintf( pErr, "\t-r : toggle the use of AIG rewriting [default = %s]\n", p->fRewriting? "yes": "no" ); + fprintf( pErr, "\t-f : stop after one output is disproved [default = %s]\n", p->fFirstStop? "yes": "no" ); + fprintf( pErr, "\t-v : enable verbose printout [default = %s]\n", p->fVerbose? "yes": "no" ); + fprintf( pErr, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* Synopsis [] @@ -10121,7 +10393,7 @@ int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv ) } if ( i == Abc_NtkCoNum(pNtk) ) printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); } if ( RetValue == -1 ) @@ -10132,7 +10404,7 @@ int Abc_CommandIProve( Abc_Frame_t * pAbc, int argc, char ** argv ) printf( "UNSATISFIABLE " ); //printf( "\n" ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp ); return 0; @@ -10157,6 +10429,7 @@ usage: SeeAlso [] ***********************************************************************/ +/* int Abc_CommandHaig( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pOut, * pErr; @@ -10264,6 +10537,7 @@ usage: fprintf( pErr, "\t-h : print the command usage\n"); return 1; } +*/ /**Function************************************************************* @@ -11001,6 +11275,7 @@ usage: return 1; } +#if 0 /**Function************************************************************* @@ -11448,7 +11723,7 @@ usage: return 1; } - +#endif /**Function************************************************************* @@ -11741,7 +12016,7 @@ usage: 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-i : toggles assuming inverters are ABC_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"); @@ -12454,6 +12729,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) globalUtilOptind++; if ( pPars->DelayTarget <= 0.0 ) goto usage; + break; case 'E': if ( globalUtilOptind >= argc ) { @@ -12888,7 +13164,7 @@ int Abc_CommandUndc( Abc_Frame_t * pAbc, int argc, char ** argv ) usage: fprintf( pErr, "usage: undc [-h]\n" ); - fprintf( pErr, "\t converts latches with DC init values into free PIs\n" ); + fprintf( pErr, "\t converts latches with DC init values into ABC_FREE PIs\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; } @@ -14897,13 +15173,13 @@ int Abc_CommandSim( Abc_Frame_t * pAbc, int argc, char ** argv ) fprintf( pErr, "Only works for strashed networks.\n" ); return 1; } - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pSeqModel ); Abc_NtkDarSeqSim( pNtk, nFrames, nWords, TimeOut, fNew, fComb, fMiter, fVerbose ); return 0; usage: fprintf( pErr, "usage: sim [-FWT num] [-ncmvh]\n" ); - fprintf( pErr, "\t performs random simulation of the sequentail miter\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 ); @@ -15698,7 +15974,7 @@ int Abc_CommandDCec( Abc_Frame_t * pAbc, int argc, char ** argv ) int fPartition; int fMiter; - extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int fAlignPol, int fAndOuts, int fVerbose ); + extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fAlignPol, int fAndOuts, int fVerbose ); extern int Abc_NtkDarCec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int fPartition, int fVerbose ); pNtk = Abc_FrameReadNtk(pAbc); @@ -16843,13 +17119,13 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv ) clk = clock(); if ( Abc_NtkIsStrash(pNtk) ) { - RetValue = Abc_NtkMiterSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fVerbose, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, fVerbose, NULL, NULL ); } else { assert( Abc_NtkIsLogic(pNtk) ); Abc_NtkToBdd( pNtk ); - RetValue = Abc_NtkMiterSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fVerbose, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, fVerbose, NULL, NULL ); } // verify that the pattern is correct @@ -16860,7 +17136,7 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv ) int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel ); if ( pSimInfo[0] != 1 ) printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); /* // print model Abc_NtkForEachPi( pNtk, pObj, i ) @@ -16880,7 +17156,7 @@ int Abc_CommandSat( Abc_Frame_t * pAbc, int argc, char ** argv ) else printf( "UNSATISFIABLE " ); //printf( "\n" ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); return 0; usage: @@ -16919,7 +17195,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) int nInsLimit; int clk; - extern int Abc_NtkDSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int fAlignPol, int fAndOuts, int fVerbose ); + 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); @@ -16999,7 +17275,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) } clk = clock(); - RetValue = Abc_NtkDSat( pNtk, (sint64)nConfLimit, (sint64)nInsLimit, fAlignPol, fAndOuts, fVerbose ); + RetValue = Abc_NtkDSat( pNtk, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, fAlignPol, fAndOuts, fVerbose ); // verify that the pattern is correct if ( RetValue == 0 && Abc_NtkPoNum(pNtk) == 1 ) { @@ -17008,7 +17284,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel ); if ( pSimInfo[0] != 1 ) printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); /* // print model Abc_NtkForEachPi( pNtk, pObj, i ) @@ -17028,7 +17304,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) else printf( "UNSATISFIABLE " ); //printf( "\n" ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); return 0; usage: @@ -17163,7 +17439,7 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv ) int * pSimInfo = Abc_NtkVerifySimulatePattern( pNtk, pNtk->pModel ); if ( pSimInfo[0] != 1 ) printf( "ERROR in Abc_NtkMiterSat(): Generated counter example is invalid.\n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); /* // print model Abc_NtkForEachPi( pNtk, pObj, i ) @@ -17183,7 +17459,7 @@ int Abc_CommandPSat( Abc_Frame_t * pAbc, int argc, char ** argv ) else printf( "UNSATISFIABLE " ); //printf( "\n" ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); return 0; usage: @@ -17341,7 +17617,7 @@ 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" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); } if ( RetValue == -1 ) @@ -17352,7 +17628,7 @@ int Abc_CommandProve( Abc_Frame_t * pAbc, int argc, char ** argv ) printf( "UNSATISFIABLE " ); //printf( "\n" ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); // replace the current network Abc_FrameReplaceCurrentNetwork( pAbc, pNtkTemp ); return 0; @@ -18581,7 +18857,7 @@ int Abc_CommandAbc8Read( Abc_Frame_t * pAbc, int argc, char ** argv ) } else { - extern void * Nal_ManRead( char * pFileName ); +// extern void * Nal_ManRead( char * pFileName ); pAbc->pAbc8Ntl = NULL; // pAbc->pAbc8Ntl = Nal_ManRead( pFileName ); // Ioa_WriteBlif( pAbc->pAbc8Ntl, "test_boxes.blif" ); @@ -19380,7 +19656,7 @@ int Abc_CommandAbc8If( Abc_Frame_t * pAbc, int argc, char ** argv ) } // enable truth table computation if choices are selected - if ( (c = Aig_ManCountChoices( pAbc->pAbc8Aig )) ) + if ( (c = Aig_ManChoiceNum( pAbc->pAbc8Aig )) ) { printf( "Performing LUT mapping with %d choices.\n", c ); pPars->fExpRed = 0; @@ -21519,6 +21795,1213 @@ usage: } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Read( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pAig; + FILE * pFile; + char ** pArgvNew; + char * FileName, * pTemp; + int nArgcNew; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + default: + goto usage; + } + } + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( nArgcNew != 1 ) + { + printf( "There is no file name.\n" ); + return 1; + } + + // get the input file name + FileName = pArgvNew[0]; + // fix the wrong symbol + for ( pTemp = FileName; *pTemp; pTemp++ ) + if ( *pTemp == '>' ) + *pTemp = '\\'; + if ( (pFile = fopen( FileName, "r" )) == NULL ) + { + fprintf( pAbc->Err, "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" ); + 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; + return 0; + +usage: + fprintf( stdout, "usage: &r [-vh] \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 : the file name\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Get( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters ); + Gia_Man_t * pAig; + Aig_Man_t * pMan; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + default: + goto usage; + } + } + if ( pAbc->pNtkCur == NULL ) + { + printf( "There is no current network\n" ); + return 1; + } + if ( !Abc_NtkIsStrash( pAbc->pNtkCur ) ) + { + printf( "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_AigCleanup(pAbc->pNtkCur->pManFunc); + } + 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; + return 0; + +usage: + fprintf( stdout, "usage: &get [-vh] \n" ); + fprintf( stdout, "\t transfer the current network from the old ABC\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 : the file name\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Put( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan ); + Aig_Man_t * pMan; + FILE * pOut, * pErr; + Abc_Ntk_t * pNtk; + int c; + int fVerbose; + + pNtk = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set defaults + fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) + { + switch ( c ) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + fprintf( pErr, "Empty network.\n" ); + return 1; + } + pMan = Gia_ManToAig( pAbc->pAig ); + pNtk = Abc_NtkFromAigPhase( pMan ); + Aig_ManStop( pMan ); + // replace the current network + Abc_FrameReplaceCurrentNetwork( pAbc, pNtk ); + 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"); + return 1; +} + + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Write( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + char * pFileName; + char ** pArgvNew; + int c, nArgcNew; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + pArgvNew = argv + globalUtilOptind; + nArgcNew = argc - globalUtilOptind; + if ( nArgcNew != 1 ) + { + printf( "There is no file name.\n" ); + return 1; + } + if ( pAbc->pAig == NULL ) + { + printf( "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 ); + return 0; + +usage: + fprintf( stdout, "usage: &w [-h] \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 : the file name\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Ps(): There is no AIG.\n" ); + return 1; + } + Gia_ManPrintStats( pAbc->pAig ); + return 0; + +usage: + fprintf( stdout, "usage: &ps [-h]\n" ); + fprintf( stdout, "\t prints stats of the current AIG\n" ); + fprintf( stdout, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9PFan( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c; + int nNodes = 40; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Nh" ) ) != EOF ) + { + switch ( c ) + { + case 'N': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + nNodes = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nNodes < 0 ) + goto usage; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9PFan(): There is no AIG.\n" ); + return 1; + } + Gia_ManPrintFanio( pAbc->pAig, 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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Status( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Status(): There is no AIG.\n" ); + return 1; + } + Gia_ManPrintMiterStatus( pAbc->pAig ); + 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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Show( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Aig_Man_t * pMan; + int c; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Show(): There is no AIG.\n" ); + return 1; + } + pMan = Gia_ManToAig( pAbc->pAig ); + 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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Hash( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + int c; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Hash(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Gia_ManRehash( pTemp = pAbc->pAig ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: &hash [-h]\n" ); + fprintf( stdout, "\t performs structural hashing\n" ); + fprintf( stdout, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Topand( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + int c, fVerbose = 1; + 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->pAig == NULL ) + { + printf( "Abc_CommandAbc9Hash(): There is no AIG.\n" ); + return 1; + } + if ( Gia_ManRegNum(pAbc->pAig) > 0 ) + { + printf( "Abc_CommandAbc9Topand(): Can only be applied to a combinational miter.\n" ); + return 1; + } + pAbc->pAig = Gia_ManDupTopAnd( pTemp = pAbc->pAig, fVerbose ); + Gia_ManStop( 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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Cof( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + int c, iVar = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Vh" ) ) != EOF ) + { + switch ( c ) + { + case 'V': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-V\" should be followed by an integer.\n" ); + goto usage; + } + iVar = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( iVar < 0 ) + goto usage; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Cof(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Gia_ManDupCofactored( pTemp = pAbc->pAig, iVar ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: &cof [-V num] [-h]\n" ); + fprintf( stdout, "\t performs cofactoring w.r.t. a variable\n" ); + fprintf( stdout, "\t-V num : the zero-based ID of the variable to cofactor [default = %d]\n", iVar ); + fprintf( stdout, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Trim( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + int c; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Trim(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Gia_ManDupTrimmed( pTemp = pAbc->pAig ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: &trim [-h]\n" ); + fprintf( stdout, "\t removes PIs without fanout and PO driven by constants\n" ); + fprintf( stdout, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Dfs( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + int c; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Dfs(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Gia_ManDupDfs( pTemp = pAbc->pAig ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: &dfs [-h]\n" ); + fprintf( stdout, "\t orders objects in the DFS order\n" ); + fprintf( stdout, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Sim( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_ParSim_t Pars, * pPars = &Pars; + int c; + Gia_ManSimSetDefaultParams( pPars ); + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "WFTmvh" ) ) != EOF ) + { + switch ( c ) + { + case 'W': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "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 'F': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nIters = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nIters < 0 ) + goto usage; + break; + case 'T': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "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 'm': + pPars->fCheckMiter ^= 1; + break; + case 'v': + pPars->fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Sim(): There is no AIG.\n" ); + return 1; + } + Gia_ManSimSimulate( pAbc->pAig, pPars ); + return 0; + +usage: + fprintf( stdout, "usage: &sim [-WFT ] [-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": "not miter" ); + fprintf( stdout, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" ); + fprintf( stdout, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Times( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + int c, nTimes = 2, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Nvh" ) ) != EOF ) + { + switch ( c ) + { + case 'N': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-T\" should be followed by an integer.\n" ); + goto usage; + } + nTimes = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nTimes < 0 ) + goto usage; + break; + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Times(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Gia_ManDupTimes( pTemp = pAbc->pAig, nTimes ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: × [-N ] [-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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Frames( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + Gia_ParFra_t Pars, * pPars = &Pars; + int c; + Gia_ManFraSetDefaultParams( pPars ); + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "Fivh" ) ) != EOF ) + { + switch ( c ) + { + case 'F': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-F\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nFrames = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nFrames < 0 ) + goto usage; + break; + case 'i': + pPars->fInit ^= 1; + break; + case 'v': + pPars->fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Times(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Gia_ManFrames( pTemp = pAbc->pAig, pPars ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: &frames [-F ] [-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-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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Scl( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Gia_Man_t * pTemp; + int c, fConst = 1, fEquiv = 1, fVerbose = 1; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "cevh" ) ) != EOF ) + { + switch ( c ) + { + case 'c': + fConst ^= 1; + break; + case 'e': + fEquiv ^= 1; + break; + case 'v': + fVerbose ^= 1; + break; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Scl(): There is no AIG.\n" ); + return 1; + } + printf( "Implementation of this command is not finished.\n" ); + return 0; + + pAbc->pAig = Gia_ManSeqStructSweep( pTemp = pAbc->pAig, fConst, fEquiv, fVerbose ); + Gia_ManStop( 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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Sat( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Cec_ParSat_t ParsSat, * pPars = &ParsSat; + Gia_Man_t * pTemp; + int c; + Cec_ManSatSetDefaultParams( pPars ); + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "CSNfvh" ) ) != EOF ) + { + switch ( c ) + { + case 'C': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nBTLimit = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nBTLimit < 0 ) + goto usage; + break; + case 'S': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "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 'N': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nCallsRecycle = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nCallsRecycle < 0 ) + goto usage; + break; + case 'f': + pPars->fFirstStop ^= 1; + break; + case 'v': + pPars->fVerbose ^= 1; + break; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Sat(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Cec_ManSatSolving( pTemp = pAbc->pAig, pPars ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: &sat [-CSN ] [-fvh]\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 max number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle ); + fprintf( stdout, "\t-f : toggle stopping when an output is satisfiable [default = %s]\n", pPars->fFirstStop? "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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Fraig( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + Cec_ParCsw_t ParsCsw, * pPars = &ParsCsw; + Gia_Man_t * pTemp; + int c; + Cec_ManCswSetDefaultParams( pPars ); + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "WRILDCSNrmwvh" ) ) != EOF ) + { + switch ( c ) + { + case 'W': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "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 'R': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-R\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nRounds = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nRounds < 0 ) + goto usage; + break; + case 'I': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-I\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nItersMax = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nItersMax < 0 ) + goto usage; + break; + case 'L': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-L\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nLevelMax = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nLevelMax < 0 ) + goto usage; + break; + case 'D': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-D\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nDepthMax = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nDepthMax < 0 ) + goto usage; + break; + case 'C': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-C\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nBTLimit = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nBTLimit < 0 ) + goto usage; + break; + case 'S': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "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 'N': + if ( globalUtilOptind >= argc ) + { + fprintf( stdout, "Command line switch \"-N\" should be followed by an integer.\n" ); + goto usage; + } + pPars->nCallsRecycle = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( pPars->nCallsRecycle < 0 ) + goto usage; + break; + case 'r': + pPars->fRewriting ^= 1; + break; + case 'm': + pPars->fFirstStop ^= 1; + break; + case 'w': + pPars->fVeryVerbose ^= 1; + break; + case 'v': + pPars->fVerbose ^= 1; + break; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Fraig(): There is no AIG.\n" ); + return 1; + } + pAbc->pAig = Cec_ManSatSweeping( pTemp = pAbc->pAig, pPars ); + Gia_ManStop( pTemp ); + return 0; + +usage: + fprintf( stdout, "usage: &fraig [-WRILDCSN ] [-rmwvh]\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-S num : the min number of variables to recycle the solver [default = %d]\n", pPars->nSatVarMax ); + fprintf( stdout, "\t-N num : the max number of calls to recycle the solver [default = %d]\n", pPars->nCallsRecycle ); + fprintf( stdout, "\t-r : toggle the use of AIG rewriting [default = %s]\n", pPars->fRewriting? "yes": "no" ); + fprintf( stdout, "\t-m : toggle stopping when an output is satisfiable [default = %s]\n", pPars->fFirstStop? "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"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Test( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + int c; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) + { + switch ( c ) + { + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pAig == NULL ) + { + printf( "Abc_CommandAbc9Test(): There is no AIG.\n" ); + return 1; + } +// Gia_ManFrontTest( pAbc->pAig ); +// Gia_ManReduceConst( pAbc->pAig, 1 ); +// Sat_ManTest( pAbc->pAig, Gia_ManCo(pAbc->pAig, 0), 0 ); + Gia_ManTestDistance( pAbc->pAig ); + return 0; + +usage: + fprintf( stdout, "usage: &test [-h]\n" ); + fprintf( stdout, "\t testing various procedures\n" ); + fprintf( stdout, "\t-h : print the command usage\n"); + return 1; +} + /**Function************************************************************* diff --git a/src/base/abci/abcAbc8.c b/src/base/abci/abcAbc8.c index be25d9c2..a306a8e4 100644 --- a/src/base/abci/abcAbc8.c +++ b/src/base/abci/abcAbc8.c @@ -161,12 +161,12 @@ Abc_Ntk_t * Abc_NtkNtkTest2( Abc_Ntk_t * pNtk ) clk = clock(); Abc_NtkSupportSum( pNtk ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); pMan = Abc_NtkToNtkNew( pNtk ); clk = clock(); Nwk_ManSupportSum( pMan ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); pNtkNew = Abc_NtkFromNtkNew( pNtk, pMan ); Nwk_ManFree( pMan ); @@ -195,13 +195,13 @@ Abc_Ntk_t * Abc_NtkNtkTest3( Abc_Ntk_t * pNtk ) clk = clock(); printf( "%6.2f\n", Abc_NtkDelayTraceLut( pNtk, 1 ) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); pMan = Abc_NtkToNtkNew( pNtk ); pMan->pLutLib = Abc_FrameReadLibLut(); clk = clock(); printf( "%6.2f\n", Nwk_ManDelayTraceLut( pMan ) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); pNtkNew = Abc_NtkFromNtkNew( pNtk, pMan ); Nwk_ManFree( pMan ); diff --git a/src/base/abci/abcAttach.c b/src/base/abci/abcAttach.c index d5d2aa16..e35cfdf6 100644 --- a/src/base/abci/abcAttach.c +++ b/src/base/abci/abcAttach.c @@ -80,8 +80,8 @@ int Abc_NtkAttach( Abc_Ntk_t * pNtk ) ppGates = Mio_CollectRoots( pGenlib, 6, (float)1.0e+20, 1, &nGates ); // derive the gate truth tables - puTruthGates = ALLOC( unsigned *, nGates ); - puTruthGates[0] = ALLOC( unsigned, 2 * nGates ); + puTruthGates = ABC_ALLOC( unsigned *, nGates ); + puTruthGates[0] = ABC_ALLOC( unsigned, 2 * nGates ); for ( i = 1; i < nGates; i++ ) puTruthGates[i] = puTruthGates[i-1] + 2; for ( i = 0; i < nGates; i++ ) @@ -109,24 +109,24 @@ int Abc_NtkAttach( Abc_Ntk_t * pNtk ) else if ( nFanins > 6 ) { printf( "Cannot attach gate with more than 6 inputs to node %s.\n", Abc_ObjName(pNode) ); - free( puTruthGates[0] ); - free( puTruthGates ); - free( ppGates ); + ABC_FREE( puTruthGates[0] ); + ABC_FREE( puTruthGates ); + ABC_FREE( ppGates ); return 0; } else if ( !Abc_NodeAttach( pNode, ppGates, puTruthGates, nGates, uTruths ) ) { printf( "Could not attach the library gate to node %s.\n", Abc_ObjName(pNode) ); - free( puTruthGates[0] ); - free( puTruthGates ); - free( ppGates ); + ABC_FREE( puTruthGates[0] ); + ABC_FREE( puTruthGates ); + ABC_FREE( ppGates ); return 0; } } - free( puTruthGates[0] ); - free( puTruthGates ); - free( ppGates ); - FREE( s_pPerms ); + ABC_FREE( puTruthGates[0] ); + ABC_FREE( puTruthGates ); + ABC_FREE( ppGates ); + ABC_FREE( s_pPerms ); // perform the final transformation Abc_NtkForEachNode( pNtk, pNode, i ) diff --git a/src/base/abci/abcAuto.c b/src/base/abci/abcAuto.c index 40212c17..13be6eea 100644 --- a/src/base/abci/abcAuto.c +++ b/src/base/abci/abcAuto.c @@ -96,8 +96,8 @@ void Abc_NtkAutoPrint( Abc_Ntk_t * pNtk, int Output, int fNaive, int fVerbose ) // Extra_StopManager( pNtk->pManGlob ); // pNtk->pManGlob = NULL; Abc_NtkFreeGlobalBdds( pNtk, 1 ); - free( pInputNames ); - free( pOutputNames ); + ABC_FREE( pInputNames ); + ABC_FREE( pOutputNames ); Vec_PtrFree( vFuncsGlob ); } @@ -161,8 +161,8 @@ void Abc_NtkAutoPrintAll( DdManager * dd, int nInputs, DdNode * pbOutputs[], int nSuppSizeMax = nSupp; -//PRB( dd, bCanVars ); -//PRB( dd, bReduced ); +//ABC_PRB( dd, bCanVars ); +//ABC_PRB( dd, bReduced ); //Cudd_PrintMinterm( dd, bReduced ); //printf( "The equations are:\n" ); //Cudd_zddPrintCover( dd, zEquations ); @@ -170,8 +170,8 @@ void Abc_NtkAutoPrintAll( DdManager * dd, int nInputs, DdNode * pbOutputs[], int //fflush( stdout ); bSpace2 = Extra_bddSpaceFromMatrixPos( dd, zEquations ); Cudd_Ref( bSpace2 ); -//PRB( dd, bSpace1 ); -//PRB( dd, bSpace2 ); +//ABC_PRB( dd, bSpace1 ); +//ABC_PRB( dd, bSpace2 ); if ( bSpace1 != bSpace2 ) printf( "Spaces are NOT EQUAL!\n" ); // else diff --git a/src/base/abci/abcBalance.c b/src/base/abci/abcBalance.c index 26b6db99..134a175a 100644 --- a/src/base/abci/abcBalance.c +++ b/src/base/abci/abcBalance.c @@ -49,7 +49,7 @@ static Vec_Ptr_t * Abc_NodeBalanceConeExor( Abc_Obj_t * pNode ); ***********************************************************************/ Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective, bool fUpdateLevel ) { - extern void Abc_NtkHaigTranfer( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ); +// extern void Abc_NtkHaigTranfer( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ); Abc_Ntk_t * pNtkAig; assert( Abc_NtkIsStrash(pNtk) ); // compute the required times @@ -61,7 +61,7 @@ Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective, // perform balancing pNtkAig = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG ); // transfer HAIG - Abc_NtkHaigTranfer( pNtk, pNtkAig ); +// Abc_NtkHaigTranfer( pNtk, pNtkAig ); // perform balancing Abc_NtkBalancePerform( pNtk, pNtkAig, fDuplicate, fSelective, fUpdateLevel ); Abc_NtkFinalize( pNtk, pNtkAig ); @@ -271,8 +271,8 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_ // printf( "Constant node\n" ); // assert( pNodeOld->Level >= Abc_ObjRegular(pNodeOld->pCopy)->Level ); // update HAIG - if ( Abc_ObjRegular(pNodeOld->pCopy)->pNtk->pHaig ) - Hop_ObjCreateChoice( pNodeOld->pEquiv, Abc_ObjRegular(pNodeOld->pCopy)->pEquiv ); +// if ( Abc_ObjRegular(pNodeOld->pCopy)->pNtk->pHaig ) +// Hop_ObjCreateChoice( pNodeOld->pEquiv, Abc_ObjRegular(pNodeOld->pCopy)->pEquiv ); return pNodeOld->pCopy; } diff --git a/src/base/abci/abcBidec.c b/src/base/abci/abcBidec.c index 01146014..0b6165fb 100644 --- a/src/base/abci/abcBidec.c +++ b/src/base/abci/abcBidec.c @@ -138,7 +138,7 @@ void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose ) if ( fVerbose ) { printf( "Total gain in AIG nodes = %d. ", nGainTotal ); - PRT( "Total runtime", clock() - clk ); + ABC_PRT( "Total runtime", clock() - clk ); } } diff --git a/src/base/abci/abcBmc.c b/src/base/abci/abcBmc.c index 1512c76f..d2c5a12c 100644 --- a/src/base/abci/abcBmc.c +++ b/src/base/abci/abcBmc.c @@ -64,7 +64,7 @@ printf( "Fraig has %6d nodes.\n", Ivy_ManNodeNum(pFraig) ); // report the classes // if ( fVerbose ) // Abc_NtkBmcReport( pMan, pFrames, pFraig, vMapping, nFrames ); - // free stuff + // ABC_FREE stuff Vec_PtrFree( vMapping ); Ivy_ManStop( pFraig ); Ivy_ManStop( pFrames ); diff --git a/src/base/abci/abcCas.c b/src/base/abci/abcCas.c index 4ed7a774..ff0d761e 100644 --- a/src/base/abci/abcCas.c +++ b/src/base/abci/abcCas.c @@ -68,12 +68,12 @@ Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVer { DdManager * dd = Abc_NtkGlobalBddMan( pNtk ); printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) ); - PRT( "BDD construction time", clock() - clk ); + ABC_PRT( "BDD construction time", clock() - clk ); } // collect global BDDs dd = Abc_NtkGlobalBddMan( pNtk ); - ppOutputs = ALLOC( DdNode *, Abc_NtkCoNum(pNtk) ); + ppOutputs = ABC_ALLOC( DdNode *, Abc_NtkCoNum(pNtk) ); Abc_NtkForEachCo( pNtk, pNode, i ) ppOutputs[i] = Abc_ObjGlobalBdd(pNode); @@ -89,8 +89,8 @@ Abc_Ntk_t * Abc_NtkCascade( Abc_Ntk_t * pNtk, int nLutSize, int fCheck, int fVer // cleanup Abc_NtkFreeGlobalBdds( pNtk, 1 ); - free( ppOutputs ); - free( pFileGeneric ); + ABC_FREE( ppOutputs ); + ABC_FREE( pFileGeneric ); // if ( pNtk->pExdc ) // pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc ); diff --git a/src/base/abci/abcClpBdd.c b/src/base/abci/abcClpBdd.c index a6b3a770..27cba249 100644 --- a/src/base/abci/abcClpBdd.c +++ b/src/base/abci/abcClpBdd.c @@ -56,7 +56,7 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i { DdManager * dd = Abc_NtkGlobalBddMan( pNtk ); printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) ); - PRT( "BDD construction time", clock() - clk ); + ABC_PRT( "BDD construction time", clock() - clk ); } // create the new network @@ -142,8 +142,8 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk ) Extra_ProgressBarStop( pProgress ); // Extra_ReorderQuit( pReo ); -//PRT( "Reo ", runtime1 ); -//PRT( "Cudd", runtime2 ); +//ABC_PRT( "Reo ", runtime1 ); +//ABC_PRT( "Cudd", runtime2 ); return pNtkNew; } diff --git a/src/base/abci/abcCut.c b/src/base/abci/abcCut.c index 1c7459eb..48c2f8e0 100644 --- a/src/base/abci/abcCut.c +++ b/src/base/abci/abcCut.c @@ -189,7 +189,7 @@ Cut_Man_t * Abc_NtkCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ) Vec_PtrFree( vNodes ); Vec_IntFree( vChoices ); Cut_ManPrintStats( p ); -PRT( "TOTAL", clock() - clk ); +ABC_PRT( "TOTAL", clock() - clk ); printf( "Area = %d.\n", Abc_NtkComputeArea( pNtk, p ) ); //Abc_NtkPrintCuts( p, pNtk, 0 ); // Cut_ManPrintStatsToFile( p, pNtk->pSpec, clock() - clk ); @@ -256,7 +256,7 @@ void Abc_NtkCutsOracle( Abc_Ntk_t * pNtk, Cut_Oracle_t * p ) } } Vec_PtrFree( vNodes ); -//PRT( "Total", clock() - clk ); +//ABC_PRT( "Total", clock() - clk ); //Abc_NtkPrintCuts_( p, pNtk, 0 ); } @@ -356,7 +356,7 @@ Cut_Man_t * Abc_NtkSeqCuts( Abc_Ntk_t * pNtk, Cut_Params_t * pParams ) if ( pParams->fVerbose ) { Cut_ManPrintStats( p ); -PRT( "TOTAL ", clock() - clk ); +ABC_PRT( "TOTAL ", clock() - clk ); printf( "Converged after %d iterations.\n", nIters ); } //Abc_NtkPrintCuts( p, pNtk, 1 ); diff --git a/src/base/abci/abcDar.c b/src/base/abci/abcDar.c index 9dc10d84..dbd461c4 100644 --- a/src/base/abci/abcDar.c +++ b/src/base/abci/abcDar.c @@ -29,8 +29,9 @@ #include "dch.h" #include "ssw.h" #include "cgt.h" +//#include "fsim.h" +#include "gia.h" #include "cec.h" -#include "fsim.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -174,7 +175,7 @@ Aig_Man_t * Abc_NtkToDarChoices( Abc_Ntk_t * pNtk ) pMan->pName = Extra_UtilStrsav( pNtk->pName ); if ( Abc_NtkGetChoiceNum(pNtk) ) { - pMan->pEquivs = ALLOC( Aig_Obj_t *, Abc_NtkObjNum(pNtk) ); + pMan->pEquivs = ABC_ALLOC( Aig_Obj_t *, Abc_NtkObjNum(pNtk) ); memset( pMan->pEquivs, 0, sizeof(Aig_Obj_t *) * Abc_NtkObjNum(pNtk) ); } // transfer the pointers to the basic nodes @@ -690,6 +691,35 @@ Abc_Ntk_t * Abc_NtkDarFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, in return pNtkAig; } +/**Function************************************************************* + + Synopsis [Gives the current ABC network to AIG manager for processing.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Abc_Ntk_t * Abc_NtkDarSatSweep( Abc_Ntk_t * pNtk, Cec_ParCsw_t * pPars ) +{ +/* + extern Aig_Man_t * Cec_ManSatSweep( Aig_Man_t * pAig, Cec_ParCsw_t * pPars ); + Abc_Ntk_t * pNtkAig; + Aig_Man_t * pMan, * pTemp; + pMan = Abc_NtkToDar( pNtk, 0, 0 ); + if ( pMan == NULL ) + return NULL; + pMan = Cec_ManSatSweep( pTemp = pMan, pPars ); + Aig_ManStop( pTemp ); + pNtkAig = Abc_NtkFromDar( pNtk, pMan ); + Aig_ManStop( pMan ); + return pNtkAig; + */ + return NULL; +} + /**Function************************************************************* Synopsis [Gives the current ABC network to AIG manager for processing.] @@ -777,7 +807,7 @@ Abc_Ntk_t * Abc_NtkDRewrite( Abc_Ntk_t * pNtk, Dar_RwrPar_t * pPars ) clk = clock(); pMan = Aig_ManDupDfs( pTemp = pMan ); Aig_ManStop( pTemp ); -//PRT( "time", clock() - clk ); +//ABC_PRT( "time", clock() - clk ); // Aig_ManPrintStats( pMan ); pNtkAig = Abc_NtkFromDar( pNtk, pMan ); @@ -814,7 +844,7 @@ Abc_Ntk_t * Abc_NtkDRefactor( Abc_Ntk_t * pNtk, Dar_RefPar_t * pPars ) clk = clock(); pMan = Aig_ManDupDfs( pTemp = pMan ); Aig_ManStop( pTemp ); -//PRT( "time", clock() - clk ); +//ABC_PRT( "time", clock() - clk ); // Aig_ManPrintStats( pMan ); pNtkAig = Abc_NtkFromDar( pNtk, pMan ); @@ -847,7 +877,7 @@ Abc_Ntk_t * Abc_NtkDC2( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, int fF clk = clock(); pMan = Dar_ManCompress2( pTemp = pMan, fBalance, fUpdateLevel, fFanout, fPower, fVerbose ); Aig_ManStop( pTemp ); -//PRT( "time", clock() - clk ); +//ABC_PRT( "time", clock() - clk ); // Aig_ManPrintStats( pMan ); pNtkAig = Abc_NtkFromDar( pNtk, pMan ); @@ -953,7 +983,7 @@ Abc_Ntk_t * Abc_NtkDrwsat( Abc_Ntk_t * pNtk, int fBalance, int fVerbose ) clk = clock(); pMan = Dar_ManRwsat( pTemp = pMan, fBalance, fVerbose ); Aig_ManStop( pTemp ); -//PRT( "time", clock() - clk ); +//ABC_PRT( "time", clock() - clk ); // Aig_ManPrintStats( pMan ); pNtkAig = Abc_NtkFromDar( pNtk, pMan ); @@ -1032,7 +1062,7 @@ Abc_Ntk_t * Abc_NtkConstructFromCnf( Abc_Ntk_t * pNtk, Cnf_Man_t * p, Vec_Ptr_t fprintf( stdout, "Abc_NtkConstructFromCnf(): Network check has failed.\n" ); return pNtkNew; } - + /**Function************************************************************* Synopsis [Gives the current ABC network to AIG manager for processing.] @@ -1069,6 +1099,8 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName ) // derive CNF pCnf = Cnf_Derive( pMan, 0 ); Cnf_DataTranformPolarity( pCnf, 0 ); + printf( "Vars = %6d. Clauses = %7d. Literals = %8d.\n", pCnf->nVars, pCnf->nClauses, pCnf->nLiterals ); + /* // write the network for verification pManCnf = Cnf_ManRead(); @@ -1097,7 +1129,7 @@ Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName ) SeeAlso [] ***********************************************************************/ -int Abc_NtkDSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int fAlignPol, int fAndOuts, int fVerbose ) +int Abc_NtkDSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fAlignPol, int fAndOuts, int fVerbose ) { Aig_Man_t * pMan; int RetValue;//, clk = clock(); @@ -1195,7 +1227,7 @@ int Abc_NtkDarCec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int fPa pNtk1->pModel = Abc_NtkVerifyGetCleanModel( pNtk1, 1 ); // pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, nFrames ); // Abc_NtkVerifyReportErrorSeq( pNtk1, pNtk2, pMiter->pModel, nFrames ); -// FREE( pMiter->pModel ); +// ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return 0; } @@ -1226,17 +1258,17 @@ finish: if ( RetValue == 1 ) { printf( "Networks are equivalent. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else if ( RetValue == 0 ) { printf( "Networks are NOT EQUIVALENT. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else { printf( "Networks are UNDECIDED. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } fflush( stdout ); return RetValue; @@ -1290,7 +1322,8 @@ int Abc_NtkDarCec2( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Cec_ParCec_t * pPars ) } } // perform verification - RetValue = Cec_Solve( pMan1, pMan2, pPars ); +// RetValue = Cec_Solve( pMan1, pMan2, pPars ); + RetValue = -1; // transfer model if given pNtk1->pModel = pMan1->pData, pMan1->pData = NULL; Aig_ManStop( pMan1 ); @@ -1301,17 +1334,17 @@ int Abc_NtkDarCec2( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Cec_ParCec_t * pPars ) if ( RetValue == 1 ) { printf( "Networks are equivalent. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else if ( RetValue == 0 ) { printf( "Networks are NOT EQUIVALENT. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else { printf( "Networks are UNDECIDED. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } fflush( stdout ); return RetValue; @@ -1345,7 +1378,7 @@ Abc_Ntk_t * Abc_NtkDarSeqSweep( Abc_Ntk_t * pNtk, Fra_Ssw_t * pPars ) pNtkFraig = Abc_NtkFraig( pNtk, &Params, 0, 0 ); if ( pPars->fVerbose ) { -PRT( "Initial fraiging time", clock() - clk ); +ABC_PRT( "Initial fraiging time", clock() - clk ); } } else @@ -1391,8 +1424,8 @@ void Abc_NtkPrintLatchEquivClasses( Abc_Ntk_t * pNtk, Aig_Man_t * pAig ) { bool header_dumped = false; int num_orig_latches = Abc_NtkLatchNum(pNtk); - char **pNames = ALLOC( char *, num_orig_latches ); - bool *p_irrelevant = ALLOC( bool, num_orig_latches ); + char **pNames = ABC_ALLOC( char *, num_orig_latches ); + bool *p_irrelevant = ABC_ALLOC( bool, num_orig_latches ); char * pFlopName, * pReprName; Aig_Obj_t * pFlop, * pRepr; Abc_Obj_t * pNtkFlop; @@ -1402,7 +1435,7 @@ void Abc_NtkPrintLatchEquivClasses( Abc_Ntk_t * pNtk, Aig_Man_t * pAig ) Abc_NtkForEachLatch( pNtk, pNtkFlop, i ) { char *temp_name = Abc_ObjName( Abc_ObjFanout0(pNtkFlop) ); - pNames[i] = ALLOC( char , strlen(temp_name)+1); + pNames[i] = ABC_ALLOC( char , strlen(temp_name)+1); strcpy(pNames[i], temp_name); } i = 0; @@ -1457,13 +1490,13 @@ void Abc_NtkPrintLatchEquivClasses( Abc_Ntk_t * pNtk, Aig_Man_t * pAig ) printf("%s ", pNames[i]); } - FREE(pNames[i]); + ABC_FREE(pNames[i]); } if (header_dumped) printf("\n"); - FREE(pNames); - FREE(p_irrelevant); + ABC_FREE(pNames); + ABC_FREE(p_irrelevant); } /**Function************************************************************* @@ -1617,8 +1650,8 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nFrames, int nSizeMax, int nNodeDelta, { int iFrame; RetValue = Saig_ManBmcSimple( pMan, nFrames, nSizeMax, nBTLimit, fRewrite, fVerbose, &iFrame ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + 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 ); @@ -1634,8 +1667,8 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nFrames, int nSizeMax, int nNodeDelta, { /* Fra_BmcPerformSimple( pMan, nFrames, nBTLimit, fRewrite, fVerbose ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL; if ( pNtk->pSeqModel ) { @@ -1652,8 +1685,8 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nFrames, int nSizeMax, int nNodeDelta, /* int iFrame; RetValue = Ssw_BmcDynamic( pMan, nFrames, nBTLimit, fVerbose, &iFrame ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + 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 ); @@ -1666,11 +1699,11 @@ int Abc_NtkDarBmc( Abc_Ntk_t * pNtk, int nFrames, int nSizeMax, int nNodeDelta, } */ Saig_BmcPerform( pMan, nFrames, nNodeDelta, nBTLimit, nBTLimitAll, fVerbose ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL; } -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); // verify counter-example if ( pNtk->pSeqModel ) { @@ -1711,15 +1744,15 @@ int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, Inter_ManParams_t * pPars ) else if ( RetValue == 0 ) { printf( "Property DISPROVED in frame %d (use \"write_counter\" to dump a witness). ", iFrame ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL; } else if ( RetValue == -1 ) printf( "Property UNDECIDED. " ); else assert( 0 ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); Aig_ManStop( pMan ); return 1; } @@ -1801,11 +1834,11 @@ int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar ) if ( RetValue == 1 ) { printf( "Networks are equivalent after CEC. " ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); if ( pSecPar->fReportSolution ) { printf( "SOLUTION: PASS " ); - PRT( "Time", clock() - clkTotal ); + ABC_PRT( "Time", clock() - clkTotal ); } return RetValue; } @@ -1819,7 +1852,7 @@ int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar ) if ( pSecPar->fReportSolution ) { printf( "SOLUTION: FAIL " ); - PRT( "Time", clock() - clkTotal ); + ABC_PRT( "Time", clock() - clkTotal ); } return RetValue; } @@ -1840,8 +1873,8 @@ int Abc_NtkDarProve( Abc_Ntk_t * pNtk, Fra_Sec_t * pSecPar ) else { RetValue = Fra_FraigSec( pMan, pSecPar, NULL ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL; if ( pNtk->pSeqModel ) { @@ -1888,7 +1921,7 @@ int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Fra_Sec_t * pSecPar ) // report the error pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, pSecPar->nFramesMax ); Abc_NtkVerifyReportErrorSeq( pNtk1, pNtk2, pMiter->pModel, pSecPar->nFramesMax ); - FREE( pMiter->pModel ); + ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return 0; } @@ -1916,7 +1949,7 @@ int Abc_NtkDarSec( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, Fra_Sec_t * pSecPar ) // report the error pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, nFrames ); Abc_NtkVerifyReportErrorSeq( pNtk1, pNtk2, pMiter->pModel, nFrames ); - FREE( pMiter->pModel ); + ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return 0; } @@ -2297,6 +2330,7 @@ Abc_Ntk_t * Abc_NtkDarRetimeStep( Abc_Ntk_t * pNtk, int fVerbose ) SeeAlso [] ***********************************************************************/ +/* Abc_Ntk_t * Abc_NtkDarHaigRecord( Abc_Ntk_t * pNtk, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose ) { Abc_Ntk_t * pNtkAig; @@ -2315,6 +2349,7 @@ Abc_Ntk_t * Abc_NtkDarHaigRecord( Abc_Ntk_t * pNtk, int nIters, int nSteps, int Aig_ManStop( pMan ); return pNtkAig; } +*/ /**Function************************************************************* @@ -2334,9 +2369,15 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in Aig_Man_t * pMan; Fra_Cex_t * pCex; int status, RetValue, clk = clock(); + if ( Abc_NtkGetChoiceNum(pNtk) ) + { + printf( "Removing %d choices from the AIG.\n", Abc_NtkGetChoiceNum(pNtk) ); + Abc_AigCleanup(pNtk->pManFunc); + } pMan = Abc_NtkToDar( pNtk, 0, 1 ); if ( fComb || Abc_NtkLatchNum(pNtk) == 0 ) { +/* if ( Cec_ManSimulate( pMan, nWords, nFrames, TimeOut, fMiter, fVerbose ) ) { pCex = pMan->pSeqModel; @@ -2348,8 +2389,8 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in if ( status == 0 ) printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" ); } - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pCex; RetValue = 1; } @@ -2359,6 +2400,8 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in printf( "Simulation iterated %d times with %d words did not assert the outputs. ", nFrames, nWords ); } +*/ + printf( "Comb simulation is temporarily disabled.\n" ); } else if ( fNew ) { @@ -2373,8 +2416,8 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in if ( status == 0 ) printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" ); } - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pCex; pMan->pSeqModel = NULL; RetValue = 1; } @@ -2385,6 +2428,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in nFrames, nWords ); } */ +/* Fsim_ParSim_t Pars, * pPars = &Pars; Fsim_ManSetDefaultParamsSim( pPars ); pPars->nWords = nWords; @@ -2393,7 +2437,38 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in pPars->fCheckMiter = fMiter; pPars->fVerbose = fVerbose; if ( Fsim_ManSimulate( pMan, pPars ) ) + { + if ( (pCex = pMan->pSeqModel) ) + { + 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 ); + 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; + } + else { + RetValue = 0; + printf( "Simulation of %d frames with %d words did not assert the outputs. ", + nFrames, nWords ); + } +*/ + Gia_Man_t * pGia; + Gia_ParSim_t Pars, * pPars = &Pars; + Gia_ManSimSetDefaultParams( pPars ); + pPars->nWords = nWords; + pPars->nIters = nFrames; + pPars->TimeLimit = TimeOut; + pPars->fCheckMiter = fMiter; + pPars->fVerbose = fVerbose; + pGia = Gia_ManFromAig( pMan ); + if ( Gia_ManSimSimulate( pGia, pPars ) ) + { if ( (pCex = pMan->pSeqModel) ) { printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ", @@ -2402,8 +2477,8 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in if ( status == 0 ) printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" ); } - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pCex; pMan->pSeqModel = NULL; RetValue = 1; } @@ -2413,20 +2488,20 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in printf( "Simulation of %d frames with %d words did not assert the outputs. ", nFrames, nWords ); } + Gia_ManStop( pGia ); } else { -/* Fra_Sml_t * pSml; - pSml = Fra_SmlSimulateSeq( pMan, 0, nFrames, nWords ); + pSml = Fra_SmlSimulateSeq( pMan, 0, nFrames, nWords, fMiter ); if ( pSml->fNonConstOut ) { pCex = Fra_SmlGetCounterExample( pSml ); if ( pCex ) printf( "Simulation of %d frames with %d words asserted output %d in frame %d. ", nFrames, nWords, pCex->iPo, pCex->iFrame ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pCex; RetValue = 1; } @@ -2437,7 +2512,7 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in nFrames, nWords ); } Fra_SmlStop( pSml ); -*/ +/* if ( Raig_ManSimulate( pMan, nWords, nFrames, TimeOut, fMiter, fVerbose ) ) { if ( (pCex = pMan->pSeqModel) ) @@ -2448,8 +2523,8 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in if ( status == 0 ) printf( "Abc_NtkDarSeqSim(): Counter-example verification has FAILED.\n" ); } - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pCex; pMan->pSeqModel = NULL; RetValue = 1; } @@ -2459,8 +2534,9 @@ int Abc_NtkDarSeqSim( Abc_Ntk_t * pNtk, int nFrames, int nWords, int TimeOut, in printf( "Simulation of %d frames with %d words did not assert the outputs. ", nFrames, nWords ); } +*/ } - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); Aig_ManStop( pMan ); return RetValue; } @@ -2549,17 +2625,17 @@ void Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fV if ( RetValue == 1 ) { printf( "Networks are equivalent. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else if ( RetValue == 0 ) { printf( "Networks are NOT EQUIVALENT. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } else { printf( "Networks are UNDECIDED. " ); -PRT( "Time", clock() - clkTotal ); +ABC_PRT( "Time", clock() - clkTotal ); } } @@ -2588,8 +2664,8 @@ Abc_Ntk_t * Abc_NtkDarPBAbstraction( Abc_Ntk_t * pNtk, int nFramesMax, int nConf pMan = Saig_ManProofAbstraction( pTemp = pMan, nFramesMax, nConfMax, fDynamic, fExtend, 0, fVerbose ); if ( pTemp->pSeqModel ) { - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pTemp->pSeqModel; pTemp->pSeqModel = NULL; } Aig_ManStop( pTemp ); @@ -2753,10 +2829,10 @@ timeInt = 0; Abc_NtkDelete( pNtkOn1 ); Abc_NtkDelete( pNtkOff1 ); } -// PRT( "CNF", timeCnf ); -// PRT( "SAT", timeSat ); -// PRT( "Int", timeInt ); -// PRT( "Slow interpolation time", clock() - clk ); +// ABC_PRT( "CNF", timeCnf ); +// ABC_PRT( "SAT", timeSat ); +// ABC_PRT( "Int", timeInt ); +// ABC_PRT( "Slow interpolation time", clock() - clk ); // return the network if ( !Abc_NtkCheck( pNtkInter ) ) @@ -3188,8 +3264,8 @@ void Abc_NtkDarReach( Abc_Ntk_t * pNtk, int nBddMax, int nIterMax, int fPartitio if ( pMan == NULL ) return; Aig_ManVerifyUsingBdds( pMan, nBddMax, nIterMax, fPartition, fReorder, fVerbose, 0 ); - FREE( pNtk->pModel ); - FREE( pNtk->pSeqModel ); + ABC_FREE( pNtk->pModel ); + ABC_FREE( pNtk->pSeqModel ); pNtk->pSeqModel = pMan->pSeqModel; pMan->pSeqModel = NULL; Aig_ManStop( pMan ); } @@ -3270,6 +3346,7 @@ Abc_Ntk_t * Amap_ManProduceNetwork( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMapping ) ***********************************************************************/ Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars ) { + extern Vec_Ptr_t * Amap_ManTest( Aig_Man_t * pAig, Amap_Par_t * pPars ); Vec_Ptr_t * vMapping; Abc_Ntk_t * pNtkAig = NULL; Aig_Man_t * pMan; @@ -3314,7 +3391,7 @@ Abc_Ntk_t * Abc_NtkDarAmap( Abc_Ntk_t * pNtk, Amap_Par_t * pPars ) ***********************************************************************/ void Abc_NtkDarTest( Abc_Ntk_t * pNtk ) { - extern void Fsim_ManTest( 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; Aig_Man_t * pMan;//, * pMan2;//, * pTemp; @@ -3347,7 +3424,7 @@ Aig_ManPrintStats( pMan ); // Saig_MvManSimulate( pMan, 1 ); - Fsim_ManTest( pMan ); +// Fsim_ManTest( pMan ); Aig_ManStop( pMan ); } @@ -3365,7 +3442,7 @@ Aig_ManPrintStats( pMan ); ***********************************************************************/ Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk ) { - extern Aig_Man_t * Saig_ManDualRail( Aig_Man_t * p, int fMiter ); +// extern Aig_Man_t * Saig_ManDualRail( Aig_Man_t * p, int fMiter ); /* extern Aig_Man_t * Ssw_SignalCorrespondeceTestPairs( Aig_Man_t * pAig ); @@ -3390,7 +3467,7 @@ Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk ) return pNtkAig; */ Abc_Ntk_t * pNtkAig; - Aig_Man_t * pMan, * pTemp; + Aig_Man_t * pMan;//, * pTemp; assert( Abc_NtkIsStrash(pNtk) ); pMan = Abc_NtkToDar( pNtk, 0, 1 ); if ( pMan == NULL ) @@ -3402,7 +3479,7 @@ Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk ) if ( pMan == NULL ) return NULL; */ - +/* Aig_ManSetRegNum( pMan, pMan->nRegs ); pMan = Saig_ManDualRail( pTemp = pMan, 1 ); Aig_ManStop( pTemp ); @@ -3413,6 +3490,12 @@ Abc_Ntk_t * Abc_NtkDarTestNtk( Abc_Ntk_t * pNtk ) pNtkAig->pName = Extra_UtilStrsav(pNtk->pName); pNtkAig->pSpec = Extra_UtilStrsav(pNtk->pSpec); Aig_ManStop( pMan ); +*/ + + + pNtkAig = Abc_NtkFromDar( pNtk, pMan ); + Aig_ManStop( pMan ); + return pNtkAig; } diff --git a/src/base/abci/abcDebug.c b/src/base/abci/abcDebug.c index 95b95d89..6d8d9bfa 100644 --- a/src/base/abci/abcDebug.c +++ b/src/base/abci/abcDebug.c @@ -88,14 +88,14 @@ void Abc_NtkAutoDebug( Abc_Ntk_t * pNtk, int (*pFuncError) (Abc_Ntk_t *) ) } printf( "Iter %6d : Latches = %6d. Nodes = %6d. Steps = %6d. Error step = %3d. ", nIter, Abc_NtkLatchNum(pNtk), Abc_NtkNodeNum(pNtk), nSteps, i ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); if ( i == nSteps ) // could not modify it while preserving the bug break; } // write out the final network Io_WriteBlifLogic( pNtk, pFileName, 1 ); printf( "Final network written into file \"%s\". ", pFileName ); - PRT( "Total time", clock() - clkTotal ); + ABC_PRT( "Total time", clock() - clkTotal ); Abc_NtkDelete( pNtk ); } diff --git a/src/base/abci/abcDelay.c b/src/base/abci/abcDelay.c index 847c7f1b..203b076f 100644 --- a/src/base/abci/abcDelay.c +++ b/src/base/abci/abcDelay.c @@ -117,8 +117,8 @@ float Abc_NtkDelayTraceLut( Abc_Ntk_t * pNtk, int fUseLutLib ) } // initialize the arrival times - FREE( pNtk->pLutTimes ); - pNtk->pLutTimes = ALLOC( float, 3 * Abc_NtkObjNumMax(pNtk) ); + ABC_FREE( pNtk->pLutTimes ); + pNtk->pLutTimes = ABC_ALLOC( float, 3 * Abc_NtkObjNumMax(pNtk) ); for ( i = 0; i < Abc_NtkObjNumMax(pNtk); i++ ) { pNtk->pLutTimes[3*i+0] = pNtk->pLutTimes[3*i+2] = 0; @@ -255,7 +255,7 @@ void Abc_NtkDelayTracePrint( Abc_Ntk_t * pNtk, int fUseLutLib, int fVerbose ) } // decide how many steps nSteps = fUseLutLib ? 20 : Abc_NtkLevel(pNtk); - pCounters = ALLOC( int, nSteps + 1 ); + pCounters = ABC_ALLOC( int, nSteps + 1 ); memset( pCounters, 0, sizeof(int)*(nSteps + 1) ); // perform delay trace tArrival = Abc_NtkDelayTraceLut( pNtk, fUseLutLib ); @@ -278,7 +278,7 @@ void Abc_NtkDelayTracePrint( Abc_Ntk_t * pNtk, int fUseLutLib, int fVerbose ) printf( "%3d %s : %5d (%6.2f %%)\n", fUseLutLib? 5*(i+1) : i+1, fUseLutLib? "%":"lev", Nodes, 100.0*Nodes/Abc_NtkNodeNum(pNtk) ); } - free( pCounters ); + ABC_FREE( pCounters ); } /**Function************************************************************* @@ -527,7 +527,7 @@ Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, in printf( "\n" ); } // mark the timing critical nodes and edges - puTCEdges = ALLOC( unsigned, Abc_NtkObjNumMax(pNtk) ); + puTCEdges = ABC_ALLOC( unsigned, Abc_NtkObjNumMax(pNtk) ); memset( puTCEdges, 0, sizeof(unsigned) * Abc_NtkObjNumMax(pNtk) ); Abc_NtkForEachNode( pNtk, pNode, i ) { @@ -636,7 +636,7 @@ Abc_Ntk_t * Abc_NtkSpeedup( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, in } Vec_PtrFree( vTimeCries ); Vec_PtrFree( vTimeFanins ); - free( puTCEdges ); + ABC_FREE( puTCEdges ); if ( fVerbose ) printf( "Nodes: Total = %7d. 0-slack = %7d. Workable = %7d. Ratio = %4.2f\n", Abc_NtkNodeNum(pNtk), Counter, CounterRes, 1.0*CounterRes/Counter ); @@ -691,7 +691,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 = pObjAbc2->pTemp) ) + if ( (pObjAbc2 = Abc_ObjRegular(pObjAbc->pTemp)) && (pObjAig = Aig_Regular(pObjAbc2->pTemp)) ) pProbability[pObjAbc->Id] = pSwitching[pObjAig->Id]; } Vec_IntFree( vSwitching ); @@ -714,8 +714,8 @@ Vec_Int_t * Abc_NtkPowerEstimate( Abc_Ntk_t * pNtk, int fProbOne ) void Abc_NtkPowerPrint( Abc_Ntk_t * pNtk, Vec_Int_t * vProbs ) { Abc_Obj_t * pObj; - float * pProb, TotalProb = 0.0, ProbThis, Probs[5] = {0.0}; - int i, nNodes = 0, nEdges = 0, Counter[5] = {0}; + float * pProb, TotalProb = 0.0, ProbThis, Probs[6] = {0.0}; + int i, nNodes = 0, nEdges = 0, Counter[6] = {0}; pProb = (float *)vProbs->pArray; assert( Vec_IntSize(vProbs) >= Abc_NtkObjNumMax(pNtk) ); Abc_NtkForEachObj( pNtk, pObj, i ) @@ -726,8 +726,13 @@ void Abc_NtkPowerPrint( Abc_Ntk_t * pNtk, Vec_Int_t * vProbs ) nEdges += Abc_ObjFanoutNum(pObj); ProbThis = pProb[i] * Abc_ObjFanoutNum(pObj); TotalProb += ProbThis; - assert( pProb[i] >= 0.0 && pProb[i] <= 0.5 ); - if ( pProb[i] >= 0.4 ) + assert( pProb[i] >= 0.0 && pProb[i] <= 1.0 ); + if ( pProb[i] >= 0.5 ) + { + Counter[5]++; + Probs[5] += ProbThis; + } + else if ( pProb[i] >= 0.4 ) { Counter[4]++; Probs[4] += ProbThis; @@ -754,11 +759,11 @@ void Abc_NtkPowerPrint( Abc_Ntk_t * pNtk, Vec_Int_t * vProbs ) } } printf( "Node distribution: " ); - for ( i = 0; i < 5; i++ ) + for ( i = 0; i < 6; i++ ) printf( "n%d%d = %6.2f%% ", i, i+1, 100.0 * Counter[i]/nNodes ); printf( "\n" ); printf( "Power distribution: " ); - for ( i = 0; i < 5; i++ ) + for ( i = 0; i < 6; i++ ) printf( "p%d%d = %6.2f%% ", i, i+1, 100.0 * Probs[i]/TotalProb ); printf( "\n" ); printf( "Total probs = %7.2f. ", TotalProb ); @@ -819,7 +824,7 @@ Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, if ( fVerbose ) Abc_NtkPowerPrint( pNtk, vProbs ); // mark the power critical nodes and edges - puPCEdges = ALLOC( unsigned, Abc_NtkObjNumMax(pNtk) ); + puPCEdges = ABC_ALLOC( unsigned, Abc_NtkObjNumMax(pNtk) ); memset( puPCEdges, 0, sizeof(unsigned) * Abc_NtkObjNumMax(pNtk) ); Abc_NtkForEachNode( pNtk, pNode, i ) { @@ -931,7 +936,7 @@ Abc_Ntk_t * Abc_NtkPowerdown( Abc_Ntk_t * pNtk, int fUseLutLib, int Percentage, } Vec_PtrFree( vTimeCries ); Vec_PtrFree( vTimeFanins ); - free( puPCEdges ); + ABC_FREE( puPCEdges ); if ( fVerbose ) printf( "Nodes: Total = %7d. Power-critical = %7d. Workable = %7d. Ratio = %4.2f\n", Abc_NtkNodeNum(pNtk), Counter, CounterRes, 1.0*CounterRes/Counter ); diff --git a/src/base/abci/abcDsd.c b/src/base/abci/abcDsd.c index ab6279b6..7f3d2071 100644 --- a/src/base/abci/abcDsd.c +++ b/src/base/abci/abcDsd.c @@ -133,8 +133,8 @@ Abc_Ntk_t * Abc_NtkDsdInternal( Abc_Ntk_t * pNtk, bool fVerbose, bool fPrint, bo ppNamesCi = Abc_NtkCollectCioNames( pNtk, 0 ); ppNamesCo = Abc_NtkCollectCioNames( pNtk, 1 ); Dsd_TreePrint( stdout, pManDsd, ppNamesCi, ppNamesCo, fShort, -1 ); - free( ppNamesCi ); - free( ppNamesCo ); + ABC_FREE( ppNamesCi ); + ABC_FREE( ppNamesCo ); } // stop the DSD manager @@ -161,18 +161,18 @@ void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * int i, nNodesDsd; // save the CI nodes in the DSD nodes - Dsd_NodeSetMark( Dsd_ManagerReadConst1(pManDsd), (int)(PORT_PTRINT_T)Abc_NtkCreateNodeConst1(pNtkNew) ); + Dsd_NodeSetMark( Dsd_ManagerReadConst1(pManDsd), (int)(ABC_PTRINT_T)Abc_NtkCreateNodeConst1(pNtkNew) ); Abc_NtkForEachCi( pNtk, pNode, i ) { pNodeDsd = Dsd_ManagerReadInput( pManDsd, i ); - Dsd_NodeSetMark( pNodeDsd, (int)(PORT_PTRINT_T)pNode->pCopy ); + Dsd_NodeSetMark( pNodeDsd, (int)(ABC_PTRINT_T)pNode->pCopy ); } // collect DSD nodes in DFS order (leaves and const1 are not collected) ppNodesDsd = Dsd_TreeCollectNodesDfs( pManDsd, &nNodesDsd ); for ( i = 0; i < nNodesDsd; i++ ) Abc_NtkDsdConstructNode( pManDsd, ppNodesDsd[i], pNtkNew, NULL ); - free( ppNodesDsd ); + ABC_FREE( ppNodesDsd ); // set the pointers to the CO drivers Abc_NtkForEachCo( pNtk, pNode, i ) @@ -183,7 +183,7 @@ void Abc_NtkDsdConstruct( Dsd_Manager_t * pManDsd, Abc_Ntk_t * pNtk, Abc_Ntk_t * if ( !Abc_AigNodeIsAnd(pDriver) ) continue; pNodeDsd = Dsd_ManagerReadRoot( pManDsd, i ); - pNodeNew = (Abc_Obj_t *)(PORT_PTRINT_T)Dsd_NodeReadMark( Dsd_Regular(pNodeDsd) ); + pNodeNew = (Abc_Obj_t *)(ABC_PTRINT_T)Dsd_NodeReadMark( Dsd_Regular(pNodeDsd) ); assert( !Abc_ObjIsComplement(pNodeNew) ); pDriver->pCopy = Abc_ObjNotCond( pNodeNew, Dsd_IsComplement(pNodeDsd) ); } @@ -219,7 +219,7 @@ Abc_Obj_t * Abc_NtkDsdConstructNode( Dsd_Manager_t * pManDsd, Dsd_Node_t * pNode for ( i = 0; i < nDecs; i++ ) { pFaninDsd = Dsd_NodeReadDec( pNodeDsd, i ); - pFanin = (Abc_Obj_t *)(PORT_PTRINT_T)Dsd_NodeReadMark(Dsd_Regular(pFaninDsd)); + pFanin = (Abc_Obj_t *)(ABC_PTRINT_T)Dsd_NodeReadMark(Dsd_Regular(pFaninDsd)); Abc_ObjAddFanin( pNodeNew, pFanin ); assert( Type == DSD_NODE_OR || !Dsd_IsComplement(pFaninDsd) ); } @@ -284,7 +284,7 @@ printf( "\n" ); } } pNodeNew->pData = bLocal; - Dsd_NodeSetMark( pNodeDsd, (int)(PORT_PTRINT_T)pNodeNew ); + Dsd_NodeSetMark( pNodeDsd, (int)(ABC_PTRINT_T)pNodeNew ); return pNodeNew; } @@ -400,7 +400,7 @@ void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager Abc_ObjForEachFanin( pNode, pFanin, i ) { pFaninDsd = Dsd_ManagerReadInput( pManDsd, i ); - Dsd_NodeSetMark( pFaninDsd, (int)(PORT_PTRINT_T)pFanin ); + Dsd_NodeSetMark( pFaninDsd, (int)(ABC_PTRINT_T)pFanin ); } // construct the intermediate nodes @@ -411,7 +411,7 @@ void Abc_NodeDecompDsdAndMux( Abc_Obj_t * pNode, Vec_Ptr_t * vNodes, Dsd_Manager if ( Abc_NodeIsForDsd(pRoot) && fRecursive ) Vec_PtrPush( vNodes, pRoot ); } - free( ppNodesDsd ); + ABC_FREE( ppNodesDsd ); assert(pRoot); // remove the current fanins diff --git a/src/base/abci/abcFraig.c b/src/base/abci/abcFraig.c index d3cbaccb..1db939b2 100644 --- a/src/base/abci/abcFraig.c +++ b/src/base/abci/abcFraig.c @@ -185,7 +185,7 @@ Fraig_Node_t * Abc_NtkToFraigExdc( Fraig_Man_t * pMan, Abc_Ntk_t * pNtkMain, Abc } assert( pObj->pCopy != NULL ); } - free( ppNames ); + ABC_FREE( ppNames ); // build FRAIG for each node Abc_AigForEachAnd( pNtkStrash, pObj, i ) pObj->pCopy = (Abc_Obj_t *)Fraig_NodeAnd( pMan, @@ -742,7 +742,7 @@ Abc_Ntk_t * Abc_NtkFraigRestore() // perform partitioned computation of structural choices pFraig = Abc_NtkFraigPartitioned( vStore, &Params ); Abc_NtkFraigStoreClean(); -//PRT( "Total choicing time", clock() - clk ); +//ABC_PRT( "Total choicing time", clock() - clk ); return pFraig; } diff --git a/src/base/abci/abcFxu.c b/src/base/abci/abcFxu.c index 45515dd1..850a6e24 100644 --- a/src/base/abci/abcFxu.c +++ b/src/base/abci/abcFxu.c @@ -54,9 +54,9 @@ bool 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 - // and it may not be SCC-free, in which case FXU will not work correctly + // and it may not be SCC-ABC_FREE, in which case FXU will not work correctly if ( Abc_NtkIsSopLogic(pNtk) ) - { // to make sure the SOPs are SCC-free + { // to make sure the SOPs are SCC-ABC_FREE // Abc_NtkSopToBdd(pNtk); // Abc_NtkBddToSop(pNtk); } @@ -177,17 +177,17 @@ void Abc_NtkFxuCollectInfo( Abc_Ntk_t * pNtk, Fxu_Data_t * p ) void Abc_NtkFxuFreeInfo( Fxu_Data_t * p ) { int i; - // free the arrays of new fanins + // ABC_FREE the arrays of new fanins if ( p->vFaninsNew ) for ( i = 0; i < p->vFaninsNew->nSize; i++ ) if ( p->vFaninsNew->pArray[i] ) Vec_IntFree( p->vFaninsNew->pArray[i] ); - // free the arrays + // ABC_FREE the arrays if ( p->vSops ) Vec_PtrFree( p->vSops ); if ( p->vSopsNew ) Vec_PtrFree( p->vSopsNew ); if ( p->vFanins ) Vec_PtrFree( p->vFanins ); if ( p->vFaninsNew ) Vec_PtrFree( p->vFaninsNew ); - FREE( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/base/abci/abcHaig.c b/src/base/abci/abcHaig.c index d3513bbe..569275f2 100644 --- a/src/base/abci/abcHaig.c +++ b/src/base/abci/abcHaig.c @@ -28,6 +28,8 @@ /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// +#if 0 + /**Function************************************************************* Synopsis [Start history AIG.] @@ -148,6 +150,7 @@ void Abc_NtkHaigTranfer( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew ) } +#endif /**Function************************************************************* @@ -636,6 +639,8 @@ int Abc_NtkHaigResetReprs( Hop_Man_t * p ) return nFanouts; } +#if 0 + /**Function************************************************************* Synopsis [Stops history AIG.] @@ -686,10 +691,12 @@ Abc_Ntk_t * Abc_NtkHaigUse( Abc_Ntk_t * pNtk ) pNtkAig = Abc_NtkHaigRecreateAig( pNtk, pMan ); Hop_ManStop( pMan ); - // free HAIG + // ABC_FREE HAIG return pNtkAig; } +#endif + /**Function************************************************************* Synopsis [Transform HOP manager into the one without loops.] diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c index c5d9ada7..facf06bc 100644 --- a/src/base/abci/abcIf.c +++ b/src/base/abci/abcIf.c @@ -89,7 +89,7 @@ void Abc_NtkIfComputeSwitching( Abc_Ntk_t * pNtk, If_Man_t * pIfMan ) pSwitching[i] = pObjAbc->dTemp; if ( pIfMan->pPars->fVerbose ) { - PRT( "Computing switching activity", clock() - clk ); + ABC_PRT( "Computing switching activity", clock() - clk ); } } @@ -509,8 +509,8 @@ Hop_Obj_t * Abc_NodeIfToHop( Hop_Man_t * pHopMan, If_Man_t * pIfMan, If_Obj_t * ***********************************************************************/ int Abc_ObjCompareFlow( Abc_Obj_t ** ppNode0, Abc_Obj_t ** ppNode1 ) { - float Flow0 = Abc_Int2Float((int)(PORT_PTRINT_T)(*ppNode0)->pCopy); - float Flow1 = Abc_Int2Float((int)(PORT_PTRINT_T)(*ppNode1)->pCopy); + float Flow0 = Abc_Int2Float((int)(ABC_PTRINT_T)(*ppNode0)->pCopy); + float Flow1 = Abc_Int2Float((int)(ABC_PTRINT_T)(*ppNode1)->pCopy); if ( Flow0 > Flow1 ) return -1; if ( Flow0 < Flow1 ) @@ -573,9 +573,9 @@ Vec_Ptr_t * Abc_NtkFindGoodOrder( Abc_Ntk_t * pNtk ) { pFanin0 = Abc_ObjFanin0(pNode); pFanin1 = Abc_ObjFanin1(pNode); - Flow0 = Abc_Int2Float((int)(PORT_PTRINT_T)pFanin0->pCopy)/Abc_ObjFanoutNum(pFanin0); - Flow1 = Abc_Int2Float((int)(PORT_PTRINT_T)pFanin1->pCopy)/Abc_ObjFanoutNum(pFanin1); - pNode->pCopy = (Abc_Obj_t *)(PORT_PTRINT_T)Abc_Float2Int(Flow0 + Flow1+(float)1.0); + Flow0 = Abc_Int2Float((int)(ABC_PTRINT_T)pFanin0->pCopy)/Abc_ObjFanoutNum(pFanin0); + Flow1 = Abc_Int2Float((int)(ABC_PTRINT_T)pFanin1->pCopy)/Abc_ObjFanoutNum(pFanin1); + pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)Abc_Float2Int(Flow0 + Flow1+(float)1.0); } // find the flow of the COs vCos = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) ); @@ -592,7 +592,7 @@ Vec_Ptr_t * Abc_NtkFindGoodOrder( Abc_Ntk_t * pNtk ) // verify sorting pFanin0 = Vec_PtrEntry(vCos, 0); pFanin1 = Vec_PtrEntryLast(vCos); - assert( Abc_Int2Float((int)(PORT_PTRINT_T)pFanin0->pCopy) >= Abc_Int2Float((int)(PORT_PTRINT_T)pFanin1->pCopy) ); + 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 ); diff --git a/src/base/abci/abcIvy.c b/src/base/abci/abcIvy.c index 96d8196e..c7fa5a1e 100644 --- a/src/base/abci/abcIvy.c +++ b/src/base/abci/abcIvy.c @@ -216,13 +216,13 @@ clk = clock(); Ivy_ManRewriteSeq( pMan, 1, 0 ); //printf( "%d ", Ivy_ManNodeNum(pMan) ); //printf( "%d ", Ivy_ManNodeNum(pMan->pHaig) ); -//PRT( " ", clock() - clk ); +//ABC_PRT( " ", clock() - clk ); //printf( "\n" ); /* printf( "Moves = %d. ", nMoves ); printf( "MovesS = %d. ", nMovesS ); printf( "Clauses = %d. ", nClauses ); - PRT( "Time", timeInv ); + ABC_PRT( "Time", timeInv ); */ // Ivy_ManRewriteSeq( pMan, 1, 0 ); //printf( "Haig size = %d.\n", Ivy_ManNodeNum(pMan->pHaig) ); @@ -510,13 +510,13 @@ int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars ) pFanin = Abc_ObjFanin0(pObj); if ( Abc_ObjFanin0(pObj)->fPhase != (unsigned)Abc_ObjFaninC0(pObj) ) { - pNtk->pModel = ALLOC( int, Abc_NtkPiNum(pNtk) ); + pNtk->pModel = ABC_ALLOC( int, Abc_NtkPiNum(pNtk) ); memset( pNtk->pModel, 0, sizeof(int) * Abc_NtkPiNum(pNtk) ); return 0; } // if SAT only, solve without iteration - RetValue = Abc_NtkMiterSat( pNtk, 2*(sint64)pParams->nMiteringLimitStart, (sint64)0, 0, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pNtk, 2*(ABC_INT64_T)pParams->nMiteringLimitStart, (ABC_INT64_T)0, 0, NULL, NULL ); if ( RetValue >= 0 ) return RetValue; @@ -534,7 +534,7 @@ int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars ) Abc_NtkRewrite( pNtk, 0, 0, 0, 0, 0 ); Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 ); //printf( "After rwsat = %d. ", Abc_NtkNodeNum(pNtk) ); -//PRT( "Time", clock() - clk ); +//ABC_PRT( "Time", clock() - clk ); } // convert ABC network into IVY network @@ -672,13 +672,13 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk ) // make sure everything is okay if ( !Abc_NtkCheck( pNtkAig ) ) { - FREE( pInit ); + ABC_FREE( pInit ); printf( "Abc_NtkStrash: The network check has failed.\n" ); Abc_NtkDelete( pNtkAig ); return NULL; } - FREE( pInit ); + ABC_FREE( pInit ); return pNtkAig; */ } diff --git a/src/base/abci/abcLut.c b/src/base/abci/abcLut.c index 4203a425..bb45f6c4 100644 --- a/src/base/abci/abcLut.c +++ b/src/base/abci/abcLut.c @@ -286,7 +286,7 @@ Abc_ManScl_t * Abc_ManSclStart( int nLutSize, int nCutSizeMax, int nNodesMax ) Abc_ManScl_t * p; int i, k; assert( sizeof(unsigned) == 4 ); - p = ALLOC( Abc_ManScl_t, 1 ); + p = ABC_ALLOC( Abc_ManScl_t, 1 ); memset( p, 0, sizeof(Abc_ManScl_t) ); p->nLutSize = nLutSize; p->nCutSizeMax = nCutSizeMax; @@ -321,10 +321,10 @@ Abc_ManScl_t * Abc_ManSclStart( int nLutSize, int nCutSizeMax, int nNodesMax ) void Abc_ManSclStop( Abc_ManScl_t * p ) { // Vec_IntFree( p->vBound ); - free( p->uVars ); - free( p->uSims ); - free( p->uCofs ); - free( p ); + ABC_FREE( p->uVars ); + ABC_FREE( p->uSims ); + ABC_FREE( p->uCofs ); + ABC_FREE( p ); } diff --git a/src/base/abci/abcMap.c b/src/base/abci/abcMap.c index 3a454fc0..c4a68cc7 100644 --- a/src/base/abci/abcMap.c +++ b/src/base/abci/abcMap.c @@ -117,7 +117,7 @@ clk = clock(); pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc ); if ( fVerbose ) { -PRT( "Total runtime", clock() - clkTotal ); +ABC_PRT( "Total runtime", clock() - clkTotal ); } // make sure that everything is okay diff --git a/src/base/abci/abcMeasure.c b/src/base/abci/abcMeasure.c index 6604a0c4..00d5d971 100644 --- a/src/base/abci/abcMeasure.c +++ b/src/base/abci/abcMeasure.c @@ -244,8 +244,8 @@ void Abc_Ntk4VarTable( Abc_Ntk_t * pNtk ) // Counters[ puMap[uTruth & 0xFFFF] ]++; Vec_PtrFree( vNodes ); } - free( puCanons ); - free( puMap ); + ABC_FREE( puCanons ); + ABC_FREE( puMap ); Count = 0; for ( k = 0; k < 222; k++ ) diff --git a/src/base/abci/abcMerge.c b/src/base/abci/abcMerge.c index 25a4f02e..4997af48 100644 --- a/src/base/abci/abcMerge.c +++ b/src/base/abci/abcMerge.c @@ -322,7 +322,7 @@ Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars ) if ( pPars->fVerbose ) { printf( "Mergable LUTs = %6d. Total cands = %6d. ", p->nVertsMax, nCands ); - PRT( "Deriving graph", clock() - clk ); + ABC_PRT( "Deriving graph", clock() - clk ); } // solve the graph problem clk = clock(); @@ -331,7 +331,7 @@ Vec_Int_t * Abc_NtkLutMerge( Abc_Ntk_t * pNtk, Nwk_LMPars_t * pPars ) { printf( "GRAPH: Nodes = %6d. Edges = %6d. Pairs = %6d. ", p->nVerts, p->nEdges, Vec_IntSize(p->vPairs)/2 ); - PRT( "Solving", clock() - clk ); + ABC_PRT( "Solving", clock() - clk ); Nwk_ManGraphReportMemoryUsage( p ); } vResult = p->vPairs; p->vPairs = NULL; diff --git a/src/base/abci/abcMiter.c b/src/base/abci/abcMiter.c index 4e1022b8..34270fab 100644 --- a/src/base/abci/abcMiter.c +++ b/src/base/abci/abcMiter.c @@ -805,7 +805,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 free PI variables.\n", Counter ); + printf( "Warning: %d uninitialized latches are replaced by ABC_FREE PI variables.\n", Counter ); } // create the timeframes @@ -939,7 +939,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 free PI variables.\n", Counter ); + printf( "Warning: %d uninitialized latches are replaced by ABC_FREE PI variables.\n", Counter ); } // create the timeframes diff --git a/src/base/abci/abcMv.c b/src/base/abci/abcMv.c index 2858b8a7..dacd16b2 100644 --- a/src/base/abci/abcMv.c +++ b/src/base/abci/abcMv.c @@ -60,7 +60,7 @@ void Abc_MvExperiment() { Mv_Man_t * p; // get the functions - p = ALLOC( Mv_Man_t, 1 ); + p = ABC_ALLOC( Mv_Man_t, 1 ); memset( p, 0, sizeof(Mv_Man_t) ); p->dd = Cudd_Init( 32, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); p->nFuncs = 15; @@ -76,7 +76,7 @@ void Abc_MvExperiment() // remove the manager Abc_MvDeref( p ); Extra_StopManager( p->dd ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -349,7 +349,7 @@ void Abc_MvDecompose( Mv_Man_t * p ) printf( "%d ", Vec_PtrSize(vCofs) ); Vec_PtrFree( vCofs ); - // free the cofactors + // ABC_FREE the cofactors for ( v1 = 0; v1 < 4; v1++ ) for ( v2 = 0; v2 < 4; v2++ ) Cudd_RecursiveDeref( p->dd, bCofs[v1 * 4 + v2] ); diff --git a/src/base/abci/abcNtbdd.c b/src/base/abci/abcNtbdd.c index ed02f589..62256997 100644 --- a/src/base/abci/abcNtbdd.c +++ b/src/base/abci/abcNtbdd.c @@ -582,7 +582,7 @@ clk = clock(); printf( "The BDD before = %d.\n", Cudd_DagSize(bSum) ); Cudd_ReduceHeap( dd, CUDD_REORDER_SIFT, 1 ); printf( "The BDD after = %d.\n", Cudd_DagSize(bSum) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); Cudd_RecursiveDeref( dd, bSum ); Cudd_Quit( dd ); } diff --git a/src/base/abci/abcOdc.c b/src/base/abci/abcOdc.c index 989d551f..67b243b9 100644 --- a/src/base/abci/abcOdc.c +++ b/src/base/abci/abcOdc.c @@ -168,7 +168,7 @@ Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int f Odc_Man_t * p; unsigned * pData; int i, k; - p = ALLOC( Odc_Man_t, 1 ); + p = ABC_ALLOC( Odc_Man_t, 1 ); memset( p, 0, sizeof(Odc_Man_t) ); assert( nVarsMax > 4 && nVarsMax < 16 ); assert( nLevels > 0 && nLevels < 10 ); @@ -189,7 +189,7 @@ Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int f // internal AIG package // allocate room for objects p->nObjsAlloc = ABC_DC_MAX_NODES; - p->pObjs = ALLOC( Odc_Obj_t, p->nObjsAlloc * sizeof(Odc_Obj_t) ); + p->pObjs = ABC_ALLOC( Odc_Obj_t, p->nObjsAlloc * sizeof(Odc_Obj_t) ); p->nPis = nVarsMax + 32; p->nObjs = 1 + p->nPis; memset( p->pObjs, 0, p->nObjs * sizeof(Odc_Obj_t) ); @@ -198,7 +198,7 @@ Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int f p->pObjs[1 + p->nVarsMax + i].uMask = (1 << i); // allocate hash table p->nTableSize = p->nObjsAlloc/3 + 1; - p->pTable = ALLOC( Odc_Lit_t, p->nTableSize * sizeof(Odc_Lit_t) ); + p->pTable = ABC_ALLOC( Odc_Lit_t, p->nTableSize * sizeof(Odc_Lit_t) ); memset( p->pTable, 0, p->nTableSize * sizeof(Odc_Lit_t) ); p->vUsedSpots = Vec_IntAlloc( 1000 ); @@ -284,23 +284,23 @@ void Abc_NtkDontCareFree( Odc_Man_t * p ) printf( "Ave DCs per window = %6.2f %%. Ave DCs per finished window = %6.2f %%.\n", 1.0*p->nTotalDcs/p->nWins, 1.0*p->nTotalDcs/p->nWinsFinish ); printf( "Runtime stats of the ODC manager:\n" ); - PRT( "Cleaning ", p->timeClean ); - PRT( "Windowing ", p->timeWin ); - PRT( "Miter ", p->timeMiter ); - PRT( "Simulation ", p->timeSim ); - PRT( "Quantifying ", p->timeQuant ); - PRT( "Truth table ", p->timeTruth ); - PRT( "TOTAL ", p->timeTotal ); - PRT( "Aborted ", p->timeAbort ); + ABC_PRT( "Cleaning ", p->timeClean ); + ABC_PRT( "Windowing ", p->timeWin ); + ABC_PRT( "Miter ", p->timeMiter ); + ABC_PRT( "Simulation ", p->timeSim ); + ABC_PRT( "Quantifying ", p->timeQuant ); + ABC_PRT( "Truth table ", p->timeTruth ); + ABC_PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Aborted ", p->timeAbort ); } Vec_PtrFree( p->vRoots ); Vec_PtrFree( p->vBranches ); Vec_PtrFree( p->vTruths ); Vec_PtrFree( p->vTruthsElem ); Vec_IntFree( p->vUsedSpots ); - free( p->pObjs ); - free( p->pTable ); - free( p ); + ABC_FREE( p->pObjs ); + ABC_FREE( p->pTable ); + ABC_FREE( p ); } @@ -662,10 +662,10 @@ 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 *)(PORT_PTRUINT_T)((Odc_Const1() << 16) | Odc_Const0()); + return pNode->pCopy = (void *)(ABC_PTRUINT_T)((Odc_Const1() << 16) | Odc_Const0()); // compute the cofactors - uData0 = (unsigned)(PORT_PTRUINT_T)Abc_NtkDontCareTransfer_rec( p, Abc_ObjFanin0(pNode), pPivot ); - uData1 = (unsigned)(PORT_PTRUINT_T)Abc_NtkDontCareTransfer_rec( p, Abc_ObjFanin1(pNode), pPivot ); + 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 ); // find the 0-cofactor uLit0 = Odc_NotCond( (Odc_Lit_t)(uData0 & 0xffff), Abc_ObjFaninC0(pNode) ); uLit1 = Odc_NotCond( (Odc_Lit_t)(uData1 & 0xffff), Abc_ObjFaninC1(pNode) ); @@ -675,7 +675,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 *)(PORT_PTRUINT_T)((uRes1 << 16) | uRes0); + return pNode->pCopy = (void *)(ABC_PTRUINT_T)((uRes1 << 16) | uRes0); } /**Function************************************************************* @@ -701,21 +701,21 @@ int Abc_NtkDontCareTransfer( Odc_Man_t * p ) Vec_PtrForEachEntry( p->vLeaves, pObj, i ) { uLit = Odc_Var( p, i ); - pObj->pCopy = (void *)(PORT_PTRUINT_T)((uLit << 16) | uLit); + pObj->pCopy = (void *)(ABC_PTRUINT_T)((uLit << 16) | uLit); Abc_NodeSetTravIdCurrent(pObj); } // set elementary variables at the branched Vec_PtrForEachEntry( p->vBranches, pObj, i ) { uLit = Odc_Var( p, i+p->nVarsMax ); - pObj->pCopy = (void *)(PORT_PTRUINT_T)((uLit << 16) | uLit); + pObj->pCopy = (void *)(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 ) { - uData = (unsigned)(PORT_PTRUINT_T)Abc_NtkDontCareTransfer_rec( p, pObj, p->pNode ); + uData = (unsigned)(ABC_PTRUINT_T)Abc_NtkDontCareTransfer_rec( p, pObj, p->pNode ); // get the cofactors uRes0 = uData & 0xffff; uRes1 = uData >> 16; diff --git a/src/base/abci/abcPart.c b/src/base/abci/abcPart.c index a482e5c9..4c348b16 100644 --- a/src/base/abci/abcPart.c +++ b/src/base/abci/abcPart.c @@ -29,10 +29,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 free memory - int nFreeSize; // the size of remaining free memory + char * pFreeBuf; // the pointer to ABC_FREE memory + int nFreeSize; // the size of remaining ABC_FREE memory Vec_Ptr_t * vMemory; // the memory allocated - Vec_Ptr_t * vFree; // the vector of free pieces of memory + Vec_Ptr_t * vFree; // the vector of ABC_FREE pieces of memory }; typedef struct Supp_One_t_ Supp_One_t; @@ -66,7 +66,7 @@ static inline void Supp_OneSetNext( char * pPart, char * pNext ) { *((char **) Supp_Man_t * Supp_ManStart( int nChunkSize, int nStepSize ) { Supp_Man_t * p; - p = ALLOC( Supp_Man_t, 1 ); + p = ABC_ALLOC( Supp_Man_t, 1 ); memset( p, 0, sizeof(Supp_Man_t) ); p->nChunkSize = nChunkSize; p->nStepSize = nStepSize; @@ -91,10 +91,10 @@ void Supp_ManStop( Supp_Man_t * p ) void * pMemory; int i; Vec_PtrForEachEntry( p->vMemory, pMemory, i ) - free( pMemory ); + ABC_FREE( pMemory ); Vec_PtrFree( p->vMemory ); Vec_PtrFree( p->vFree ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -123,7 +123,7 @@ char * Supp_ManFetch( Supp_Man_t * p, int nSize ) nSizeReal = p->nStepSize * Type; if ( p->nFreeSize < nSizeReal ) { - p->pFreeBuf = ALLOC( char, p->nChunkSize ); + p->pFreeBuf = ABC_ALLOC( char, p->nChunkSize ); p->nFreeSize = p->nChunkSize; Vec_PtrPush( p->vMemory, p->pFreeBuf ); } @@ -321,9 +321,9 @@ Vec_Ptr_t * Abc_NtkComputeSupportsSmart( Abc_Ntk_t * pNtk ) int i; // set the number of PIs/POs Abc_NtkForEachCi( pNtk, pObj, i ) - pObj->pNext = (Abc_Obj_t *)(PORT_PTRINT_T)i; + pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i; Abc_NtkForEachCo( pNtk, pObj, i ) - pObj->pNext = (Abc_Obj_t *)(PORT_PTRINT_T)i; + pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i; // start the support computation manager p = Supp_ManStart( 1 << 20, 1 << 6 ); // consider objects in the topological order @@ -353,7 +353,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsSmart( Abc_Ntk_t * pNtk ) if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) ) { vSupp = Supp_ManTransferEntry(pPart0); - Vec_IntPush( vSupp, (int)(PORT_PTRINT_T)pObj->pNext ); + Vec_IntPush( vSupp, (int)(ABC_PTRINT_T)pObj->pNext ); Vec_PtrPush( vSupports, vSupp ); } assert( pPart0->nRefs > 0 ); @@ -366,7 +366,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsSmart( Abc_Ntk_t * pNtk ) if ( Abc_ObjFanoutNum(pObj) ) { pPart0 = (Supp_One_t *)Supp_ManFetchEntry( p, 1, Abc_ObjFanoutNum(pObj) ); - pPart0->pOuts[ pPart0->nOuts++ ] = (int)(PORT_PTRINT_T)pObj->pNext; + pPart0->pOuts[ pPart0->nOuts++ ] = (int)(ABC_PTRINT_T)pObj->pNext; pObj->pCopy = (Abc_Obj_t *)pPart0; } continue; @@ -417,7 +417,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 *)(PORT_PTRINT_T)i; + pObj->pNext = (void *)(ABC_PTRINT_T)i; // save the CI numbers vSupports = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) ); Abc_NtkForEachCo( pNtk, pObj, i ) @@ -427,7 +427,7 @@ Vec_Ptr_t * Abc_NtkComputeSupportsNaive( Abc_Ntk_t * pNtk ) vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 ); vSuppI = (Vec_Int_t *)vSupp; Vec_PtrForEachEntry( vSupp, pTemp, k ) - Vec_IntWriteEntry( vSuppI, k, (int)(PORT_PTRINT_T)pTemp->pNext ); + Vec_IntWriteEntry( vSuppI, k, (int)(ABC_PTRINT_T)pTemp->pNext ); Vec_IntSort( vSuppI, 0 ); // append the number of this output Vec_IntPush( vSuppI, i ); @@ -463,7 +463,7 @@ unsigned * Abc_NtkSuppCharStart( Vec_Int_t * vOne, int nPis ) unsigned * pBuffer; int i, Entry; int nWords = Abc_BitWordNum(nPis); - pBuffer = ALLOC( unsigned, nWords ); + pBuffer = ABC_ALLOC( unsigned, nWords ); memset( pBuffer, 0, sizeof(unsigned) * nWords ); Vec_IntForEachEntry( vOne, Entry, i ) { @@ -728,7 +728,7 @@ clk = clock(); vSupps = Abc_NtkComputeSupportsSmart( pNtk ); if ( fVerbose ) { -PRT( "Supps", clock() - clk ); +ABC_PRT( "Supps", clock() - clk ); } // start char-based support representation vPartSuppsChar = Vec_PtrAlloc( 1000 ); @@ -782,14 +782,14 @@ timeFind += clock() - clk2; // stop char-based support representation Vec_PtrForEachEntry( vPartSuppsChar, vTemp, i ) - free( vTemp ); + ABC_FREE( vTemp ); Vec_PtrFree( vPartSuppsChar ); //printf( "\n" ); if ( fVerbose ) { -PRT( "Parts", clock() - clk ); -//PRT( "Find ", timeFind ); +ABC_PRT( "Parts", clock() - clk ); +//ABC_PRT( "Find ", timeFind ); } clk = clock(); @@ -811,7 +811,7 @@ clk = clock(); if ( fVerbose ) { -PRT( "Comps", clock() - clk ); +ABC_PRT( "Comps", clock() - clk ); } if ( fVerbose ) printf( "Created %d partitions.\n", Vec_PtrSize(vPartsAll) ); @@ -1195,7 +1195,7 @@ void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams ) Abc_NtkDelete( pNtkAig ); Vec_PtrFree( vFraigs ); Vec_PtrFree( vOnePtr ); - PRT( "Partitioned fraiging time", clock() - clk ); + ABC_PRT( "Partitioned fraiging time", clock() - clk ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c index 0b1d8fc1..50b0c749 100644 --- a/src/base/abci/abcPrint.c +++ b/src/base/abci/abcPrint.c @@ -64,10 +64,10 @@ int Abc_NtkCompareAndSaveBest( Abc_Ntk_t * pNtk ) int nPis; // the number of primary inputs int nPos; // the number of primary outputs } ParsNew, ParsBest = { 0 }; - // free storage for the name + // ABC_FREE storage for the name if ( pNtk == NULL ) { - FREE( ParsBest.pName ); + ABC_FREE( ParsBest.pName ); return 0; } // quit if not a logic network @@ -86,7 +86,7 @@ int Abc_NtkCompareAndSaveBest( Abc_Ntk_t * pNtk ) (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops > ParsNew.Flops) || (ParsBest.Depth == ParsNew.Depth && ParsBest.Flops == ParsNew.Flops && ParsBest.Nodes > ParsNew.Nodes) ) { - FREE( ParsBest.pName ); + ABC_FREE( ParsBest.pName ); ParsBest.pName = Extra_UtilStrsav( pNtk->pName ); ParsBest.Depth = ParsNew.Depth; ParsBest.Flops = ParsNew.Flops; @@ -134,8 +134,9 @@ float Abc_NtkMfsTotalSwitching( Abc_Ntk_t * pNtk ) pSwitching = (float *)vSwitching->pArray; Abc_NtkForEachObj( pNtk, pObjAbc, i ) { - if ( (pObjAbc2 = Abc_ObjRegular(pObjAbc->pTemp)) && (pObjAig = pObjAbc2->pTemp) ) + if ( (pObjAbc2 = Abc_ObjRegular(pObjAbc->pTemp)) && (pObjAig = Aig_Regular(pObjAbc2->pTemp)) ) Result += Abc_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id]; +// Result += pSwitching[pObjAig->Id]; } Vec_IntFree( vSwitching ); Aig_ManStop( pAig ); @@ -154,7 +155,7 @@ 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 ) +void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDumpResult, int fUseLutLib, int fPrintMuxes, int fPower, int fGlitch ) { int Num; if ( fSaveBest ) @@ -165,7 +166,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSave 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 ) free( pNameGen ); + if ( pNtk->pSpec ) ABC_FREE( pNameGen ); } // if ( Abc_NtkIsStrash(pNtk) ) @@ -230,15 +231,33 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored, int fSave } if ( Abc_NtkIsStrash(pNtk) ) + { + extern int Abc_NtkGetMultiRefNum( Abc_Ntk_t * pNtk ); fprintf( pFile, " lev = %3d", Abc_AigLevel(pNtk) ); +// fprintf( pFile, " ff = %5d", Abc_NtkNodeNum(pNtk) + 2 * (Abc_NtkCoNum(pNtk)+Abc_NtkGetMultiRefNum(pNtk)) ); +// fprintf( pFile, " var = %5d", Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk)+Abc_NtkGetMultiRefNum(pNtk) ); + } else fprintf( pFile, " lev = %3d", Abc_NtkLevel(pNtk) ); if ( fUseLutLib && Abc_FrameReadLibLut() ) fprintf( pFile, " delay = %5.2f", Abc_NtkDelayTraceLut(pNtk, 1) ); if ( fPower ) fprintf( pFile, " power = %7.2f", Abc_NtkMfsTotalSwitching(pNtk) ); + if ( fGlitch ) + { + extern float Abc_NtkMfsTotalGlitching( Abc_Ntk_t * pNtk ); + if ( Abc_NtkIsLogic(pNtk) && Abc_NtkGetFaninMax(pNtk) <= 6 ) + fprintf( pFile, " glitch = %7.2f %%", Abc_NtkMfsTotalGlitching(pNtk) ); + else + printf( "\nCurrently computes glitching only for K-LUT networks with K <= 6." ); + } fprintf( pFile, "\n" ); + { + extern int Abc_NtkPrintSubraphSizes( Abc_Ntk_t * pNtk ); +// Abc_NtkPrintSubraphSizes( pNtk ); + } + // Abc_NtkCrossCut( pNtk ); // print the statistic into a file @@ -627,6 +646,13 @@ void Abc_NtkPrintFanioNew( FILE * pFile, Abc_Ntk_t * pNtk ) fprintf( pFile, "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n", nFaninsMax, 1.0*nFaninsAll/Abc_NtkNodeNum(pNtk), nFanoutsMax, 1.0*nFanoutsAll/Abc_NtkNodeNum(pNtk) ); +/* + Abc_NtkForEachCi( pNtk, pNode, i ) + { + printf( "%d ", Abc_ObjFanoutNum(pNode) ); + } + printf( "\n" ); +*/ } /**Function************************************************************* @@ -786,7 +812,7 @@ void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile, int fListN DelayMax = Abc_NtkDelayTrace( pNtk ); DelayDelta = DelayMax/nIntervals; // collect outputs by delay - pLevelCounts = ALLOC( int, nIntervals ); + pLevelCounts = ABC_ALLOC( int, nIntervals ); memset( pLevelCounts, 0, sizeof(int) * nIntervals ); Abc_NtkForEachCo( pNtk, pNode, i ) { @@ -805,7 +831,7 @@ void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile, int fListN printf( "[%8.2f - %8.2f] : COs = %4d. %5.1f %%\n", DelayDelta * i, DelayDelta * (i+1), pLevelCounts[i], 100.0 * nOutsSum/nOutsTotal ); } - free( pLevelCounts ); + ABC_FREE( pLevelCounts ); return; } else if ( fProfile ) @@ -820,7 +846,7 @@ void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile, int fListN Abc_NtkForEachCo( pNtk, pNode, i ) if ( LevelMax < (int)Abc_ObjFanin0(pNode)->Level ) LevelMax = Abc_ObjFanin0(pNode)->Level; - pLevelCounts = ALLOC( int, LevelMax + 1 ); + pLevelCounts = ABC_ALLOC( int, LevelMax + 1 ); memset( pLevelCounts, 0, sizeof(int) * (LevelMax + 1) ); Abc_NtkForEachCo( pNtk, pNode, i ) pLevelCounts[Abc_ObjFanin0(pNode)->Level]++; @@ -833,7 +859,7 @@ void Abc_NtkPrintLevel( FILE * pFile, Abc_Ntk_t * pNtk, int fProfile, int fListN nOutsSum += pLevelCounts[i]; printf( "Level = %4d. COs = %4d. %5.1f %%\n", i, pLevelCounts[i], 100.0 * nOutsSum/nOutsTotal ); } - free( pLevelCounts ); + ABC_FREE( pLevelCounts ); return; } assert( Abc_NtkIsStrash(pNtk) ); @@ -1188,6 +1214,152 @@ void Abc_ObjPrint( FILE * pFile, Abc_Obj_t * pObj ) } +/**Function************************************************************* + + Synopsis [Checks the status of the miter.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Abc_NtkPrintMiter( Abc_Ntk_t * pNtk ) +{ + Abc_Obj_t * pObj, * pChild, * pConst1 = Abc_AigConst1(pNtk); + int i, iOut = -1, Time = clock(); + int nUnsat = 0; + int nSat = 0; + int nUndec = 0; + int nPis = 0; + Abc_NtkForEachPi( pNtk, pObj, i ) + nPis += (int)( Abc_ObjFanoutNum(pObj) > 0 ); + Abc_NtkForEachPo( pNtk, pObj, i ) + { + pChild = Abc_ObjChild0(pObj); + // check if the output is constant 0 + if ( pChild == Abc_ObjNot(pConst1) ) + nUnsat++; + // check if the output is constant 1 + else if ( pChild == pConst1 ) + { + nSat++; + if ( iOut == -1 ) + iOut = i; + } + // check if the output is a primary input + else if ( Abc_ObjIsPi(Abc_ObjRegular(pChild)) ) + { + nSat++; + if ( iOut == -1 ) + iOut = i; + } + // check if the output is 1 for the 0000 pattern + else if ( Abc_ObjRegular(pChild)->fPhase != (unsigned)Abc_ObjIsComplement(pChild) ) + { + nSat++; + if ( iOut == -1 ) + iOut = i; + } + else + nUndec++; + } + printf( "Miter: I =%6d", nPis ); + printf( " N =%7d", Abc_NtkNodeNum(pNtk) ); + printf( " ? =%7d", nUndec ); + printf( " U =%6d", nUnsat ); + printf( " S =%6d", nSat ); + Time = clock() - Time; + printf(" %7.2f sec\n", (float)(Time)/(float)(CLOCKS_PER_SEC)); + if ( iOut >= 0 ) + printf( "The first satisfiable output is number %d (%d).\n", iOut, Abc_ObjName( Abc_NtkPo(pNtk, iOut) ) ); +} + + + + +typedef struct Gli_Man_t_ Gli_Man_t; + +extern Gli_Man_t * Gli_ManAlloc( int nObjs, int nRegs, int nFanioPairs ); +extern void Gli_ManStop( Gli_Man_t * p ); +extern int Gli_ManCreateCi( Gli_Man_t * p, int nFanouts ); +extern int Gli_ManCreateCo( Gli_Man_t * p, int iFanin ); +extern int Gli_ManCreateNode( Gli_Man_t * p, Vec_Int_t * vFanins, int nFanouts, unsigned * puTruth ); + +extern void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb, int fVerbose ); +extern int Gli_ObjNumSwitches( Gli_Man_t * p, int iNode ); +extern int Gli_ObjNumGlitches( Gli_Man_t * p, int iNode ); + +/**Function************************************************************* + + Synopsis [Returns the percentable of increased power due to glitching.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +float Abc_NtkMfsTotalGlitching( Abc_Ntk_t * pNtk ) +{ + int nSwitches, nGlitches; + Gli_Man_t * p; + Vec_Ptr_t * vNodes; + Vec_Int_t * vFanins, * vTruth; + Abc_Obj_t * pObj, * pFanin; + unsigned * puTruth; + int i, k; + assert( Abc_NtkIsLogic(pNtk) ); + assert( Abc_NtkGetFaninMax(pNtk) <= 6 ); + if ( Abc_NtkGetFaninMax(pNtk) > 6 ) + { + printf( "Abc_NtkMfsTotalGlitching() This procedure works only for mapped networks with LUTs size up to 6 inputs.\n" ); + return -1.0; + } + Abc_NtkToAig( pNtk ); + vNodes = Abc_NtkDfs( pNtk, 0 ); + vFanins = Vec_IntAlloc( 6 ); + vTruth = Vec_IntAlloc( 1 << 12 ); + + // derive network for glitch computation + p = Gli_ManAlloc( Vec_PtrSize(vNodes) + Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk), + Abc_NtkLatchNum(pNtk), Abc_NtkGetTotalFanins(pNtk) + Abc_NtkCoNum(pNtk) ); + Abc_NtkForEachObj( pNtk, pObj, i ) + pObj->iTemp = -1; + Abc_NtkForEachCi( pNtk, pObj, i ) + pObj->iTemp = Gli_ManCreateCi( p, Abc_ObjFanoutNum(pObj) ); + Vec_PtrForEachEntry( 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 ); + pObj->iTemp = Gli_ManCreateNode( p, vFanins, Abc_ObjFanoutNum(pObj), puTruth ); + } + Abc_NtkForEachCo( pNtk, pObj, i ) + Gli_ManCreateCo( p, Abc_ObjFanin0(pObj)->iTemp ); + + // compute glitching + Gli_ManSwitchesAndGlitches( p, 4000, 1.0/8.0, 0 ); + + // compute the ratio + nSwitches = nGlitches = 0; + Abc_NtkForEachObj( pNtk, pObj, i ) + if ( pObj->iTemp >= 0 ) + { + nSwitches += Abc_ObjFanoutNum(pObj) * Gli_ObjNumSwitches(p, pObj->iTemp); + nGlitches += Abc_ObjFanoutNum(pObj) * Gli_ObjNumGlitches(p, pObj->iTemp); + } + + Gli_ManStop( p ); + Vec_PtrFree( vNodes ); + Vec_IntFree( vTruth ); + Vec_IntFree( vFanins ); + return nSwitches ? 100.0*(nGlitches-nSwitches)/nSwitches : 0.0; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/abci/abcProve.c b/src/base/abci/abcProve.c index 6a695fc4..5a546ab1 100644 --- a/src/base/abci/abcProve.c +++ b/src/base/abci/abcProve.c @@ -29,7 +29,7 @@ extern int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool fUpdateLevel, bool fUseZeros, bool fUseDcs, bool 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, sint64 nInspLimit, int * pRetValue, int * pNumFails, sint64 * pNumConfs, sint64 * pNumInspects ); +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 ); static void Abc_NtkMiterPrint( Abc_Ntk_t * pNtk, char * pString, int clk, int fVerbose ); @@ -56,7 +56,7 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars ) Prove_Params_t * pParams = pPars; Abc_Ntk_t * pNtk, * pNtkTemp; int RetValue = -1, nIter, nSatFails, Counter, clk; //, timeStart = clock(); - sint64 nSatConfs, nSatInspects, nInspectLimit; + ABC_INT64_T nSatConfs, nSatInspects, nInspectLimit; // get the starting network pNtk = *ppNtk; @@ -77,7 +77,7 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars ) if ( !pParams->fUseRewriting && !pParams->fUseFraiging ) { clk = clock(); - RetValue = Abc_NtkMiterSat( pNtk, (sint64)pParams->nMiteringLimitLast, (sint64)0, 0, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)pParams->nMiteringLimitLast, (ABC_INT64_T)0, 0, NULL, NULL ); Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose ); *ppNtk = pNtk; return RetValue; @@ -97,7 +97,7 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars ) // try brute-force SAT clk = clock(); nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0; - RetValue = Abc_NtkMiterSat( pNtk, (sint64)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)), (sint64)nInspectLimit, 0, &nSatConfs, &nSatInspects ); + RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)(pParams->nMiteringLimitStart * pow(pParams->nMiteringLimitMulti,nIter)), (ABC_INT64_T)nInspectLimit, 0, &nSatConfs, &nSatInspects ); Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose ); if ( RetValue >= 0 ) break; @@ -211,14 +211,14 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars ) } clk = clock(); nInspectLimit = pParams->nTotalInspectLimit? pParams->nTotalInspectLimit - pParams->nTotalInspectsMade : 0; - RetValue = Abc_NtkMiterSat( pNtk, (sint64)pParams->nMiteringLimitLast, (sint64)nInspectLimit, 0, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pNtk, (ABC_INT64_T)pParams->nMiteringLimitLast, (ABC_INT64_T)nInspectLimit, 0, NULL, NULL ); Abc_NtkMiterPrint( pNtk, "SAT solving", clk, pParams->fVerbose ); } // assign the model if it was proved by rewriting (const 1 miter) if ( RetValue == 0 && pNtk->pModel == NULL ) { - pNtk->pModel = ALLOC( int, Abc_NtkCiNum(pNtk) ); + pNtk->pModel = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) ); memset( pNtk->pModel, 0, sizeof(int) * Abc_NtkCiNum(pNtk) ); } *ppNtk = pNtk; @@ -236,7 +236,7 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars ) SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Abc_NtkMiterFraig( Abc_Ntk_t * pNtk, int nBTLimit, sint64 nInspLimit, int * pRetValue, int * pNumFails, sint64 * pNumConfs, sint64 * pNumInspects ) +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 ) { Abc_Ntk_t * pNtkNew; Fraig_Params_t Params, * pParams = &Params; @@ -275,8 +275,8 @@ Abc_Ntk_t * Abc_NtkMiterFraig( Abc_Ntk_t * pNtk, int nBTLimit, sint64 nInspLimit if ( RetValue == 0 ) { pModel = Fraig_ManReadModel( pMan ); - FREE( pNtkNew->pModel ); - pNtkNew->pModel = ALLOC( int, Abc_NtkCiNum(pNtkNew) ); + ABC_FREE( pNtkNew->pModel ); + pNtkNew->pModel = ABC_ALLOC( int, Abc_NtkCiNum(pNtkNew) ); memcpy( pNtkNew->pModel, pModel, sizeof(int) * Abc_NtkCiNum(pNtkNew) ); } @@ -308,7 +308,7 @@ void Abc_NtkMiterPrint( Abc_Ntk_t * pNtk, char * pString, int clk, int fVerbose return; printf( "Nodes = %7d. Levels = %4d. ", Abc_NtkNodeNum(pNtk), Abc_NtkIsStrash(pNtk)? Abc_AigLevel(pNtk) : Abc_NtkLevel(pNtk) ); - PRT( pString, clock() - clk ); + ABC_PRT( pString, clock() - clk ); } diff --git a/src/base/abci/abcQbf.c b/src/base/abci/abcQbf.c index b839f812..fe6ef895 100644 --- a/src/base/abci/abcQbf.c +++ b/src/base/abci/abcQbf.c @@ -140,8 +140,8 @@ clkV = clock() - clkV; printf( "AIG = %6d ", Abc_NtkNodeNum(pNtkSyn) ); Abc_NtkVectorPrintVars( pNtk, vPiValues, nPars ); printf( " " ); -// PRTn( "Syn", clkS ); - PRT( "Ver", clkV ); +// ABC_PRTn( "Syn", clkS ); + ABC_PRT( "Ver", clkV ); } } Abc_NtkDelete( pNtkSyn ); @@ -157,7 +157,7 @@ clkV = clock() - clkV; printf( "Unsolved after %d interations. ", nIters ); else printf( "Implementation does not exist. " ); - PRT( "Total runtime", clock() - clkTotal ); + ABC_PRT( "Total runtime", clock() - clkTotal ); Vec_IntFree( vPiValues ); } diff --git a/src/base/abci/abcQuant.c b/src/base/abci/abcQuant.c index 24981d1c..6d973a85 100644 --- a/src/base/abci/abcQuant.c +++ b/src/base/abci/abcQuant.c @@ -41,6 +41,8 @@ ***********************************************************************/ void Abc_NtkSynthesize( Abc_Ntk_t ** ppNtk, int fMoreEffort ) { + extern Abc_Ntk_t * Abc_NtkIvyFraig( Abc_Ntk_t * pNtk, int nConfLimit, int fDoSparse, int fProve, int fTransfer, int fVerbose ); + Abc_Ntk_t * pNtk, * pNtkTemp; pNtk = *ppNtk; @@ -56,6 +58,9 @@ void Abc_NtkSynthesize( Abc_Ntk_t ** ppNtk, int fMoreEffort ) Abc_NtkRefactor( pNtk, 10, 16, 0, 0, 0, 0 ); pNtk = Abc_NtkBalance( pNtkTemp = pNtk, 0, 0, 0 ); Abc_NtkDelete( pNtkTemp ); + + pNtk = Abc_NtkIvyFraig( pNtkTemp = pNtk, 100, 1, 0, 0, 0 ); + Abc_NtkDelete( pNtkTemp ); } *ppNtk = pNtk; @@ -384,7 +389,7 @@ Abc_Ntk_t * Abc_NtkReachability( Abc_Ntk_t * pNtkRel, int nIters, int fVerbose ) { printf( "I = %3d : Reach = %6d Fr = %6d FrM = %6d %7.2f %% ", i + 1, Abc_NtkNodeNum(pNtkReached), nNodesOld, nNodesNew, 100.0*(nNodesNew-nNodesPrev)/nNodesPrev ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); } nNodesPrev = Abc_NtkNodeNum(pNtkFront); } diff --git a/src/base/abci/abcReach.c b/src/base/abci/abcReach.c index 815e452a..3834c00d 100644 --- a/src/base/abci/abcReach.c +++ b/src/base/abci/abcReach.c @@ -47,8 +47,8 @@ DdNode * Abc_NtkInitStateVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbose int i; // set the variable mapping for Cudd_bddVarMap() - pbVarsX = ALLOC( DdNode *, dd->size ); - pbVarsY = ALLOC( DdNode *, dd->size ); + pbVarsX = ABC_ALLOC( DdNode *, dd->size ); + pbVarsY = ABC_ALLOC( DdNode *, dd->size ); bProd = b1; Cudd_Ref( bProd ); Abc_NtkForEachLatch( pNtk, pLatch, i ) { @@ -60,8 +60,8 @@ DdNode * Abc_NtkInitStateVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbose Cudd_RecursiveDeref( dd, bTemp ); } Cudd_SetVarMap( dd, pbVarsX, pbVarsY, Abc_NtkLatchNum(pNtk) ); - FREE( pbVarsX ); - FREE( pbVarsY ); + ABC_FREE( pbVarsX ); + ABC_FREE( pbVarsY ); Cudd_Deref( bProd ); return bProd; @@ -96,13 +96,13 @@ DdNode ** Abc_NtkCreatePartitions( DdManager * dd, Abc_Ntk_t * pNtk, int fReorde Cudd_AutodynDisable( dd ); // compute the transition relation - pbParts = ALLOC( DdNode *, Abc_NtkLatchNum(pNtk) ); + pbParts = ABC_ALLOC( DdNode *, Abc_NtkLatchNum(pNtk) ); Abc_NtkForEachLatch( pNtk, pNode, i ) { bVar = Cudd_bddIthVar( dd, Abc_NtkCiNum(pNtk) + i ); pbParts[i] = Cudd_bddXnor( dd, bVar, Abc_ObjGlobalBdd(Abc_ObjFanin0(pNode)) ); Cudd_Ref( pbParts[i] ); } - // free the global BDDs + // ABC_FREE the global BDDs Abc_NtkFreeGlobalBdds( pNtk, 0 ); // reorder and disable reordering @@ -143,7 +143,7 @@ DdNode * Abc_NtkComputeReachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode ** pb // collect the NS variables // set the variable mapping for Cudd_bddVarMap() - pbVarsY = ALLOC( DdNode *, dd->size ); + pbVarsY = ABC_ALLOC( DdNode *, dd->size ); Abc_NtkForEachLatch( pNtk, pLatch, i ) pbVarsY[i] = dd->vars[ Abc_NtkCiNum(pNtk) + i ]; @@ -153,7 +153,7 @@ DdNode * Abc_NtkComputeReachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode ** pb pTree = Extra_bddImageStart( dd, bCubeCs, Abc_NtkLatchNum(pNtk), pbParts, Abc_NtkLatchNum(pNtk), pbVarsY, fVerbose ); else pTree2 = Extra_bddImageStart2( dd, bCubeCs, Abc_NtkLatchNum(pNtk), pbParts, Abc_NtkLatchNum(pNtk), pbVarsY, fVerbose ); - free( pbVarsY ); + ABC_FREE( pbVarsY ); Cudd_RecursiveDeref( dd, bCubeCs ); // perform reachability analisys @@ -230,7 +230,7 @@ DdNode * Abc_NtkComputeReachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode ** pb fprintf( stdout, "Reachable states = %.0f. (Ratio = %.4f %%)\n", nMints, 100.0*nMints/pow(2.0, Abc_NtkLatchNum(pNtk)) ); fflush( stdout ); } -//PRB( dd, bReached ); +//ABC_PRB( dd, bReached ); Cudd_Deref( bReached ); if ( nIters > nIterMax || Cudd_DagSize(bReached) > nBddMax ) printf( "Verified ONLY FOR STATES REACHED in %d iterations. \n", nIters ); @@ -298,11 +298,11 @@ void Abc_NtkVerifyUsingBdds( Abc_Ntk_t * pNtk, int nBddMax, int nIterMax, int fP Cudd_RecursiveDeref( dd, bInitial ); for ( i = 0; i < Abc_NtkLatchNum(pNtk); i++ ) Cudd_RecursiveDeref( dd, pbParts[i] ); - free( pbParts ); + ABC_FREE( pbParts ); Extra_StopManager( dd ); // report the runtime - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); fflush( stdout ); } diff --git a/src/base/abci/abcRec.c b/src/base/abci/abcRec.c index 2983efc2..d8884147 100644 --- a/src/base/abci/abcRec.c +++ b/src/base/abci/abcRec.c @@ -184,7 +184,7 @@ void Abc_NtkRecStart( Abc_Ntk_t * pNtk, int nVars, int nCuts ) Abc_NtkCleanEquiv( pNtk ); // start the manager - p = ALLOC( Abc_ManRec_t, 1 ); + p = ABC_ALLOC( Abc_ManRec_t, 1 ); memset( p, 0, sizeof(Abc_ManRec_t) ); p->pNtk = pNtk; p->nVars = Abc_NtkPiNum(pNtk); @@ -206,7 +206,7 @@ void Abc_NtkRecStart( Abc_Ntk_t * pNtk, int nVars, int nCuts ) // create hash table p->nBins = 50011; - p->pBins = ALLOC( Abc_Obj_t *, p->nBins ); + p->pBins = ABC_ALLOC( Abc_Obj_t *, p->nBins ); memset( p->pBins, 0, sizeof(Abc_Obj_t *) * p->nBins ); // set elementary tables @@ -251,10 +251,10 @@ p->timeTruth += clock() - clk; } // temporaries - p->pBytes = ALLOC( int, 4*p->nWords ); - p->pMints = ALLOC( int, 2*p->nVars ); - p->pTemp1 = ALLOC( unsigned, p->nWords ); - p->pTemp2 = ALLOC( unsigned, p->nWords ); + p->pBytes = ABC_ALLOC( int, 4*p->nWords ); + p->pMints = ABC_ALLOC( int, 2*p->nVars ); + p->pTemp1 = ABC_ALLOC( unsigned, p->nWords ); + p->pTemp2 = ABC_ALLOC( unsigned, p->nWords ); p->vNodes = Vec_PtrAlloc( 100 ); p->vTtTemps = Vec_PtrAllocSimInfo( 64, p->nWords ); p->vMemory = Vec_IntAlloc( Abc_TruthWordNum(p->nVars) * 1000 ); @@ -282,13 +282,13 @@ void Abc_NtkRecStop() Abc_NtkDelete( s_pMan->pNtk ); Vec_PtrFree( s_pMan->vTtNodes ); Vec_PtrFree( s_pMan->vTtElems ); - free( s_pMan->pBins ); + ABC_FREE( s_pMan->pBins ); // temporaries - free( s_pMan->pBytes ); - free( s_pMan->pMints ); - free( s_pMan->pTemp1 ); - free( s_pMan->pTemp2 ); + ABC_FREE( s_pMan->pBytes ); + ABC_FREE( s_pMan->pMints ); + ABC_FREE( s_pMan->pTemp1 ); + ABC_FREE( s_pMan->pTemp2 ); Vec_PtrFree( s_pMan->vNodes ); Vec_PtrFree( s_pMan->vTtTemps ); if ( s_pMan->vLabels ) @@ -297,7 +297,7 @@ void Abc_NtkRecStop() Vec_StrFree( s_pMan->vCosts ); Vec_IntFree( s_pMan->vMemory ); - free( s_pMan ); + ABC_FREE( s_pMan ); s_pMan = NULL; } @@ -396,11 +396,11 @@ void Abc_NtkRecPs() printf( "Functions added = %8d. (%6.2f %%)\n", p->nAddedFuncs, !p->nTried? 0 : 100.0*p->nAddedFuncs/p->nTried ); p->timeOther = p->timeTotal - p->timeCollect - p->timeTruth - p->timeCanon; - PRTP( "Collecting nodes ", p->timeCollect, p->timeTotal ); - PRTP( "Computing truth ", p->timeTruth, p->timeTotal ); - PRTP( "Canonicizing ", p->timeCanon, p->timeTotal ); - PRTP( "Other ", p->timeOther, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + ABC_PRTP( "Collecting nodes ", p->timeCollect, p->timeTotal ); + ABC_PRTP( "Computing truth ", p->timeTruth, p->timeTotal ); + ABC_PRTP( "Canonicizing ", p->timeCanon, p->timeTotal ); + ABC_PRTP( "Other ", p->timeOther, p->timeTotal ); + ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); if ( p->nFunsFound ) printf( "During rewriting found = %d and not found = %d functions.\n", p->nFunsFound, p->nFunsNotFound ); } diff --git a/src/base/abci/abcReconv.c b/src/base/abci/abcReconv.c index 078aee9d..1c086fb0 100644 --- a/src/base/abci/abcReconv.c +++ b/src/base/abci/abcReconv.c @@ -584,7 +584,7 @@ DdNode * Abc_NodeConeDcs( DdManager * dd, DdNode ** pbVarsX, DdNode ** pbVarsY, Abc_ManCut_t * Abc_NtkManCutStart( int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop ) { Abc_ManCut_t * p; - p = ALLOC( Abc_ManCut_t, 1 ); + p = ABC_ALLOC( Abc_ManCut_t, 1 ); memset( p, 0, sizeof(Abc_ManCut_t) ); p->vNodeLeaves = Vec_PtrAlloc( 100 ); p->vConeLeaves = Vec_PtrAlloc( 100 ); @@ -616,7 +616,7 @@ void Abc_NtkManCutStop( Abc_ManCut_t * p ) Vec_PtrFree( p->vVisited ); Vec_VecFree( p->vLevels ); Vec_PtrFree( p->vNodesTfo ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/base/abci/abcRefactor.c b/src/base/abci/abcRefactor.c index 821bd66b..5245bd23 100644 --- a/src/base/abci/abcRefactor.c +++ b/src/base/abci/abcRefactor.c @@ -245,7 +245,7 @@ p->timeSop += clock() - clk; // get the factored form clk = clock(); pFForm = Dec_Factor( pSop ); - free( pSop ); + ABC_FREE( pSop ); p->timeFact += clock() - clk; // mark the fanin boundary @@ -310,7 +310,7 @@ p->timeEval += clock() - clk; Abc_ManRef_t * Abc_NtkManRefStart( int nNodeSizeMax, int nConeSizeMax, bool fUseDcs, bool fVerbose ) { Abc_ManRef_t * p; - p = ALLOC( Abc_ManRef_t, 1 ); + p = ABC_ALLOC( Abc_ManRef_t, 1 ); memset( p, 0, sizeof(Abc_ManRef_t) ); p->vCube = Vec_StrAlloc( 100 ); p->vVisited = Vec_PtrAlloc( 100 ); @@ -342,7 +342,7 @@ void Abc_NtkManRefStop( Abc_ManRef_t * p ) Extra_StopManager( p->dd ); Vec_PtrFree( p->vVisited ); Vec_StrFree( p->vCube ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -362,15 +362,15 @@ void Abc_NtkManRefPrintStats( Abc_ManRef_t * p ) printf( "Nodes considered = %8d.\n", p->nNodesConsidered ); printf( "Nodes refactored = %8d.\n", p->nNodesRefactored ); printf( "Gain = %8d. (%6.2f %%).\n", p->nNodesBeg-p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg ); - PRT( "Cuts ", p->timeCut ); - PRT( "Resynthesis", p->timeRes ); - PRT( " BDD ", p->timeBdd ); - PRT( " DCs ", p->timeDcs ); - PRT( " SOP ", p->timeSop ); - PRT( " FF ", p->timeFact ); - PRT( " Eval ", p->timeEval ); - PRT( "AIG update ", p->timeNtk ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Cuts ", p->timeCut ); + ABC_PRT( "Resynthesis", p->timeRes ); + ABC_PRT( " BDD ", p->timeBdd ); + ABC_PRT( " DCs ", p->timeDcs ); + ABC_PRT( " SOP ", p->timeSop ); + ABC_PRT( " FF ", p->timeFact ); + ABC_PRT( " Eval ", p->timeEval ); + ABC_PRT( "AIG update ", p->timeNtk ); + ABC_PRT( "TOTAL ", p->timeTotal ); } diff --git a/src/base/abci/abcReorder.c b/src/base/abci/abcReorder.c index 182780cd..340e3d17 100644 --- a/src/base/abci/abcReorder.c +++ b/src/base/abci/abcReorder.c @@ -46,7 +46,7 @@ void Abc_NodeBddReorder( reo_man * p, Abc_Obj_t * pNode ) DdNode * bFunc; int * pOrder, i; // create the temporary array for the variable order - pOrder = ALLOC( int, Abc_ObjFaninNum(pNode) ); + pOrder = ABC_ALLOC( int, Abc_ObjFaninNum(pNode) ); for ( i = 0; i < Abc_ObjFaninNum(pNode); i++ ) pOrder[i] = -1; // reorder the BDD @@ -58,7 +58,7 @@ void Abc_NodeBddReorder( reo_man * p, Abc_Obj_t * pNode ) pOrder[i] = pNode->vFanins.pArray[ pOrder[i] ]; Abc_ObjForEachFanin( pNode, pFanin, i ) pNode->vFanins.pArray[i] = pOrder[i]; - free( pOrder ); + ABC_FREE( pOrder ); } /**Function************************************************************* diff --git a/src/base/abci/abcRestruct.c b/src/base/abci/abcRestruct.c index 2550e02c..26774620 100644 --- a/src/base/abci/abcRestruct.c +++ b/src/base/abci/abcRestruct.c @@ -990,7 +990,7 @@ Cut_Man_t * Abc_NtkStartCutManForRestruct( Abc_Ntk_t * pNtk, int nCutMax, int fD Abc_ManRst_t * Abc_NtkManRstStart( int nCutMax, bool fUpdateLevel, bool fUseZeros, bool fVerbose ) { Abc_ManRst_t * p; - p = ALLOC( Abc_ManRst_t, 1 ); + p = ABC_ALLOC( Abc_ManRst_t, 1 ); memset( p, 0, sizeof(Abc_ManRst_t) ); // set the parameters p->nCutMax = nCutMax; @@ -1045,7 +1045,7 @@ void Abc_NtkManRstStop( Abc_ManRst_t * p ) Vec_IntFree( p->vBinate ); Vec_IntFree( p->vTwos ); Vec_IntFree( p->vRands ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -1067,13 +1067,13 @@ void Abc_NtkManRstPrintStats( Abc_ManRst_t * p ) printf( "Cuts explored = %8d.\n", p->nCutsExplored ); printf( "Nodes restructured = %8d.\n", p->nNodesRestructured ); printf( "Calculated gain = %8d.\n", p->nNodesGained ); - PRT( "Cuts ", p->timeCut ); - PRT( "Resynthesis", p->timeRes ); - PRT( " BDD ", p->timeBdd ); - PRT( " DSD ", p->timeDsd ); - PRT( " Eval ", p->timeEval ); - PRT( "AIG update ", p->timeNtk ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Cuts ", p->timeCut ); + ABC_PRT( "Resynthesis", p->timeRes ); + ABC_PRT( " BDD ", p->timeBdd ); + ABC_PRT( " DSD ", p->timeDsd ); + ABC_PRT( " Eval ", p->timeEval ); + ABC_PRT( "AIG update ", p->timeNtk ); + ABC_PRT( "TOTAL ", p->timeTotal ); } @@ -1201,16 +1201,16 @@ void Abc_NodeMffcSimulate( Vec_Ptr_t * vDecs, int nLeaves, Vec_Int_t * vRands, V Vec_PtrForEachEntryStop( vDecs, pObj, i, nLeaves ) { uData = (unsigned)Vec_IntEntry( vRands, i ); - pObj->pData = (void *)(PORT_PTRUINT_T)uData; + pObj->pData = (void *)(ABC_PTRUINT_T)uData; Vec_IntPush( vSims, uData ); } // simulate Vec_PtrForEachEntryStart( vDecs, pObj, i, nLeaves ) { - uData0 = (unsigned)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; - uData1 = (unsigned)(PORT_PTRUINT_T)Abc_ObjFanin1(pObj)->pData; + uData0 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; + uData1 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin1(pObj)->pData; uData = (Abc_ObjFaninC0(pObj)? ~uData0 : uData0) & (Abc_ObjFaninC1(pObj)? ~uData1 : uData1); - pObj->pData = (void *)(PORT_PTRUINT_T)uData; + pObj->pData = (void *)(ABC_PTRUINT_T)uData; Vec_IntPush( vSims, uData ); } } diff --git a/src/base/abci/abcResub.c b/src/base/abci/abcResub.c index 80532b14..861a5e66 100644 --- a/src/base/abci/abcResub.c +++ b/src/base/abci/abcResub.c @@ -293,7 +293,7 @@ Abc_ManRes_t * Abc_ManResubStart( int nLeavesMax, int nDivsMax ) unsigned * pData; int i, k; assert( sizeof(unsigned) == 4 ); - p = ALLOC( Abc_ManRes_t, 1 ); + p = ABC_ALLOC( Abc_ManRes_t, 1 ); memset( p, 0, sizeof(Abc_ManRes_t) ); p->nLeavesMax = nLeavesMax; p->nDivsMax = nDivsMax; @@ -301,7 +301,7 @@ Abc_ManRes_t * Abc_ManResubStart( int nLeavesMax, int nDivsMax ) // allocate simulation info p->nBits = (1 << p->nLeavesMax); p->nWords = (p->nBits <= 32)? 1 : (p->nBits / 32); - p->pInfo = ALLOC( unsigned, p->nWords * (p->nDivsMax + 1) ); + p->pInfo = ABC_ALLOC( unsigned, p->nWords * (p->nDivsMax + 1) ); memset( p->pInfo, 0, sizeof(unsigned) * p->nWords * p->nLeavesMax ); p->vSims = Vec_PtrAlloc( p->nDivsMax ); for ( i = 0; i < p->nDivsMax; i++ ) @@ -352,8 +352,8 @@ void Abc_ManResubStop( Abc_ManRes_t * p ) Vec_PtrFree( p->vDivs2UN0 ); Vec_PtrFree( p->vDivs2UN1 ); Vec_PtrFree( p->vTemp ); - free( p->pInfo ); - free( p ); + ABC_FREE( p->pInfo ); + ABC_FREE( p ); } /**Function************************************************************* @@ -369,16 +369,16 @@ void Abc_ManResubStop( Abc_ManRes_t * p ) ***********************************************************************/ void Abc_ManResubPrint( Abc_ManRes_t * p ) { - printf( "Used constants = %6d. ", p->nUsedNodeC ); PRT( "Cuts ", p->timeCut ); - printf( "Used replacements = %6d. ", p->nUsedNode0 ); PRT( "Resub ", p->timeRes ); - printf( "Used single ORs = %6d. ", p->nUsedNode1Or ); PRT( " Div ", p->timeDiv ); - printf( "Used single ANDs = %6d. ", p->nUsedNode1And ); PRT( " Mffc ", p->timeMffc ); - printf( "Used double ORs = %6d. ", p->nUsedNode2Or ); PRT( " Sim ", p->timeSim ); - printf( "Used double ANDs = %6d. ", p->nUsedNode2And ); PRT( " 1 ", p->timeRes1 ); - printf( "Used OR-AND = %6d. ", p->nUsedNode2OrAnd ); PRT( " D ", p->timeResD ); - printf( "Used AND-OR = %6d. ", p->nUsedNode2AndOr ); PRT( " 2 ", p->timeRes2 ); - printf( "Used OR-2ANDs = %6d. ", p->nUsedNode3OrAnd ); PRT( "Truth ", p->timeTruth ); //PRT( " 3 ", p->timeRes3 ); - printf( "Used AND-2ORs = %6d. ", p->nUsedNode3AndOr ); PRT( "AIG ", p->timeNtk ); + printf( "Used constants = %6d. ", p->nUsedNodeC ); ABC_PRT( "Cuts ", p->timeCut ); + printf( "Used replacements = %6d. ", p->nUsedNode0 ); ABC_PRT( "Resub ", p->timeRes ); + printf( "Used single ORs = %6d. ", p->nUsedNode1Or ); ABC_PRT( " Div ", p->timeDiv ); + printf( "Used single ANDs = %6d. ", p->nUsedNode1And ); ABC_PRT( " Mffc ", p->timeMffc ); + printf( "Used double ORs = %6d. ", p->nUsedNode2Or ); ABC_PRT( " Sim ", p->timeSim ); + printf( "Used double ANDs = %6d. ", p->nUsedNode2And ); ABC_PRT( " 1 ", p->timeRes1 ); + printf( "Used OR-AND = %6d. ", p->nUsedNode2OrAnd ); ABC_PRT( " D ", p->timeResD ); + printf( "Used AND-OR = %6d. ", p->nUsedNode2AndOr ); ABC_PRT( " 2 ", p->timeRes2 ); + printf( "Used OR-2ANDs = %6d. ", p->nUsedNode3OrAnd ); ABC_PRT( "Truth ", p->timeTruth ); //ABC_PRT( " 3 ", p->timeRes3 ); + printf( "Used AND-2ORs = %6d. ", p->nUsedNode3AndOr ); ABC_PRT( "AIG ", p->timeNtk ); printf( "TOTAL = %6d. ", p->nUsedNodeC + p->nUsedNode0 + p->nUsedNode1Or + @@ -389,7 +389,7 @@ void Abc_ManResubPrint( Abc_ManRes_t * p ) p->nUsedNode2AndOr + p->nUsedNode3OrAnd + p->nUsedNode3AndOr - ); PRT( "TOTAL ", p->timeTotal ); + ); ABC_PRT( "TOTAL ", p->timeTotal ); printf( "Total leaves = %8d.\n", p->nTotalLeaves ); printf( "Total divisors = %8d.\n", p->nTotalDivs ); // printf( "Total gain = %8d.\n", p->nTotalGain ); diff --git a/src/base/abci/abcRewrite.c b/src/base/abci/abcRewrite.c index ff1e1f8b..a119ccd2 100644 --- a/src/base/abci/abcRewrite.c +++ b/src/base/abci/abcRewrite.c @@ -168,7 +168,7 @@ Rwr_ManAddTimeTotal( pManRwr, clock() - clkStart ); { // int clk = clock(); Abc_NtkReassignIds( pNtk ); -// PRT( "time", clock() - clk ); +// ABC_PRT( "time", clock() - clk ); } // Abc_AigCheckFaninOrder( pNtk->pManFunc ); // fix the levels diff --git a/src/base/abci/abcRr.c b/src/base/abci/abcRr.c index 888850e1..9fbad080 100644 --- a/src/base/abci/abcRr.c +++ b/src/base/abci/abcRr.c @@ -244,14 +244,14 @@ int Abc_NtkRR( Abc_Ntk_t * pNtk, int nFaninLevels, int nFanoutLevels, int fUseFa Abc_RRMan_t * Abc_RRManStart() { Abc_RRMan_t * p; - p = ALLOC( Abc_RRMan_t, 1 ); + p = ABC_ALLOC( Abc_RRMan_t, 1 ); memset( p, 0, sizeof(Abc_RRMan_t) ); p->vFaninLeaves = Vec_PtrAlloc( 100 ); // the leaves of the fanin cone p->vFanoutRoots = Vec_PtrAlloc( 100 ); // the roots of the fanout cone p->vLeaves = Vec_PtrAlloc( 100 ); // the leaves of the window p->vCone = Vec_PtrAlloc( 100 ); // the internal nodes of the window p->vRoots = Vec_PtrAlloc( 100 ); // the roots of the window - p->pParams = ALLOC( Prove_Params_t, 1 ); + p->pParams = ABC_ALLOC( Prove_Params_t, 1 ); memset( p->pParams, 0, sizeof(Prove_Params_t) ); Prove_ParamsSetDefault( p->pParams ); return p; @@ -276,8 +276,8 @@ void Abc_RRManStop( Abc_RRMan_t * p ) Vec_PtrFree( p->vLeaves ); Vec_PtrFree( p->vCone ); Vec_PtrFree( p->vRoots ); - free( p->pParams ); - free( p ); + ABC_FREE( p->pParams ); + ABC_FREE( p ); } /**Function************************************************************* @@ -299,12 +299,12 @@ void Abc_RRManPrintStats( Abc_RRMan_t * p ) printf( "Edges removed = %6d. (%5.2f %%)\n", p->nEdgesRemoved, 100.0*p->nEdgesRemoved/p->nEdgesTried ); printf( "Node gain = %6d. (%5.2f %%)\n", p->nNodesOld - Abc_NtkNodeNum(p->pNtk), Ratio ); printf( "Level gain = %6d.\n", p->nLevelsOld - Abc_AigLevel(p->pNtk) ); - PRT( "Windowing ", p->timeWindow ); - PRT( "Miter ", p->timeMiter ); - PRT( " Construct ", p->timeMiter - p->timeProve ); - PRT( " Prove ", p->timeProve ); - PRT( "Update ", p->timeUpdate ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Windowing ", p->timeWindow ); + ABC_PRT( "Miter ", p->timeMiter ); + ABC_PRT( " Construct ", p->timeMiter - p->timeProve ); + ABC_PRT( " Prove ", p->timeProve ); + ABC_PRT( "Update ", p->timeUpdate ); + ABC_PRT( "TOTAL ", p->timeTotal ); } /**Function************************************************************* @@ -729,16 +729,16 @@ void Abc_NtkRRSimulateStart( Abc_Ntk_t * pNtk ) int i; Abc_AigConst1(pNtk)->pData = (void *)~((unsigned)0); Abc_NtkForEachCi( pNtk, pObj, i ) - pObj->pData = (void *)(PORT_PTRUINT_T)SIM_RANDOM_UNSIGNED; + pObj->pData = (void *)(ABC_PTRUINT_T)SIM_RANDOM_UNSIGNED; Abc_NtkForEachNode( pNtk, pObj, i ) { if ( i == 0 ) continue; - uData0 = (unsigned)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; - uData1 = (unsigned)(PORT_PTRUINT_T)Abc_ObjFanin1(pObj)->pData; + uData0 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; + uData1 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin1(pObj)->pData; uData = Abc_ObjFaninC0(pObj)? ~uData0 : uData0; uData &= Abc_ObjFaninC1(pObj)? ~uData1 : uData1; assert( pObj->pData == NULL ); - pObj->pData = (void *)(PORT_PTRUINT_T)uData; + pObj->pData = (void *)(ABC_PTRUINT_T)uData; } } @@ -802,24 +802,24 @@ Vec_Str_t * Abc_NtkRRSimulate( Abc_Ntk_t * pNtk ) // simulate patters and store them in copy Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)~((unsigned)0); Abc_NtkForEachCi( pNtk, pObj, i ) - pObj->pCopy = (Abc_Obj_t *)(PORT_PTRUINT_T)SIM_RANDOM_UNSIGNED; + pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)SIM_RANDOM_UNSIGNED; Abc_NtkForEachNode( pNtk, pObj, i ) { if ( i == 0 ) continue; - uData0 = (unsigned)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; - uData1 = (unsigned)(PORT_PTRUINT_T)Abc_ObjFanin1(pObj)->pData; + uData0 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; + uData1 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin1(pObj)->pData; uData = Abc_ObjFaninC0(pObj)? ~uData0 : uData0; uData &= Abc_ObjFaninC1(pObj)? ~uData1 : uData1; - pObj->pCopy = (Abc_Obj_t *)(PORT_PTRUINT_T)uData; + pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)uData; } // store the result in data Abc_NtkForEachCo( pNtk, pObj, i ) { - uData0 = (unsigned)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; + uData0 = (unsigned)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pData; if ( Abc_ObjFaninC0(pObj) ) - pObj->pData = (void *)(PORT_PTRUINT_T)~uData0; + pObj->pData = (void *)(ABC_PTRUINT_T)~uData0; else - pObj->pData = (void *)(PORT_PTRUINT_T)uData0; + pObj->pData = (void *)(ABC_PTRUINT_T)uData0; } // refine the candidates @@ -904,7 +904,7 @@ void Sim_CollectNodes_rec( Abc_Obj_t * pRoot, Vec_Ptr_t * vField ) Abc_ObjForEachFanin( pRoot, pFanin, i ) Sim_CollectNodes_rec( pFanin, vField ); if ( !Abc_ObjIsCo(pRoot) ) - pRoot->pData = (void *)(PORT_PTRUINT_T)Vec_PtrSize(vField); + pRoot->pData = (void *)(ABC_PTRUINT_T)Vec_PtrSize(vField); Vec_PtrPush( vField, pRoot ); } @@ -934,13 +934,13 @@ void Sim_SimulateCollected( Vec_Str_t * vTargets, Vec_Ptr_t * vNodes, Vec_Ptr_t { pUnsigned = Vec_PtrEntry( vSims, i ); for ( k = 0; k < Vec_PtrSize(vNodes); k++ ) - pUnsigned[k] = (unsigned)(PORT_PTRUINT_T)pObj->pCopy; + pUnsigned[k] = (unsigned)(ABC_PTRUINT_T)pObj->pCopy; continue; } if ( Abc_ObjIsCo(pObj) ) { pUnsigned = Vec_PtrEntry( vSims, i ); - pUnsignedF = Vec_PtrEntry( vSims, (int)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pData ); + pUnsignedF = 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]; @@ -950,7 +950,7 @@ void Sim_SimulateCollected( Vec_Str_t * vTargets, Vec_Ptr_t * vNodes, Vec_Ptr_t // update targets for ( k = 0; k < Vec_PtrSize(vNodes); k++ ) { - if ( pUnsigned[k] == (unsigned)(PORT_PTRUINT_T)pObj->pData ) + if ( pUnsigned[k] == (unsigned)(ABC_PTRUINT_T)pObj->pData ) continue; pDisproved = Vec_PtrEntry( vNodes, k ); fCompl = Abc_ObjIsComplement(pDisproved); diff --git a/src/base/abci/abcSat.c b/src/base/abci/abcSat.c index 025652fe..3cee19ca 100644 --- a/src/base/abci/abcSat.c +++ b/src/base/abci/abcSat.c @@ -44,7 +44,7 @@ static int nMuxes; SeeAlso [] ***********************************************************************/ -int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int fVerbose, sint64 * pNumConfs, sint64 * pNumInspects ) +int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T * pNumConfs, ABC_INT64_T * pNumInspects ) { sat_solver * pSat; lbool status; @@ -70,13 +70,13 @@ int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int //return 1; // printf( "Created SAT problem with %d variable and %d clauses. ", sat_solver_nvars(pSat), sat_solver_nclauses(pSat) ); -// PRT( "Time", clock() - clk ); +// ABC_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 ); +// ABC_PRT( "Time", clock() - clk ); if ( status == 0 ) { sat_solver_delete( pSat ); @@ -88,7 +88,7 @@ int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int clk = clock(); if ( fVerbose ) pSat->verbosity = 1; - status = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfLimit, (sint64)nInsLimit, (sint64)0, (sint64)0 ); + 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" ); @@ -106,7 +106,7 @@ int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int } else assert( 0 ); -// PRT( "SAT sat_solver time", clock() - clk ); +// ABC_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 @@ -117,7 +117,7 @@ int Abc_NtkMiterSat( Abc_Ntk_t * pNtk, sint64 nConfLimit, sint64 nInsLimit, int pNtk->pModel = Sat_SolverGetModel( pSat, vCiIds->pArray, vCiIds->nSize ); Vec_IntFree( vCiIds ); } - // free the sat_solver + // ABC_FREE the sat_solver if ( fVerbose ) Sat_SolverPrintStats( stdout, pSat ); @@ -151,7 +151,7 @@ Vec_Int_t * Abc_NtkGetCiSatVarNums( Abc_Ntk_t * pNtk ) int i; vCiIds = Vec_IntAlloc( Abc_NtkCiNum(pNtk) ); Abc_NtkForEachCi( pNtk, pObj, i ) - Vec_IntPush( vCiIds, (int)(PORT_PTRINT_T)pObj->pCopy ); + Vec_IntPush( vCiIds, (int)(ABC_PTRINT_T)pObj->pCopy ); return vCiIds; } @@ -172,7 +172,7 @@ int Abc_NtkClauseTriv( sat_solver * pSat, Abc_Obj_t * pNode, Vec_Int_t * vVars ) { //printf( "Adding triv %d. %d\n", Abc_ObjRegular(pNode)->Id, (int)pSat->sat_solver_stats.clauses ); vVars->nSize = 0; - Vec_IntPush( vVars, toLitCond( (int)(PORT_PTRINT_T)Abc_ObjRegular(pNode)->pCopy, Abc_ObjIsComplement(pNode) ) ); + 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 ); } @@ -195,7 +195,7 @@ int Abc_NtkClauseTop( sat_solver * pSat, Vec_Ptr_t * vNodes, Vec_Int_t * vVars ) //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_IntPush( vVars, toLitCond( (int)(PORT_PTRINT_T)Abc_ObjRegular(pNode)->pCopy, Abc_ObjIsComplement(pNode) ) ); + 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 ); } @@ -220,7 +220,7 @@ int Abc_NtkClauseAnd( sat_solver * pSat, Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, assert( Abc_ObjIsNode( pNode ) ); // nVars = sat_solver_nvars(pSat); - Var = (int)(PORT_PTRINT_T)pNode->pCopy; + Var = (int)(ABC_PTRINT_T)pNode->pCopy; // Var = pNode->Id; // assert( Var < nVars ); @@ -230,7 +230,7 @@ int Abc_NtkClauseAnd( sat_solver * pSat, Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, // get the complemented attributes of the nodes fComp1 = Abc_ObjIsComplement(vSuper->pArray[i]); // determine the variable numbers - Var1 = (int)(PORT_PTRINT_T)Abc_ObjRegular(vSuper->pArray[i])->pCopy; + Var1 = (int)(ABC_PTRINT_T)Abc_ObjRegular(vSuper->pArray[i])->pCopy; // Var1 = (int)Abc_ObjRegular(vSuper->pArray[i])->Id; // check that the variables are in the SAT manager @@ -255,7 +255,7 @@ int Abc_NtkClauseAnd( sat_solver * pSat, Abc_Obj_t * pNode, Vec_Ptr_t * vSuper, // get the complemented attributes of the nodes fComp1 = Abc_ObjIsComplement(vSuper->pArray[i]); // determine the variable numbers - Var1 = (int)(PORT_PTRINT_T)Abc_ObjRegular(vSuper->pArray[i])->pCopy; + Var1 = (int)(ABC_PTRINT_T)Abc_ObjRegular(vSuper->pArray[i])->pCopy; // Var1 = (int)Abc_ObjRegular(vSuper->pArray[i])->Id; // add this variable to the array Vec_IntPush( vVars, toLitCond(Var1, !fComp1) ); @@ -283,10 +283,10 @@ int Abc_NtkClauseMux( sat_solver * pSat, Abc_Obj_t * pNode, Abc_Obj_t * pNodeC, assert( !Abc_ObjIsComplement( pNode ) ); assert( Abc_NodeIsMuxType( pNode ) ); // get the variable numbers - VarF = (int)(PORT_PTRINT_T)pNode->pCopy; - VarI = (int)(PORT_PTRINT_T)pNodeC->pCopy; - VarT = (int)(PORT_PTRINT_T)Abc_ObjRegular(pNodeT)->pCopy; - VarE = (int)(PORT_PTRINT_T)Abc_ObjRegular(pNodeE)->pCopy; + VarF = (int)(ABC_PTRINT_T)pNode->pCopy; + VarI = (int)(ABC_PTRINT_T)pNodeC->pCopy; + VarT = (int)(ABC_PTRINT_T)Abc_ObjRegular(pNodeT)->pCopy; + VarE = (int)(ABC_PTRINT_T)Abc_ObjRegular(pNodeE)->pCopy; // VarF = (int)pNode->Id; // VarI = (int)pNodeC->Id; // VarT = (int)Abc_ObjRegular(pNodeT)->Id; @@ -479,7 +479,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk ) // add the clause for the constant node pNode = Abc_AigConst1(pNtk); pNode->fMarkA = 1; - pNode->pCopy = (Abc_Obj_t *)(PORT_PTRINT_T)vNodes->nSize; + pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)vNodes->nSize; Vec_PtrPush( vNodes, pNode ); Abc_NtkClauseTriv( pSat, pNode, vVars ); /* @@ -501,7 +501,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk ) if ( pFanin->fMarkA == 0 ) { pFanin->fMarkA = 1; - pFanin->pCopy = (Abc_Obj_t *)(PORT_PTRINT_T)vNodes->nSize; + pFanin->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)vNodes->nSize; Vec_PtrPush( vNodes, pFanin ); } // add the trivial clause @@ -536,7 +536,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk ) if ( pFanin->fMarkA == 0 ) { pFanin->fMarkA = 1; - pFanin->pCopy = (Abc_Obj_t *)(PORT_PTRINT_T)vNodes->nSize; + pFanin->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)vNodes->nSize; Vec_PtrPush( vNodes, pFanin ); } } @@ -555,7 +555,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk ) if ( pFanin->fMarkA == 0 ) { pFanin->fMarkA = 1; - pFanin->pCopy = (Abc_Obj_t *)(PORT_PTRINT_T)vNodes->nSize; + pFanin->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)vNodes->nSize; Vec_PtrPush( vNodes, pFanin ); } } @@ -577,7 +577,7 @@ int Abc_NtkMiterSatCreateInt( sat_solver * pSat, Abc_Ntk_t * pNtk ) // set preferred variables if ( fOrderCiVarsFirst ) { - int * pPrefVars = ALLOC( int, Abc_NtkCiNum(pNtk) ); + int * pPrefVars = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) ); int nVars = 0; Abc_NtkForEachCi( pNtk, pNode, i ) { @@ -644,7 +644,7 @@ sat_solver_store_mark_roots( pSat ); return NULL; } // printf( "Ands = %6d. Muxes = %6d (%5.2f %%). ", Abc_NtkNodeNum(pNtk), nMuxes, 300.0*nMuxes/Abc_NtkNodeNum(pNtk) ); -// PRT( "Creating sat_solver", clock() - clk ); +// ABC_PRT( "Creating sat_solver", clock() - clk ); return pSat; } @@ -840,7 +840,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 *)(PORT_PTRINT_T)pNode->Id; + pNode->pCopy = (void *)(ABC_PTRINT_T)pNode->Id; // start the data structures pSat = sat_solver_new(); @@ -945,9 +945,9 @@ void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens ) Abc_NtkForEachObj( pNtk, pObj, i ) pObj->pCopy = (void *)~0; Abc_NtkForEachPi( pNtk, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRINT_T)Counter++; + pObj->pCopy = (void *)(ABC_PTRINT_T)Counter++; Vec_PtrForEachEntry( vNodes, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRINT_T)Counter++; + pObj->pCopy = (void *)(ABC_PTRINT_T)Counter++; /* OutVar = pCnf->pVarNums[ pObj->Id ]; @@ -975,14 +975,14 @@ void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens ) Vec_PtrForEachEntry( vNodes, pObj, i ) { // positive phase - fprintf( pFile, "%d %s%d %s%d 0\n", 1+(int)(PORT_PTRINT_T)pObj->pCopy, - Abc_ObjFaninC0(pObj)? "" : "-", 1+(int)(PORT_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy, - Abc_ObjFaninC1(pObj)? "" : "-", 1+(int)(PORT_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy ); + fprintf( pFile, "%d %s%d %s%d 0\n", 1+(int)(ABC_PTRINT_T)pObj->pCopy, + Abc_ObjFaninC0(pObj)? "" : "-", 1+(int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy, + Abc_ObjFaninC1(pObj)? "" : "-", 1+(int)(ABC_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy ); // negative phase - fprintf( pFile, "-%d %s%d 0\n", 1+(int)(PORT_PTRINT_T)pObj->pCopy, - Abc_ObjFaninC0(pObj)? "-" : "", 1+(int)(PORT_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy ); - fprintf( pFile, "-%d %s%d 0\n", 1+(int)(PORT_PTRINT_T)pObj->pCopy, - Abc_ObjFaninC1(pObj)? "-" : "", 1+(int)(PORT_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy ); + fprintf( pFile, "-%d %s%d 0\n", 1+(int)(ABC_PTRINT_T)pObj->pCopy, + Abc_ObjFaninC0(pObj)? "-" : "", 1+(int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy ); + fprintf( pFile, "-%d %s%d 0\n", 1+(int)(ABC_PTRINT_T)pObj->pCopy, + Abc_ObjFaninC1(pObj)? "-" : "", 1+(int)(ABC_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy ); } Vec_PtrFree( vNodes ); @@ -992,10 +992,10 @@ void Abc_NtkWriteSorterCnf( char * pFileName, int nVars, int nQueens ) */ // assert the first literal to zero fprintf( pFile, "%s%d 0\n", - Abc_ObjFaninC0(ppNodes[0])? "" : "-", 1+(int)(PORT_PTRINT_T)Abc_ObjFanin0(ppNodes[0])->pCopy ); + Abc_ObjFaninC0(ppNodes[0])? "" : "-", 1+(int)(ABC_PTRINT_T)Abc_ObjFanin0(ppNodes[0])->pCopy ); // assert the second literal to one fprintf( pFile, "%s%d 0\n", - Abc_ObjFaninC0(ppNodes[1])? "-" : "", 1+(int)(PORT_PTRINT_T)Abc_ObjFanin0(ppNodes[1])->pCopy ); + Abc_ObjFaninC0(ppNodes[1])? "-" : "", 1+(int)(ABC_PTRINT_T)Abc_ObjFanin0(ppNodes[1])->pCopy ); fclose( pFile ); } diff --git a/src/base/abci/abcSense.c b/src/base/abci/abcSense.c index a1e5b98a..3e68f0fd 100644 --- a/src/base/abci/abcSense.c +++ b/src/base/abci/abcSense.c @@ -184,7 +184,7 @@ Vec_Int_t * Abc_NtkSensitivity( Abc_Ntk_t * pNtk, int nConfLim, int fVerbose ) printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" ); // else // printf( "Networks are NOT EQUIVALENT.\n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); Vec_IntPush( vResult, i ); } Abc_NtkDelete( pMiter ); diff --git a/src/base/abci/abcStrash.c b/src/base/abci/abcStrash.c index a7c9f609..114288ba 100644 --- a/src/base/abci/abcStrash.c +++ b/src/base/abci/abcStrash.c @@ -325,7 +325,7 @@ void Abc_NtkStrashPerform( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew, int fAllNod // vNodes = Abc_NtkDfs( pNtkOld, fAllNodes ); vNodes = Abc_NtkDfsIter( pNtkOld, fAllNodes ); //printf( "Nodes = %d. ", Vec_PtrSize(vNodes) ); -//PRT( "Time", clock() - clk ); +//ABC_PRT( "Time", clock() - clk ); // pProgress = Extra_ProgressBarStart( stdout, vNodes->nSize ); Vec_PtrForEachEntry( vNodes, pNodeOld, i ) { @@ -385,6 +385,7 @@ Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, int fReco if ( Abc_NodeIsConst(pNodeOld) || Hop_Regular(pRoot) == Hop_ManConst1(pMan) ) return Abc_ObjNotCond( Abc_AigConst1(pNtkNew), Hop_IsComplement(pRoot) ); // perform special case-strashing using the record of AIG subgraphs +/* if ( fRecord && Abc_NtkRecIsRunning() && Abc_ObjFaninNum(pNodeOld) > 2 && Abc_ObjFaninNum(pNodeOld) <= Abc_NtkRecVarNum() ) { extern Vec_Int_t * Abc_NtkRecMemory(); @@ -398,6 +399,7 @@ Abc_Obj_t * Abc_NodeStrash( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, int fReco if ( Abc_NtkRecStrashNode( pNtkNew, pNodeOld, pTruth, nVars ) ) return pNodeOld->pCopy; } +*/ // set elementary variables Abc_ObjForEachFanin( pNodeOld, pFanin, i ) Hop_IthVar(pMan, i)->pData = pFanin->pCopy; diff --git a/src/base/abci/abcSweep.c b/src/base/abci/abcSweep.c index 2b78ceae..d1f4d4f7 100644 --- a/src/base/abci/abcSweep.c +++ b/src/base/abci/abcSweep.c @@ -111,7 +111,7 @@ bool Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, Abc_NtkFraigTransform( pNtk, tEquiv, fUseInv, fVerbose ); stmm_free_table( tEquiv ); - // free the manager + // ABC_FREE the manager Fraig_ManFree( pMan ); Abc_NtkDelete( pNtkAig ); @@ -835,7 +835,7 @@ int Abc_NtkLatchSweep( Abc_Ntk_t * pNtk ) /**Function************************************************************* - Synopsis [Replaces autonumnous logic by free inputs.] + Synopsis [Replaces autonumnous logic by ABC_FREE inputs.] Description [Assumes that non-autonomous logic is marked with the current ID.] diff --git a/src/base/abci/abcSymm.c b/src/base/abci/abcSymm.c index 0f76065c..73f238f9 100644 --- a/src/base/abci/abcSymm.c +++ b/src/base/abci/abcSymm.c @@ -105,9 +105,9 @@ clkSym = clock() - clk; printf( "Statistics of BDD-based symmetry detection:\n" ); printf( "Algorithm = %s. Reordering = %s. Garbage collection = %s.\n", fNaive? "naive" : "fast", fReorder? "yes" : "no", fGarbCollect? "yes" : "no" ); -PRT( "Constructing BDDs", clkBdd ); -PRT( "Computing symms ", clkSym ); -PRT( "TOTAL ", clkBdd + clkSym ); +ABC_PRT( "Constructing BDDs", clkBdd ); +ABC_PRT( "Computing symms ", clkSym ); +ABC_PRT( "TOTAL ", clkBdd + clkSym ); } /**Function************************************************************* @@ -177,7 +177,7 @@ void Ntk_NetworkSymmsPrint( Abc_Ntk_t * pNtk, Extra_SymmInfo_t * pSymms ) pInputNames = Abc_NtkCollectCioNames( pNtk, 0 ); // alloc the array of marks - pVarTaken = ALLOC( int, nVars ); + pVarTaken = ABC_ALLOC( int, nVars ); memset( pVarTaken, 0, sizeof(int) * nVars ); // print the groups @@ -217,8 +217,8 @@ void Ntk_NetworkSymmsPrint( Abc_Ntk_t * pNtk, Extra_SymmInfo_t * pSymms ) } printf( "\n" ); - free( pInputNames ); - free( pVarTaken ); + ABC_FREE( pInputNames ); + ABC_FREE( pVarTaken ); } diff --git a/src/base/abci/abcTiming.c b/src/base/abci/abcTiming.c index be16da95..36e56e7b 100644 --- a/src/base/abci/abcTiming.c +++ b/src/base/abci/abcTiming.c @@ -320,7 +320,7 @@ void Abc_NtkTimePrepare( Abc_Ntk_t * pNtk ) Abc_ManTime_t * Abc_ManTimeStart() { Abc_ManTime_t * p; - p = ALLOC( Abc_ManTime_t, 1 ); + p = ABC_ALLOC( Abc_ManTime_t, 1 ); memset( p, 0, sizeof(Abc_ManTime_t) ); p->vArrs = Vec_PtrAlloc( 0 ); p->vReqs = Vec_PtrAlloc( 0 ); @@ -342,15 +342,15 @@ void Abc_ManTimeStop( Abc_ManTime_t * p ) { if ( p->vArrs->nSize > 0 ) { - free( p->vArrs->pArray[0] ); + ABC_FREE( p->vArrs->pArray[0] ); Vec_PtrFree( p->vArrs ); } if ( p->vReqs->nSize > 0 ) { - free( p->vReqs->pArray[0] ); + ABC_FREE( p->vReqs->pArray[0] ); Vec_PtrFree( p->vReqs ); } - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -420,7 +420,7 @@ void Abc_ManTimeExpand( Abc_ManTime_t * p, int nSize, int fProgressive ) Vec_PtrGrow( vTimes, nSizeNew ); vTimes->nSize = nSizeNew; ppTimesOld = ( nSizeOld == 0 )? NULL : vTimes->pArray[0]; - ppTimes = REALLOC( Abc_Time_t, ppTimesOld, nSizeNew ); + 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++ ) @@ -435,7 +435,7 @@ void Abc_ManTimeExpand( Abc_ManTime_t * p, int nSize, int fProgressive ) Vec_PtrGrow( vTimes, nSizeNew ); vTimes->nSize = nSizeNew; ppTimesOld = ( nSizeOld == 0 )? NULL : vTimes->pArray[0]; - ppTimes = REALLOC( Abc_Time_t, ppTimesOld, nSizeNew ); + 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++ ) @@ -496,7 +496,7 @@ Abc_Time_t * Abc_NtkGetCiArrivalTimes( Abc_Ntk_t * pNtk ) Abc_Time_t * p; Abc_Obj_t * pNode; int i; - p = ALLOC( Abc_Time_t, Abc_NtkCiNum(pNtk) ); + p = ABC_ALLOC( Abc_Time_t, Abc_NtkCiNum(pNtk) ); memset( p, 0, sizeof(Abc_Time_t) * Abc_NtkCiNum(pNtk) ); if ( pNtk->pManTime == NULL ) return p; @@ -523,7 +523,7 @@ float * Abc_NtkGetCiArrivalFloats( Abc_Ntk_t * pNtk ) float * p; Abc_Obj_t * pNode; int i; - p = ALLOC( float, Abc_NtkCiNum(pNtk) ); + p = ABC_ALLOC( float, Abc_NtkCiNum(pNtk) ); memset( p, 0, sizeof(float) * Abc_NtkCiNum(pNtk) ); if ( pNtk->pManTime == NULL ) return p; diff --git a/src/base/abci/abcUnate.c b/src/base/abci/abcUnate.c index 20804d19..f6ee57ca 100644 --- a/src/base/abci/abcUnate.c +++ b/src/base/abci/abcUnate.c @@ -121,9 +121,9 @@ clkUnate = clock() - clk - clkBdd; // print stats printf( "Ins/Outs = %4d/%4d. Total supp = %5d. Total unate = %5d.\n", Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), TotalSupps, TotalUnate ); - PRT( "Glob BDDs", clkBdd ); - PRT( "Unateness", clkUnate ); - PRT( "Total ", clock() - clk ); + ABC_PRT( "Glob BDDs", clkBdd ); + ABC_PRT( "Unateness", clkUnate ); + ABC_PRT( "Total ", clock() - clk ); // deref the PO functions // Abc_NtkFreeGlobalBdds( pNtk ); diff --git a/src/base/abci/abcUnreach.c b/src/base/abci/abcUnreach.c index ea0a4cd2..196ff643 100644 --- a/src/base/abci/abcUnreach.c +++ b/src/base/abci/abcUnreach.c @@ -143,7 +143,7 @@ DdNode * Abc_NtkTransitionRelation( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo Cudd_RecursiveDeref( dd, bTemp ); Cudd_RecursiveDeref( dd, bProd ); } - // free the global BDDs + // ABC_FREE the global BDDs // Abc_NtkFreeGlobalBdds( pNtk ); Abc_NtkFreeGlobalBdds( pNtk, 0 ); @@ -186,8 +186,8 @@ DdNode * Abc_NtkInitStateAndVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo int i; // set the variable mapping for Cudd_bddVarMap() - pbVarsX = ALLOC( DdNode *, dd->size ); - pbVarsY = ALLOC( DdNode *, dd->size ); + pbVarsX = ABC_ALLOC( DdNode *, dd->size ); + pbVarsY = ABC_ALLOC( DdNode *, dd->size ); bProd = b1; Cudd_Ref( bProd ); Abc_NtkForEachLatch( pNtk, pLatch, i ) { @@ -199,8 +199,8 @@ DdNode * Abc_NtkInitStateAndVarMap( DdManager * dd, Abc_Ntk_t * pNtk, int fVerbo Cudd_RecursiveDeref( dd, bTemp ); } Cudd_SetVarMap( dd, pbVarsX, pbVarsY, Abc_NtkLatchNum(pNtk) ); - FREE( pbVarsX ); - FREE( pbVarsY ); + ABC_FREE( pbVarsX ); + ABC_FREE( pbVarsY ); Cudd_Deref( bProd ); return bProd; @@ -262,7 +262,7 @@ DdNode * Abc_NtkComputeUnreachable( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * b fprintf( stdout, "Reachability analysis completed in %d iterations.\n", nIters ); fprintf( stdout, "The number of minterms in the reachable state set = %d. (%6.2f %%)\n", nMints, 100.0*nMints/(1<pCopy ); // create the logic function - pPermute = ALLOC( int, dd->size ); + pPermute = ABC_ALLOC( int, dd->size ); for ( i = 0; i < dd->size; i++ ) pPermute[i] = -1; 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 ); - free( pPermute ); + ABC_FREE( pPermute ); Abc_NodeMinimumBase( pNodeNew ); // for each CO, create PO (skip POs equal to CIs because of name conflict) diff --git a/src/base/abci/abcVerify.c b/src/base/abci/abcVerify.c index 1131f119..60197d29 100644 --- a/src/base/abci/abcVerify.c +++ b/src/base/abci/abcVerify.c @@ -65,7 +65,7 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nI // report the error pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, 1 ); Abc_NtkVerifyReportError( pNtk1, pNtk2, pMiter->pModel ); - FREE( pMiter->pModel ); + ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return; } @@ -86,7 +86,7 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nI } // solve the CNF using the SAT solver - RetValue = Abc_NtkMiterSat( pCnf, (sint64)nConfLimit, (sint64)nInsLimit, 0, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pCnf, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, 0, NULL, NULL ); if ( RetValue == -1 ) printf( "Networks are undecided (SAT solver timed out).\n" ); else if ( RetValue == 0 ) @@ -95,7 +95,7 @@ void Abc_NtkCecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nI printf( "Networks are equivalent after SAT.\n" ); if ( pCnf->pModel ) Abc_NtkVerifyReportError( pNtk1, pNtk2, pCnf->pModel ); - FREE( pCnf->pModel ); + ABC_FREE( pCnf->pModel ); Abc_NtkDelete( pCnf ); } @@ -133,7 +133,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fV // report the error pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, 1 ); Abc_NtkVerifyReportError( pNtk1, pNtk2, pMiter->pModel ); - FREE( pMiter->pModel ); + ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return; } @@ -187,7 +187,7 @@ void Abc_NtkCecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int fV printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" ); else printf( "Networks are NOT EQUIVALENT.\n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); } else printf( "Networks are equivalent.\n" ); @@ -238,7 +238,7 @@ void Abc_NtkCecFraigPart( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, in // report the error pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, 1 ); Abc_NtkVerifyReportError( pNtk1, pNtk2, pMiter->pModel ); - FREE( pMiter->pModel ); + ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return; } @@ -287,7 +287,7 @@ void Abc_NtkCecFraigPart( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, in printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" ); else printf( "Networks are NOT EQUIVALENT. \n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); Status = 0; break; } @@ -355,7 +355,7 @@ void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds // report the error pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, 1 ); Abc_NtkVerifyReportError( pNtk1, pNtk2, pMiter->pModel ); - FREE( pMiter->pModel ); + ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return; } @@ -412,7 +412,7 @@ void Abc_NtkCecFraigPartAuto( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds printf( "ERROR in Abc_NtkMiterProve(): Generated counter-example is invalid.\n" ); else printf( "Networks are NOT EQUIVALENT. \n" ); - free( pSimInfo ); + ABC_FREE( pSimInfo ); Status = 0; Abc_NtkDelete( pMiterPart ); break; @@ -509,7 +509,7 @@ void Abc_NtkSecSat( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nConfLimit, int nI } // solve the CNF using the SAT solver - RetValue = Abc_NtkMiterSat( pCnf, (sint64)nConfLimit, (sint64)nInsLimit, 0, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pCnf, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, 0, NULL, NULL ); if ( RetValue == -1 ) printf( "Networks are undecided (SAT solver timed out).\n" ); else if ( RetValue == 0 ) @@ -552,7 +552,7 @@ int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFr // report the error pMiter->pModel = Abc_NtkVerifyGetCleanModel( pMiter, nFrames ); Abc_NtkVerifyReportErrorSeq( pNtk1, pNtk2, pMiter->pModel, nFrames ); - FREE( pMiter->pModel ); + ABC_FREE( pMiter->pModel ); Abc_NtkDelete( pMiter ); return 0; } @@ -578,7 +578,7 @@ int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFr // report the error pFrames->pModel = Abc_NtkVerifyGetCleanModel( pFrames, 1 ); // Abc_NtkVerifyReportErrorSeq( pNtk1, pNtk2, pFrames->pModel, nFrames ); - FREE( pFrames->pModel ); + ABC_FREE( pFrames->pModel ); Abc_NtkDelete( pFrames ); return 0; } @@ -632,7 +632,7 @@ int Abc_NtkSecFraig( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int nSeconds, int nFr ***********************************************************************/ int * Abc_NtkVerifyGetCleanModel( Abc_Ntk_t * pNtk, int nFrames ) { - int * pModel = ALLOC( int, Abc_NtkCiNum(pNtk) * nFrames ); + int * pModel = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) * nFrames ); memset( pModel, 0, sizeof(int) * Abc_NtkCiNum(pNtk) * nFrames ); return pModel; } @@ -669,18 +669,18 @@ int * Abc_NtkVerifySimulatePattern( Abc_Ntk_t * pNtk, int * pModel ) // set the CI values Abc_AigConst1(pNtk)->pCopy = (void *)1; Abc_NtkForEachCi( pNtk, pNode, i ) - pNode->pCopy = (void *)(PORT_PTRINT_T)pModel[i]; + pNode->pCopy = (void *)(ABC_PTRINT_T)pModel[i]; // simulate in the topological order Abc_NtkForEachNode( pNtk, pNode, i ) { - Value0 = ((int)(PORT_PTRINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode); - Value1 = ((int)(PORT_PTRINT_T)Abc_ObjFanin1(pNode)->pCopy) ^ Abc_ObjFaninC1(pNode); - pNode->pCopy = (void *)(PORT_PTRINT_T)(Value0 & Value1); + 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); } // fill the output values - pValues = ALLOC( int, Abc_NtkCoNum(pNtk) ); + pValues = ABC_ALLOC( int, Abc_NtkCoNum(pNtk) ); Abc_NtkForEachCo( pNtk, pNode, i ) - pValues[i] = ((int)(PORT_PTRINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode); + pValues[i] = ((int)(ABC_PTRINT_T)Abc_ObjFanin0(pNode)->pCopy) ^ Abc_ObjFaninC0(pNode); if ( fStrashed ) Abc_NtkDelete( pNtk ); return pValues; @@ -740,7 +740,7 @@ 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*)(PORT_PTRINT_T)i; + pNode->pCopy = (void*)(ABC_PTRINT_T)i; // print the model pNode = Vec_PtrEntry( vNodes, 0 ); if ( Abc_ObjIsCi(pNode) ) @@ -748,14 +748,14 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode Vec_PtrForEachEntry( vNodes, pNode, i ) { assert( Abc_ObjIsCi(pNode) ); - printf( " %s=%d", Abc_ObjName(pNode), pModel[(int)(PORT_PTRINT_T)pNode->pCopy] ); + printf( " %s=%d", Abc_ObjName(pNode), pModel[(int)(ABC_PTRINT_T)pNode->pCopy] ); } } printf( "\n" ); Vec_PtrFree( vNodes ); } - free( pValues1 ); - free( pValues2 ); + ABC_FREE( pValues1 ); + ABC_FREE( pValues2 ); } @@ -799,7 +799,7 @@ void Abc_NtkGetSeqPoSupp( Abc_Ntk_t * pNtk, int iFrame, int iNumPo ) for ( k = 0; k <= iFrame; k++ ) if ( Abc_NtkPi(pFrames, k*Abc_NtkPiNum(pNtk) + i)->pCopy ) pObj->pCopy = (void *)1; - // free stuff + // ABC_FREE stuff Vec_PtrFree( vSupp ); Abc_NtkDelete( pFrames ); } @@ -987,16 +987,16 @@ void Abc_NtkSimulteBuggyMiter( Abc_Ntk_t * pNtk ) assert( strlen(vPiValues1) == (unsigned)Abc_NtkPiNum(pNtk) ); assert( 1 == Abc_NtkPoNum(pNtk) ); - pModel1 = ALLOC( int, Abc_NtkCiNum(pNtk) ); + pModel1 = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) ); Abc_NtkForEachPi( pNtk, pObj, i ) pModel1[i] = vPiValues1[i] - '0'; Abc_NtkForEachLatch( pNtk, pObj, i ) - pModel1[Abc_NtkPiNum(pNtk)+i] = ((int)(PORT_PTRINT_T)pObj->pData) - 1; + pModel1[Abc_NtkPiNum(pNtk)+i] = ((int)(ABC_PTRINT_T)pObj->pData) - 1; pResult1 = Abc_NtkVerifySimulatePattern( pNtk, pModel1 ); printf( "Value = %d\n", pResult1[0] ); - pModel2 = ALLOC( int, Abc_NtkCiNum(pNtk) ); + pModel2 = ABC_ALLOC( int, Abc_NtkCiNum(pNtk) ); Abc_NtkForEachPi( pNtk, pObj, i ) pModel2[i] = vPiValues2[i] - '0'; Abc_NtkForEachLatch( pNtk, pObj, i ) @@ -1005,10 +1005,10 @@ void Abc_NtkSimulteBuggyMiter( Abc_Ntk_t * pNtk ) pResult2 = Abc_NtkVerifySimulatePattern( pNtk, pModel2 ); printf( "Value = %d\n", pResult2[0] ); - free( pModel1 ); - free( pModel2 ); - free( pResult1 ); - free( pResult2 ); + ABC_FREE( pModel1 ); + ABC_FREE( pModel2 ); + ABC_FREE( pResult1 ); + ABC_FREE( pResult2 ); } diff --git a/src/base/abci/abcXsim.c b/src/base/abci/abcXsim.c index 87739572..e63b296a 100644 --- a/src/base/abci/abcXsim.c +++ b/src/base/abci/abcXsim.c @@ -28,8 +28,8 @@ #define XVS1 ABC_INIT_ONE #define XVSX ABC_INIT_DC -static inline void Abc_ObjSetXsim( Abc_Obj_t * pObj, int Value ) { pObj->pCopy = (void *)(PORT_PTRINT_T)Value; } -static inline int Abc_ObjGetXsim( Abc_Obj_t * pObj ) { return (int)(PORT_PTRINT_T)pObj->pCopy; } +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 int Abc_XsimInv( int Value ) { if ( Value == XVS0 ) @@ -214,7 +214,7 @@ void Abc_NtkCycleInitState( Abc_Ntk_t * pNtk, int nFrames, int fVerbose ) } // set the final values Abc_NtkForEachLatch( pNtk, pObj, i ) - pObj->pData = (void *)(PORT_PTRINT_T)Abc_ObjGetXsim(Abc_ObjFanout0(pObj)); + pObj->pData = (void *)(ABC_PTRINT_T)Abc_ObjGetXsim(Abc_ObjFanout0(pObj)); } /////////////////////////////////////////////////////////////////////// diff --git a/src/base/abci/module.make b/src/base/abci/module.make index c872d62e..e520dcce 100644 --- a/src/base/abci/module.make +++ b/src/base/abci/module.make @@ -37,7 +37,6 @@ SRC += src/base/abci/abc.c \ src/base/abci/abcProve.c \ src/base/abci/abcQbf.c \ src/base/abci/abcQuant.c \ - src/base/abci/abcRec.c \ src/base/abci/abcReconv.c \ src/base/abci/abcReach.c \ src/base/abci/abcRefactor.c \ diff --git a/src/base/cmd/cmd.c b/src/base/cmd/cmd.c index 459d82c9..ca36db10 100644 --- a/src/base/cmd/cmd.c +++ b/src/base/cmd/cmd.c @@ -118,7 +118,7 @@ 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, free, free ); +// st_free_table( pAbc->tFlags, ABC_FREE, ABC_FREE ); st_foreach_item( pAbc->tCommands, gen, (char **)&pKey, (char **)&pValue ) CmdCommandFree( (Abc_Command *)pValue ); @@ -129,11 +129,11 @@ void Cmd_End( Abc_Frame_t * pAbc ) st_free_table( pAbc->tAliases ); st_foreach_item( pAbc->tFlags, gen, (char **)&pKey, (char **)&pValue ) - free( pKey ), free( pValue ); + ABC_FREE( pKey ), ABC_FREE( pValue ); st_free_table( pAbc->tFlags ); for ( i = 0; i < pAbc->aHistory->nSize; i++ ) - free( pAbc->aHistory->pArray[i] ); + ABC_FREE( pAbc->aHistory->pArray[i] ); Vec_PtrFree( pAbc->aHistory ); } @@ -586,7 +586,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) fp = CmdFileOpen( pAbc, argv[lp_file_index], "r", &real_filename, silent ); if ( fp == NULL ) { - FREE( real_filename ); + ABC_FREE( real_filename ); return !silent; /* error return if not silent */ } @@ -677,7 +677,7 @@ int CmdCommandSource( Abc_Frame_t * pAbc, int argc, char **argv ) } ( void ) fclose( fp ); } - FREE( real_filename ); + ABC_FREE( real_filename ); } while ( ( status == 0 ) && ( lp_count <= 0 ) ); @@ -734,8 +734,8 @@ int CmdCommandSetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) key = argv[1]; if ( st_delete( pAbc->tFlags, &key, &value ) ) { - FREE( key ); - FREE( value ); + ABC_FREE( key ); + ABC_FREE( value ); } flag_value = argc == 2 ? Extra_UtilStrsav( "" ) : Extra_UtilStrsav( argv[2] ); @@ -832,8 +832,8 @@ int CmdCommandUnsetVariable( Abc_Frame_t * pAbc, int argc, char **argv ) key = argv[i]; if ( st_delete( pAbc->tFlags, &key, &value ) ) { - FREE( key ); - FREE( value ); + ABC_FREE( key ); + ABC_FREE( value ); } } return 0; @@ -1108,7 +1108,7 @@ 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 char * _getcwd( char * buffer, int maxlen ); extern int _chdir( const char *dirname ); /**Function************************************************************* @@ -1561,7 +1561,7 @@ int CmdCommandSis( Abc_Frame_t * pAbc, int argc, char **argv ) // set the original spec of the new network if ( pNtk->pSpec ) { - FREE( pNtkNew->pSpec ); + ABC_FREE( pNtkNew->pSpec ); pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec ); } // replace the current network @@ -1704,7 +1704,7 @@ int CmdCommandMvsis( Abc_Frame_t * pAbc, int argc, char **argv ) // set the original spec of the new network if ( pNtk->pSpec ) { - FREE( pNtkNew->pSpec ); + ABC_FREE( pNtkNew->pSpec ); pNtkNew->pSpec = Extra_UtilStrsav( pNtk->pSpec ); } // replace the current network diff --git a/src/base/cmd/cmd.h b/src/base/cmd/cmd.h index 143f57cd..61c7264b 100644 --- a/src/base/cmd/cmd.h +++ b/src/base/cmd/cmd.h @@ -21,10 +21,6 @@ #ifndef __CMD_H__ #define __CMD_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -40,17 +40,6 @@ extern "C" { typedef struct MvCommand Abc_Command; // one command typedef struct MvAlias Abc_Alias; // one alias -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/cmd/cmdAlias.c b/src/base/cmd/cmdAlias.c index 0ec3feea..20ee0694 100644 --- a/src/base/cmd/cmdAlias.c +++ b/src/base/cmd/cmdAlias.c @@ -44,10 +44,10 @@ void CmdCommandAliasAdd( Abc_Frame_t * pAbc, char * sName, int argc, char ** arg Abc_Alias * pAlias; int fStatus, i; - pAlias = ALLOC(Abc_Alias, 1); + pAlias = ABC_ALLOC(Abc_Alias, 1); pAlias->sName = Extra_UtilStrsav(sName); pAlias->argc = argc; - pAlias->argv = ALLOC(char *, pAlias->argc); + pAlias->argv = ABC_ALLOC(char *, pAlias->argc); for(i = 0; i < argc; i++) pAlias->argv[i] = Extra_UtilStrsav(argv[i]); fStatus = st_insert( pAbc->tAliases, pAlias->sName, (char *) pAlias ); @@ -109,8 +109,8 @@ char * CmdCommandAliasLookup( Abc_Frame_t * pAbc, char * sCommand ) void CmdCommandAliasFree( Abc_Alias * pAlias ) { CmdFreeArgv( pAlias->argc, pAlias->argv ); - FREE(pAlias->sName); - FREE(pAlias); + ABC_FREE(pAlias->sName); + ABC_FREE(pAlias); } //////////////////////////////////////////////////////////////////////// diff --git a/src/base/cmd/cmdApi.c b/src/base/cmd/cmdApi.c index 71db1846..ae1949a6 100644 --- a/src/base/cmd/cmdApi.c +++ b/src/base/cmd/cmdApi.c @@ -56,7 +56,7 @@ void Cmd_CommandAdd( Abc_Frame_t * pAbc, char * sGroup, char * sName, void * pFu } // create the new command - pCommand = ALLOC( Abc_Command, 1 ); + pCommand = ABC_ALLOC( Abc_Command, 1 ); pCommand->sName = Extra_UtilStrsav( sName ); pCommand->sGroup = Extra_UtilStrsav( sGroup ); pCommand->pFunc = pFunc; diff --git a/src/base/cmd/cmdFlag.c b/src/base/cmd/cmdFlag.c index 993f2a49..d25861c0 100644 --- a/src/base/cmd/cmdFlag.c +++ b/src/base/cmd/cmdFlag.c @@ -69,7 +69,7 @@ void Cmd_FlagUpdateValue( Abc_Frame_t * pAbc, char * key, char * value ) newValue = Extra_UtilStrsav(""); // newValue = NULL; if ( st_delete(pAbc->tFlags, &key, &oldValue) ) - FREE(oldValue); + ABC_FREE(oldValue); st_insert( pAbc->tFlags, key, newValue ); } @@ -90,8 +90,8 @@ void Cmd_FlagDeleteByName( Abc_Frame_t * pAbc, char * key ) return; if ( st_delete( pAbc->tFlags, &key, &value ) ) { - FREE(key); - FREE(value); + ABC_FREE(key); + ABC_FREE(value); } } diff --git a/src/base/cmd/cmdUtils.c b/src/base/cmd/cmdUtils.c index 8c3fd38c..1e4c7700 100644 --- a/src/base/cmd/cmdUtils.c +++ b/src/base/cmd/cmdUtils.c @@ -210,7 +210,7 @@ char * CmdSplitLine( Abc_Frame_t * pAbc, char *sCommand, int *argc, char ***argv if ( start == p ) break; - new_arg = ALLOC( char, p - start + 1 ); + new_arg = ABC_ALLOC( char, p - start + 1 ); j = 0; for ( i = 0; i < p - start; i++ ) { @@ -270,13 +270,13 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) { stopit = 1; } - FREE( argv[0] ); + ABC_FREE( argv[0] ); added = alias->argc - 1; /* shift all the arguments to the right */ if ( added != 0 ) { - argv = REALLOC( char *, argv, argc + added ); + argv = ABC_REALLOC( char *, argv, argc + added ); for ( i = argc - 1; i >= 1; i-- ) { argv[i + added] = argv[i]; @@ -330,7 +330,7 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) added = newc - 1; if ( added != 0 ) { - argv = REALLOC( char *, argv, argc + added ); + argv = ABC_REALLOC( char *, argv, argc + added ); for ( j = argc - 1; j > offset; j-- ) { argv[j + added] = argv[j]; @@ -341,14 +341,14 @@ int CmdApplyAlias( Abc_Frame_t * pAbc, int *argcp, char ***argvp, int *loop ) { argv[j + offset] = newv[j]; } - FREE( newv ); + ABC_FREE( newv ); offset += added; } if ( subst == 1 ) { for ( i = offset; i < argc; i++ ) { - FREE( argv[i] ); + ABC_FREE( argv[i] ); } argc = offset; } @@ -422,12 +422,12 @@ FILE * CmdFileOpen( Abc_Frame_t * pAbc, char *sFileName, char *sMode, char **pFi sPathAll = Extra_UtilStrsav( sPathUsr ); } else { - sPathAll = ALLOC( char, strlen(sPathLib)+strlen(sPathUsr)+5 ); + sPathAll = ABC_ALLOC( char, strlen(sPathLib)+strlen(sPathUsr)+5 ); sprintf( sPathAll, "%s:%s",sPathUsr, sPathLib ); } if ( sPathAll != NULL ) { sRealName = Extra_UtilFileSearch(sFileName, sPathAll, "r"); - FREE( sPathAll ); + ABC_FREE( sPathAll ); } } if (sRealName == NULL) { @@ -442,7 +442,7 @@ FILE * CmdFileOpen( Abc_Frame_t * pAbc, char *sFileName, char *sMode, char **pFi if ( pFileNameReal ) *pFileNameReal = sRealName; else - FREE(sRealName); + ABC_FREE(sRealName); return pFile; } @@ -462,8 +462,8 @@ void CmdFreeArgv( int argc, char **argv ) { int i; for ( i = 0; i < argc; i++ ) - FREE( argv[i] ); - FREE( argv ); + ABC_FREE( argv[i] ); + ABC_FREE( argv ); } /**Function************************************************************* @@ -481,8 +481,9 @@ char ** CmdAddToArgv( int argc, char ** argv ) { char ** argv2; int i; - argv2 = ALLOC( char *, argc + 1 ); + argv2 = ABC_ALLOC( char *, argc + 1 ); argv2[0] = Extra_UtilStrsav( "read" ); +// argv2[0] = Extra_UtilStrsav( "&r" ); for ( i = 0; i < argc; i++ ) argv2[i+1] = Extra_UtilStrsav( argv[i] ); return argv2; @@ -501,9 +502,9 @@ char ** CmdAddToArgv( int argc, char ** argv ) ***********************************************************************/ void CmdCommandFree( Abc_Command * pCommand ) { - free( pCommand->sGroup ); - free( pCommand->sName ); - free( pCommand ); + ABC_FREE( pCommand->sGroup ); + ABC_FREE( pCommand->sName ); + ABC_FREE( pCommand ); } @@ -530,7 +531,7 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll ) // put all commands into one array nCommands = st_count( pAbc->tCommands ); - ppCommands = ALLOC( Abc_Command *, nCommands ); + ppCommands = ABC_ALLOC( Abc_Command *, nCommands ); i = 0; st_foreach_item( pAbc->tCommands, gen, &key, &value ) { @@ -580,7 +581,7 @@ void CmdCommandPrint( Abc_Frame_t * pAbc, bool fPrintAll ) iCom = 1; } fprintf( pAbc->Out, "\n" ); - FREE( ppCommands ); + ABC_FREE( ppCommands ); } /**Function************************************************************* @@ -658,7 +659,7 @@ void CmdPrintTable( st_table * tTable, int fAliases ) int nNames, i; // collect keys in the array - ppNames = ALLOC( char *, st_count(tTable) ); + ppNames = ABC_ALLOC( char *, st_count(tTable) ); nNames = 0; st_foreach_item( tTable, gen, &key, &value ) ppNames[nNames++] = key; @@ -676,7 +677,7 @@ void CmdPrintTable( st_table * tTable, int fAliases ) else fprintf( stdout, "%-15s %-15s\n", ppNames[i], value ); } - free( ppNames ); + ABC_FREE( ppNames ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/base/io/io.c b/src/base/io/io.c index a8941868..ee5df414 100644 --- a/src/base/io/io.c +++ b/src/base/io/io.c @@ -847,7 +847,7 @@ int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv ) } pNtk = Abc_NtkCreateWithNode( pSopCover ); - free( pSopCover ); + ABC_FREE( pSopCover ); if ( pNtk == NULL ) { fprintf( pAbc->Err, "Deriving the network has failed.\n" ); @@ -1082,7 +1082,7 @@ int IoCommandReadVerLib( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } printf( "The library contains %d gates.\n", st_count(pLibrary->tModules) ); - // free old library + // ABC_FREE old library if ( Abc_FrameReadLibVer() ) Abc_LibFree( Abc_FrameReadLibVer(), NULL ); // read new library diff --git a/src/base/io/ioAbc.h b/src/base/io/ioAbc.h index 842d8995..c11168df 100644 --- a/src/base/io/ioAbc.h +++ b/src/base/io/ioAbc.h @@ -21,10 +21,6 @@ #ifndef __IO_H__ #define __IO_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -35,6 +31,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/io/ioReadAiger.c b/src/base/io/ioReadAiger.c index 3a6ecd19..2c37e210 100644 --- a/src/base/io/ioReadAiger.c +++ b/src/base/io/ioReadAiger.c @@ -130,9 +130,9 @@ static char * Ioa_ReadLoadFileBz2Aig( char * pFileName, int * pFileSize ) } do { if (!bufHead) - buf = bufHead = ALLOC( buflist, 1 ); + buf = bufHead = ABC_ALLOC( buflist, 1 ); else - buf = buf->next = ALLOC( buflist, 1 ); + buf = buf->next = ABC_ALLOC( buflist, 1 ); nFileSize += buf->nBuf = BZ2_bzRead(&bzError,b,buf->buf,1<<20); buf->next = NULL; } while (bzError == BZ_OK); @@ -141,14 +141,14 @@ static char * Ioa_ReadLoadFileBz2Aig( char * pFileName, int * pFileSize ) char * p; int nBytes = 0; BZ2_bzReadClose(&bzError,b); - p = pContents = ALLOC( char, nFileSize + 10 ); + p = pContents = ABC_ALLOC( char, nFileSize + 10 ); buf = bufHead; do { memcpy(p+nBytes,buf->buf,buf->nBuf); nBytes += buf->nBuf; // } while((buf = buf->next)); pNext = buf->next; - free( buf ); + ABC_FREE( buf ); } while((buf = pNext)); } else if (bzError == BZ_DATA_ERROR_MAGIC) { // not a BZIP2 file @@ -160,7 +160,7 @@ static char * Ioa_ReadLoadFileBz2Aig( char * pFileName, int * pFileSize ) printf( "Ioa_ReadLoadFileBz2(): The file is empty.\n" ); return NULL; } - pContents = ALLOC( char, nFileSize + 10 ); + pContents = ABC_ALLOC( char, nFileSize + 10 ); rewind( pFile ); fread( pContents, nFileSize, 1, pFile ); } else { @@ -194,12 +194,12 @@ static char * Ioa_ReadLoadFileGzAig( char * pFileName, int * pFileSize ) 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 - pContents = ALLOC( char, nFileSize ); + pContents = ABC_ALLOC( char, nFileSize ); readBlock = 0; while ((amtRead = gzread(pFile, pContents + readBlock * READ_BLOCK_SIZE, READ_BLOCK_SIZE)) == READ_BLOCK_SIZE) { //printf("%d: read %d bytes\n", readBlock, amtRead); nFileSize += READ_BLOCK_SIZE; - pContents = REALLOC(char, pContents, nFileSize); + pContents = ABC_REALLOC(char, pContents, nFileSize); ++readBlock; } //printf("%d: read %d bytes\n", readBlock, amtRead); @@ -244,7 +244,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck ) // pContents = Ioa_ReadLoadFile( pFileName ); nFileSize = Extra_FileSize( pFileName ); pFile = fopen( pFileName, "rb" ); - pContents = ALLOC( char, nFileSize ); + pContents = ABC_ALLOC( char, nFileSize ); fread( pContents, nFileSize, 1, pFile ); fclose( pFile ); } @@ -254,6 +254,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck ) if ( strncmp(pContents, "aig", 3) != 0 || (pContents[3] != ' ' && pContents[3] != '2') ) { fprintf( stdout, "Wrong input file format.\n" ); + free( pContents ); return NULL; } @@ -262,7 +263,7 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck ) pName = Extra_FileNameGeneric( pFileName ); pNtkNew->pName = Extra_UtilStrsav( pName ); pNtkNew->pSpec = Extra_UtilStrsav( pFileName ); - free( pName ); + ABC_FREE( pName ); // read the file type @@ -469,14 +470,14 @@ Abc_Ntk_t * Io_ReadAiger( char * pFileName, int fCheck ) char * pTemp; for ( pTemp = pCur + 9; *pTemp && *pTemp != '\n'; pTemp++ ); *pTemp = 0; - free( pNtkNew->pName ); + ABC_FREE( pNtkNew->pName ); pNtkNew->pName = Extra_UtilStrsav( pCur + 9 ); } } // skipping the comments - free( pContents ); + ABC_FREE( pContents ); Vec_PtrFree( vNodes ); // remove the extra nodes diff --git a/src/base/io/ioReadBaf.c b/src/base/io/ioReadBaf.c index eb337603..495f122b 100644 --- a/src/base/io/ioReadBaf.c +++ b/src/base/io/ioReadBaf.c @@ -53,7 +53,7 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck ) // read the file into the buffer nFileSize = Extra_FileSize( pFileName ); pFile = fopen( pFileName, "rb" ); - pContents = ALLOC( char, nFileSize ); + pContents = ABC_ALLOC( char, nFileSize ); fread( pContents, nFileSize, 1, pFile ); fclose( pFile ); @@ -116,7 +116,7 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck ) // make sure we are at the place where the nodes begin if ( pBufferNode != (unsigned *)pCur ) { - free( pContents ); + ABC_FREE( pContents ); Vec_PtrFree( vNodes ); Abc_NtkDelete( pNtkNew ); printf( "Warning: Internal reader error.\n" ); @@ -140,13 +140,13 @@ Abc_Ntk_t * Io_ReadBaf( char * pFileName, int fCheck ) Num = pBufferNode[2*nAnds+i]; if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) ) { - Abc_ObjSetData( Abc_ObjFanout0(pObj), (void *)(PORT_PTRINT_T)(Num & 3) ); + Abc_ObjSetData( Abc_ObjFanout0(pObj), (void *)(ABC_PTRINT_T)(Num & 3) ); Num >>= 2; } pNode0 = Abc_ObjNotCond( Vec_PtrEntry(vNodes, Num >> 1), Num & 1 ); Abc_ObjAddFanin( pObj, pNode0 ); } - free( pContents ); + ABC_FREE( pContents ); Vec_PtrFree( vNodes ); // remove the extra nodes diff --git a/src/base/io/ioReadBlif.c b/src/base/io/ioReadBlif.c index c818cd55..b6eb29e3 100644 --- a/src/base/io/ioReadBlif.c +++ b/src/base/io/ioReadBlif.c @@ -610,7 +610,7 @@ int Io_ReadBlifNetworkGate( Io_ReadBlif_t * p, Vec_Ptr_t * vTokens ) Description [] - SideEffects [] + SideEffects [] SeeAlso [] @@ -642,7 +642,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 *)(PORT_PTRINT_T)Extra_FileReaderGetLineNumber(p->pReader, 0); + pBox->pCopy = (void *)(ABC_PTRINT_T)Extra_FileReaderGetLineNumber(p->pReader, 0); return 0; } @@ -795,7 +795,7 @@ Vec_Ptr_t * Io_ReadBlifGetTokens( Io_ReadBlif_t * p ) if ( p->vNewTokens->nSize > 0 ) { for ( i = 0; i < p->vNewTokens->nSize; i++ ) - free( p->vNewTokens->pArray[i] ); + ABC_FREE( p->vNewTokens->pArray[i] ); p->vNewTokens->nSize = 0; } @@ -868,7 +868,7 @@ Io_ReadBlif_t * Io_ReadBlifFile( char * pFileName ) return NULL; // start the reading data structure - p = ALLOC( Io_ReadBlif_t, 1 ); + p = ABC_ALLOC( Io_ReadBlif_t, 1 ); memset( p, 0, sizeof(Io_ReadBlif_t) ); p->pFileName = pFileName; p->pReader = pReader; @@ -894,7 +894,7 @@ void Io_ReadBlifFree( Io_ReadBlif_t * p ) Extra_FileReaderFree( p->pReader ); Vec_PtrFree( p->vNewTokens ); Vec_StrFree( p->vCubes ); - free( p ); + ABC_FREE( p ); } @@ -921,7 +921,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pNames = pBox->pData; if ( !stmm_lookup( tName2Model, Vec_PtrEntry(pNames, 0), (char **)&pNtkModel ) ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Cannot find the model for subcircuit %s.", (char*)Vec_PtrEntry(pNames, 0) ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -939,7 +939,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pActual = Io_ReadBlifCleanName(pName); if ( pActual == NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Cannot parse formal/actual name pair \"%s\".", pName ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -950,7 +950,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pObj = Abc_NtkFindNet( pNtkModel, pName ); if ( pObj == NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Cannot find formal input \"%s\" as an PI of model \"%s\".", pName, (char*)Vec_PtrEntry(pNames, 0) ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -967,7 +967,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s // remember the actual name in the net if ( pObj->pCopy != NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Formal input \"%s\" is used more than once.", pName ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -987,7 +987,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pActual = (void *)pObj->pCopy; if ( pActual == NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Formal input \"%s\" of model %s is not driven.", pName, (char*)Vec_PtrEntry(pNames, 0) ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -1006,7 +1006,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pActual = Io_ReadBlifCleanName(pName); if ( pActual == NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Cannot parse formal/actual name pair \"%s\".", pName ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -1017,7 +1017,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pObj = Abc_NtkFindNet( pNtkModel, pName ); if ( pObj == NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Cannot find formal output \"%s\" as an PO of model \"%s\".", pName, (char*)Vec_PtrEntry(pNames, 0) ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -1026,7 +1026,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pObj = Abc_ObjFanout0(pObj); if ( pObj->pCopy != NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Formal output \"%s\" is used more than once.", pName ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -1039,7 +1039,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s pActual = (void *)pObj->pCopy; if ( pActual == NULL ) { - p->LineCur = (int)(PORT_PTRINT_T)pBox->pCopy; + p->LineCur = (int)(ABC_PTRINT_T)pBox->pCopy; sprintf( p->sError, "Formal output \"%s\" of model %s is not driven.", pName, (char*)Vec_PtrEntry(pNames, 0) ); Io_ReadBlifPrintErrorMessage( p ); return 1; @@ -1052,7 +1052,7 @@ int Io_ReadBlifNetworkConnectBoxesOneBox( Io_ReadBlif_t * p, Abc_Obj_t * pBox, s // remove the array of names, assign the pointer to the model Vec_PtrForEachEntry( pBox->pData, pName, i ) - free( pName ); + ABC_FREE( pName ); Vec_PtrFree( pBox->pData ); pBox->pData = pNtkModel; return 0; diff --git a/src/base/io/ioReadBlifAig.c b/src/base/io/ioReadBlifAig.c index 75552192..8d4c77d4 100644 --- a/src/base/io/ioReadBlifAig.c +++ b/src/base/io/ioReadBlifAig.c @@ -60,7 +60,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 free object + int iObjNext; // the next ABC_FREE object // file lines char * pModel; // .model line Vec_Ptr_t * vInputs; // .inputs lines @@ -171,7 +171,7 @@ Abc_Ntk_t * Io_ReadBlifAsAig( char * pFileName, int fCheck ) static Io_BlifMan_t * Io_BlifAlloc() { Io_BlifMan_t * p; - p = ALLOC( Io_BlifMan_t, 1 ); + p = ABC_ALLOC( Io_BlifMan_t, 1 ); memset( p, 0, sizeof(Io_BlifMan_t) ); p->vLines = Vec_PtrAlloc( 512 ); p->vInputs = Vec_PtrAlloc( 512 ); @@ -201,9 +201,9 @@ static void Io_BlifFree( Io_BlifMan_t * p ) { if ( p->pAig ) Abc_NtkDelete( p->pAig ); - if ( p->pBuffer ) free( p->pBuffer ); - if ( p->pObjects ) free( p->pObjects ); - if ( p->pTable ) free( p->pTable ); + if ( p->pBuffer ) ABC_FREE( p->pBuffer ); + if ( p->pObjects ) ABC_FREE( p->pObjects ); + if ( p->pTable ) ABC_FREE( p->pTable ); Vec_PtrFree( p->vLines ); Vec_PtrFree( p->vInputs ); Vec_PtrFree( p->vOutputs ); @@ -214,7 +214,7 @@ static void Io_BlifFree( Io_BlifMan_t * p ) Vec_PtrFree( p->vPos ); Vec_PtrFree( p->vLis ); Vec_PtrFree( p->vLos ); - free( p ); + ABC_FREE( p ); } @@ -444,7 +444,7 @@ static char * Io_BlifLoadFile( char * pFileName ) printf( "Io_BlifLoadFile(): The file is empty.\n" ); return NULL; } - pContents = ALLOC( char, nFileSize + 10 ); + pContents = ABC_ALLOC( char, nFileSize + 10 ); rewind( pFile ); fread( pContents, nFileSize, 1, pFile ); fclose( pFile ); @@ -539,12 +539,12 @@ static void Io_BlifReadPreparse( Io_BlifMan_t * p ) p->nObjects = Io_BlifEstimatePiNum(p) + Vec_PtrSize(p->vLatches) + Vec_PtrSize(p->vNames) + 512; // allocate memory for objects - p->pObjects = ALLOC( Io_BlifObj_t, p->nObjects ); + p->pObjects = ABC_ALLOC( Io_BlifObj_t, p->nObjects ); memset( p->pObjects, 0, p->nObjects * sizeof(Io_BlifObj_t) ); // allocate memory for the hash table p->nTableSize = p->nObjects/2 + 1; - p->pTable = ALLOC( Io_BlifObj_t *, p->nTableSize ); + p->pTable = ABC_ALLOC( Io_BlifObj_t *, p->nTableSize ); memset( p->pTable, 0, p->nTableSize * sizeof(Io_BlifObj_t *) ); } @@ -970,7 +970,7 @@ static int Io_BlifParseConstruct( Io_BlifMan_t * p ) // add the latch box pLatch = Abc_NtkCreateLatch( pAig ); - pLatch->pData = (void *)(PORT_PTRUINT_T)pObjIo->Init; + pLatch->pData = (void *)(ABC_PTRUINT_T)pObjIo->Init; Abc_ObjAssignName( pLatch, pObjIo->pName, "L" ); Abc_ObjAddFanin( pLatch, pObj ); diff --git a/src/base/io/ioReadBlifMv.c b/src/base/io/ioReadBlifMv.c index 87358ed2..95ea4fe5 100644 --- a/src/base/io/ioReadBlifMv.c +++ b/src/base/io/ioReadBlifMv.c @@ -49,6 +49,7 @@ struct Io_MvMod_t_ 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 int fBlackBox; // indicates blackbox model @@ -102,6 +103,7 @@ 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_MvParseLineGateBlif( Io_MvMod_t * p, Vec_Ptr_t * vTokens ); static Io_MvVar_t * Abc_NtkMvVarDup( Abc_Ntk_t * pNtk, Io_MvVar_t * pVar ); @@ -157,8 +159,8 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck ) // set the design name pDesignName = Extra_FileNameGeneric( pFileName ); p->pDesign = Abc_LibCreate( pDesignName ); - free( pDesignName ); - // free the HOP manager + ABC_FREE( pDesignName ); + // ABC_FREE the HOP manager Hop_ManStop( p->pDesign->pManFunc ); p->pDesign->pManFunc = NULL; // prepare the file for parsing @@ -232,7 +234,7 @@ Abc_Ntk_t * Io_ReadBlifMv( char * pFileName, int fBlifMv, int fCheck ) static Io_MvMan_t * Io_MvAlloc() { Io_MvMan_t * p; - p = ALLOC( Io_MvMan_t, 1 ); + p = ABC_ALLOC( Io_MvMan_t, 1 ); memset( p, 0, sizeof(Io_MvMan_t) ); p->vLines = Vec_PtrAlloc( 512 ); p->vModels = Vec_PtrAlloc( 512 ); @@ -260,7 +262,7 @@ static void Io_MvFree( Io_MvMan_t * p ) if ( p->pDesign ) Abc_LibFree( p->pDesign, NULL ); if ( p->pBuffer ) - free( p->pBuffer ); + ABC_FREE( p->pBuffer ); if ( p->vLines ) Vec_PtrFree( p->vLines ); if ( p->vModels ) @@ -272,7 +274,7 @@ static void Io_MvFree( Io_MvMan_t * p ) Vec_PtrFree( p->vTokens ); Vec_PtrFree( p->vTokens2 ); Vec_StrFree( p->vFunc ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -289,7 +291,7 @@ static void Io_MvFree( Io_MvMan_t * p ) static Io_MvMod_t * Io_MvModAlloc() { Io_MvMod_t * p; - p = ALLOC( Io_MvMod_t, 1 ); + p = ABC_ALLOC( Io_MvMod_t, 1 ); memset( p, 0, sizeof(Io_MvMod_t) ); p->vInputs = Vec_PtrAlloc( 512 ); p->vOutputs = Vec_PtrAlloc( 512 ); @@ -297,6 +299,7 @@ static Io_MvMod_t * Io_MvModAlloc() 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 ); return p; @@ -323,9 +326,10 @@ static void Io_MvModFree( Io_MvMod_t * p ) Vec_PtrFree( p->vResets ); Vec_PtrFree( p->vNames ); Vec_PtrFree( p->vSubckts ); + Vec_PtrFree( p->vShorts ); Vec_PtrFree( p->vOnehots ); Vec_PtrFree( p->vMvs ); - free( p ); + ABC_FREE( p ); } @@ -515,7 +519,7 @@ static char * Io_MvLoadFile( char * pFileName ) printf( "Io_MvLoadFile(): The file is empty.\n" ); return NULL; } - pContents = ALLOC( char, nFileSize + 10 ); + pContents = ABC_ALLOC( char, nFileSize + 10 ); rewind( pFile ); fread( pContents, nFileSize, 1, pFile ); fclose( pFile ); @@ -601,6 +605,8 @@ static void Io_MvReadPreparse( Io_MvMan_t * p ) Vec_PtrPush( p->pLatest->vOutputs, pCur ); else if ( !strncmp(pCur, "subckt", 6) ) Vec_PtrPush( p->pLatest->vSubckts, pCur ); + else if ( !strncmp(pCur, "short", 5) ) + Vec_PtrPush( p->pLatest->vShorts, pCur ); else if ( !strncmp(pCur, "onehot", 6) ) Vec_PtrPush( p->pLatest->vOnehots, pCur ); else if ( p->fBlifMv && !strncmp(pCur, "mv", 2) ) @@ -634,6 +640,8 @@ static void Io_MvReadPreparse( Io_MvMan_t * p ) {} else if ( !strncmp(pCur, "no_merge", 8) ) {} +// else if ( !strncmp(pCur, "inouts", 6) ) +// {} else { pCur--; @@ -746,6 +754,9 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p ) Vec_PtrForEachEntry( pMod->vNames, pLine, k ) if ( !Io_MvParseLineNamesBlif( pMod, pLine ) ) return NULL; + Vec_PtrForEachEntry( pMod->vShorts, pLine, k ) + if ( !Io_MvParseLineShortBlif( pMod, pLine ) ) + return NULL; } // parse the subcircuits Vec_PtrForEachEntry( pMod->vSubckts, pLine, k ) @@ -753,10 +764,14 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p ) return NULL; // allow for blackboxes without .blackbox line - if ( Abc_NtkLatchNum(pMod->pNtk) == 0 && Abc_NtkNodeNum(pMod->pNtk) == 0 ) + if ( Abc_NtkLatchNum(pMod->pNtk) == 0 && Abc_NtkNodeNum(pMod->pNtk) == 0 && Abc_NtkBoxNum(pMod->pNtk) == 0 ) { if ( pMod->pNtk->ntkFunc == ABC_FUNC_SOP ) + { + Extra_MmFlexStop( pMod->pNtk->pManFunc ); + pMod->pNtk->pManFunc = NULL; pMod->pNtk->ntkFunc = ABC_FUNC_BLACKBOX; + } } // finalize the network @@ -768,7 +783,7 @@ static Abc_Lib_t * Io_MvParse( Io_MvMan_t * p ) Abc_Obj_t * pObj; // set register numbers Abc_NtkForEachLatch( pMod->pNtk, pObj, k ) - pObj->pNext = (Abc_Obj_t *)(PORT_PTRINT_T)k; + 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 ) @@ -990,7 +1005,7 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine ) sprintf( p->pMan->sError, "Line %d: Cannot find the model for subcircuit %s.", Io_MvGetLine(p->pMan, pToken), pName ); return 0; } - +/* // check if the number of tokens is correct if ( nEquals != Abc_NtkPiNum(pModel) + Abc_NtkPoNum(pModel) ) { @@ -998,7 +1013,7 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine ) Io_MvGetLine(p->pMan, pToken), nEquals, Abc_NtkPiNum(pModel) + Abc_NtkPoNum(pModel) ); return 0; } - +*/ // get the names ppNames = (char **)Vec_PtrArray(vTokens) + 2 + p->pMan->fBlifMv; @@ -1010,41 +1025,59 @@ static int Io_MvParseLineSubckt( Io_MvMod_t * p, char * pLine ) pBox->pData = pModel; if ( p->pMan->fBlifMv ) Abc_ObjAssignName( pBox, Vec_PtrEntry(vTokens,2), NULL ); + // go through formal inputs Abc_NtkForEachPi( pModel, pTerm, i ) - { - // find this terminal among the formal inputs of the subcircuit + { + // find this terminal among the actual inputs of the subcircuit pName = Abc_ObjName(Abc_ObjFanout0(pTerm)); for ( k = 0; k < nEquals; k++ ) if ( !strcmp( ppNames[2*k], pName ) ) break; +/* if ( k == nEquals ) { sprintf( p->pMan->sError, "Line %d: Cannot find PI \"%s\" of the model \"%s\" as a formal input of the subcircuit.", Io_MvGetLine(p->pMan, pToken), pName, Abc_NtkName(pModel) ); return 0; } +*/ + if ( k == nEquals ) + { + Abc_Obj_t * pNode = Abc_NtkCreateNode( p->pNtk ); + pNode->pData = Abc_SopRegister( p->pNtk->pManFunc, " 0\n" ); + pNet = Abc_NtkFindOrCreateNet( p->pNtk, Abc_ObjNameSuffix(pNode, "abc") ); + Abc_ObjAddFanin( pNet, pNode ); + pTerm = Abc_NtkCreateBi( p->pNtk ); + Abc_ObjAddFanin( pBox, pTerm ); + Abc_ObjAddFanin( pTerm, pNet ); + continue; + } + // create the BI with the actual name pNet = Abc_NtkFindOrCreateNet( p->pNtk, ppNames[2*k+1] ); pTerm = Abc_NtkCreateBi( p->pNtk ); Abc_ObjAddFanin( pBox, pTerm ); Abc_ObjAddFanin( pTerm, pNet ); } + // go through formal outputs Abc_NtkForEachPo( pModel, pTerm, i ) { - // find this terminal among the formal outputs of the subcircuit + // find this terminal among the actual outputs of the subcircuit pName = Abc_ObjName(Abc_ObjFanin0(pTerm)); for ( k = 0; k < nEquals; k++ ) if ( !strcmp( ppNames[2*k], pName ) ) break; +/* if ( k == nEquals ) { sprintf( p->pMan->sError, "Line %d: Cannot find PO \"%s\" of the modell \"%s\" as a formal output of the subcircuit.", Io_MvGetLine(p->pMan, pToken), pName, Abc_NtkName(pModel) ); return 0; } +*/ // create the BI with the actual name - pNet = Abc_NtkFindOrCreateNet( p->pNtk, ppNames[2*k+1] ); pTerm = Abc_NtkCreateBo( p->pNtk ); + pNet = Abc_NtkFindOrCreateNet( p->pNtk, k == nEquals ? Abc_ObjNameSuffix(pTerm, "abc") : ppNames[2*k+1] ); Abc_ObjAddFanin( pNet, pTerm ); Abc_ObjAddFanin( pTerm, pBox ); } @@ -1100,9 +1133,9 @@ static Vec_Int_t * Io_MvParseLineOnehot( Io_MvMod_t * p, char * pLine ) } // save register name // Vec_PtrPush( vResult, Abc_ObjName(pNet) ); - Vec_IntPush( vResult, (int)(PORT_PTRINT_T)Abc_ObjFanin0(pTerm)->pNext ); + Vec_IntPush( vResult, (int)(ABC_PTRINT_T)Abc_ObjFanin0(pTerm)->pNext ); // printf( "%d(%d) ", (int)Abc_ObjFanin0(pTerm)->pNext, ((int)Abc_ObjFanin0(pTerm)->pData) -1 ); - printf( "%d", ((int)(PORT_PTRINT_T)Abc_ObjFanin0(pTerm)->pData)-1 ); + printf( "%d", ((int)(ABC_PTRINT_T)Abc_ObjFanin0(pTerm)->pData)-1 ); } printf( "\n" ); return vResult; @@ -1679,6 +1712,45 @@ static int Io_MvParseLineNamesBlif( Io_MvMod_t * p, char * pLine ) return 1; } +/**Function************************************************************* + + Synopsis [Parses the nodes line.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static int Io_MvParseLineShortBlif( Io_MvMod_t * p, char * pLine ) +{ + Vec_Ptr_t * vTokens = p->pMan->vTokens; + Abc_Obj_t * pNet, * pNode; + char * pName; + assert( !p->pMan->fBlifMv ); + 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)) ); + return 0; + } + // parse the regular name line + assert( !strcmp(Vec_PtrEntry(vTokens,0), "short") ); + pName = Vec_PtrEntryLast( vTokens ); + pNet = Abc_NtkFindOrCreateNet( p->pNtk, pName ); + if ( Abc_ObjFaninNum(pNet) > 0 ) + { + sprintf( p->pMan->sError, "Line %d: Signal \"%s\" is defined more than once.", Io_MvGetLine(p->pMan, pName), pName ); + return 0; + } + // 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" ); + return 1; +} + /**Function************************************************************* Synopsis [Duplicate the MV variable.] diff --git a/src/base/io/ioReadDsd.c b/src/base/io/ioReadDsd.c index 482b5d06..4848e4e9 100644 --- a/src/base/io/ioReadDsd.c +++ b/src/base/io/ioReadDsd.c @@ -211,7 +211,7 @@ Abc_Obj_t * Io_ReadDsd_rec( Abc_Ntk_t * pNtk, char * pCur, char * pSop ) pSop = Abc_SopFromTruthHex( pCur ); *pEnd = '('; pObj = Io_ReadDsd_rec( pNtk, pEnd, pSop ); - free( pSop ); + ABC_FREE( pSop ); return pObj; } @@ -253,7 +253,7 @@ Abc_Ntk_t * Io_ReadDsd( char * pForm ) // transform the formula by inserting parantheses // this transforms strings like PRIME(a,b,cd) into (PRIME((a),(b),(cd))) - pCur = pFormCopy = ALLOC( char, 3 * strlen(pForm) + 10 ); + pCur = pFormCopy = ABC_ALLOC( char, 3 * strlen(pForm) + 10 ); *pCur++ = '('; for ( ; *pForm; pForm++ ) if ( *pForm == '(' ) @@ -279,7 +279,7 @@ Abc_Ntk_t * Io_ReadDsd( char * pForm ) // parse the formula pObj = Io_ReadDsd_rec( pNtk, pFormCopy, NULL ); - free( pFormCopy ); + ABC_FREE( pFormCopy ); if ( pObj == NULL ) return NULL; diff --git a/src/base/io/ioReadEdif.c b/src/base/io/ioReadEdif.c index 2f97644a..26e49d0e 100644 --- a/src/base/io/ioReadEdif.c +++ b/src/base/io/ioReadEdif.c @@ -184,7 +184,7 @@ Abc_Ntk_t * Io_ReadEdifNetwork( Extra_FileReader_t * p ) } else if ( strcmp( vTokens->pArray[0], "design" ) == 0 ) { - free( pNtk->pName ); + ABC_FREE( pNtk->pName ); pNtk->pName = Extra_UtilStrsav( vTokens->pArray[3] ); break; } diff --git a/src/base/io/ioReadEqn.c b/src/base/io/ioReadEqn.c index ad35c73b..f778197b 100644 --- a/src/base/io/ioReadEqn.c +++ b/src/base/io/ioReadEqn.c @@ -158,7 +158,7 @@ Abc_Ntk_t * Io_ReadEqnNetwork( Extra_FileReader_t * p ) // derive the function pNode->pData = Parse_FormulaParserEqn( stdout, pFormula, vVars, pNtk->pManFunc ); // remove the cubes - FREE( pFormulaCopy ); + ABC_FREE( pFormulaCopy ); } } Extra_ProgressBarStop( pProgress ); diff --git a/src/base/io/ioReadPla.c b/src/base/io/ioReadPla.c index 4b326783..347d1daa 100644 --- a/src/base/io/ioReadPla.c +++ b/src/base/io/ioReadPla.c @@ -168,7 +168,7 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros ) { // first time here // create the PO drivers and add them // start the SOP covers - ppSops = ALLOC( Vec_Str_t *, nOutputs ); + ppSops = ABC_ALLOC( Vec_Str_t *, nOutputs ); Abc_NtkForEachPo( pNtk, pTermPo, i ) { ppSops[i] = Vec_StrAlloc( 100 ); @@ -250,7 +250,7 @@ Abc_Ntk_t * Io_ReadPlaNetwork( Extra_FileReader_t * p, int fZeros ) pNode->pData = Abc_SopRegister( pNtk->pManFunc, ppSops[i]->pArray ); Vec_StrFree( ppSops[i] ); } - free( ppSops ); + ABC_FREE( ppSops ); Abc_NtkFinalizeRead( pNtk ); return pNtk; } diff --git a/src/base/io/ioUtil.c b/src/base/io/ioUtil.c index 60e6adc8..c67c183d 100644 --- a/src/base/io/ioUtil.c +++ b/src/base/io/ioUtil.c @@ -733,11 +733,11 @@ FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mo { if ( fVerbose ) fprintf ( stdout, "Using file %s\n", ActualFileName ); - free( t ); + ABC_FREE( t ); return fp; } } - free( t ); + ABC_FREE( t ); return 0; } else diff --git a/src/base/io/ioWriteAiger.c b/src/base/io/ioWriteAiger.c index 45e1e965..f1793a59 100644 --- a/src/base/io/ioWriteAiger.c +++ b/src/base/io/ioWriteAiger.c @@ -136,8 +136,8 @@ 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)(PORT_PTRINT_T)pObj->pCopy; } -static void Io_ObjSetAigerNum( Abc_Obj_t * pObj, unsigned Num ) { pObj->pCopy = (void *)(PORT_PTRINT_T)Num; } +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; } //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -331,7 +331,7 @@ void Io_WriteAiger_old( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, i // write the nodes into the buffer Pos = 0; nBufferSize = 6 * Abc_NtkNodeNum(pNtk) + 100; // skeptically assuming 3 chars per one AIG edge - pBuffer = ALLOC( unsigned char, nBufferSize ); + pBuffer = ABC_ALLOC( unsigned char, nBufferSize ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) ); Abc_AigForEachAnd( pNtk, pObj, i ) { @@ -354,7 +354,7 @@ void Io_WriteAiger_old( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, i // write the buffer fwrite( pBuffer, 1, Pos, pFile ); - free( pBuffer ); + ABC_FREE( pBuffer ); // write the symbol table if ( fWriteSymbols ) @@ -451,7 +451,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 = ALLOC( char, nBufferSize ); + pBuffer = ABC_ALLOC( char, nBufferSize ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) ); Abc_AigForEachAnd( pNtk, pObj, i ) { @@ -474,7 +474,7 @@ void Io_WriteAigerGz( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols ) // write the buffer gzwrite(pFile, pBuffer, Pos); - free( pBuffer ); + ABC_FREE( pBuffer ); // write the symbol table if ( fWriteSymbols ) @@ -534,7 +534,7 @@ int fprintfBz2Aig( bz2file * b, char * fmt, ... ) { b->nBytesMax = b->nBytes + 1; else b->nBytesMax *= 2; - if ((newBuf = REALLOC( char,b->buf,b->nBytesMax )) == NULL) + if ((newBuf = ABC_REALLOC( char,b->buf,b->nBytesMax )) == NULL) return -1; else b->buf = newBuf; @@ -594,14 +594,14 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f memset(&b,0,sizeof(b)); b.nBytesMax = (1<<12); - b.buf = ALLOC( char,b.nBytesMax ); + b.buf = ABC_ALLOC( char,b.nBytesMax ); // start the output stream b.f = fopen( pFileName, "wb" ); if ( b.f == NULL ) { fprintf( stdout, "Ioa_WriteBlif(): Cannot open the output file \"%s\".\n", pFileName ); - FREE(b.buf); + ABC_FREE(b.buf); return; } if (!strncmp(pFileName+strlen(pFileName)-4,".bz2",4)) { @@ -610,7 +610,7 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f BZ2_bzWriteClose( &bzError, b.b, 0, NULL, NULL ); fprintf( stdout, "Ioa_WriteBlif(): Cannot start compressed stream.\n" ); fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); return; } } @@ -663,7 +663,7 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f if (bzError == BZ_IO_ERROR) { fprintf( stdout, "Io_WriteAiger(): I/O error writing to compressed stream.\n" ); fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); return; } } @@ -674,7 +674,7 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f // write the nodes into the buffer Pos = 0; nBufferSize = 6 * Abc_NtkNodeNum(pNtk) + 100; // skeptically assuming 3 chars per one AIG edge - pBuffer = ALLOC( unsigned char, nBufferSize ); + pBuffer = ABC_ALLOC( unsigned char, nBufferSize ); pProgress = Extra_ProgressBarStart( stdout, Abc_NtkObjNumMax(pNtk) ); Abc_AigForEachAnd( pNtk, pObj, i ) { @@ -689,7 +689,7 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f { printf( "Io_WriteAiger(): AIGER generation has failed because the allocated buffer is too small.\n" ); fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); return; } } @@ -705,11 +705,11 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f if (bzError == BZ_IO_ERROR) { fprintf( stdout, "Io_WriteAiger(): I/O error writing to compressed stream.\n" ); fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); return; } } - free( pBuffer ); + ABC_FREE( pBuffer ); // write the symbol table if ( fWriteSymbols ) @@ -738,12 +738,12 @@ void Io_WriteAiger( Abc_Ntk_t * pNtk, char * pFileName, int fWriteSymbols, int f if (bzError == BZ_IO_ERROR) { fprintf( stdout, "Io_WriteAiger(): I/O error closing compressed stream.\n" ); fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); return; } } fclose( b.f ); - FREE(b.buf); + ABC_FREE(b.buf); } //////////////////////////////////////////////////////////////////////// diff --git a/src/base/io/ioWriteBaf.c b/src/base/io/ioWriteBaf.c index 6a9af2f2..1154e218 100644 --- a/src/base/io/ioWriteBaf.c +++ b/src/base/io/ioWriteBaf.c @@ -126,29 +126,29 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName ) Abc_NtkCleanCopy( pNtk ); nNodes = 1; Abc_NtkForEachCi( pNtk, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRINT_T)nNodes++; Abc_AigForEachAnd( pNtk, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRINT_T)nNodes++; // write the nodes into the buffer nAnds = 0; nBufferSize = Abc_NtkNodeNum(pNtk) * 2 + Abc_NtkCoNum(pNtk); - pBufferNode = ALLOC( unsigned, nBufferSize ); + pBufferNode = ABC_ALLOC( unsigned, nBufferSize ); pProgress = Extra_ProgressBarStart( stdout, nBufferSize ); Abc_AigForEachAnd( pNtk, pObj, i ) { Extra_ProgressBarUpdate( pProgress, nAnds, NULL ); - pBufferNode[nAnds++] = (((int)(PORT_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj); - pBufferNode[nAnds++] = (((int)(PORT_PTRINT_T)Abc_ObjFanin1(pObj)->pCopy) << 1) | Abc_ObjFaninC1(pObj); + 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); } // write the COs into the buffer Abc_NtkForEachCo( pNtk, pObj, i ) { Extra_ProgressBarUpdate( pProgress, nAnds, NULL ); - pBufferNode[nAnds] = (((int)(PORT_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj); + pBufferNode[nAnds] = (((int)(ABC_PTRINT_T)Abc_ObjFanin0(pObj)->pCopy) << 1) | Abc_ObjFaninC0(pObj); if ( Abc_ObjFanoutNum(pObj) > 0 && Abc_ObjIsLatch(Abc_ObjFanout0(pObj)) ) - pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((int)(PORT_PTRINT_T)Abc_ObjData(Abc_ObjFanout0(pObj)) & 3); + pBufferNode[nAnds] = (pBufferNode[nAnds] << 2) | ((int)(ABC_PTRINT_T)Abc_ObjData(Abc_ObjFanout0(pObj)) & 3); nAnds++; } Extra_ProgressBarStop( pProgress ); @@ -157,7 +157,7 @@ void Io_WriteBaf( Abc_Ntk_t * pNtk, char * pFileName ) // write the buffer fwrite( pBufferNode, 1, sizeof(int) * nBufferSize, pFile ); fclose( pFile ); - free( pBufferNode ); + ABC_FREE( pBufferNode ); } diff --git a/src/base/io/ioWriteBlif.c b/src/base/io/ioWriteBlif.c index 342dc0aa..dae8b783 100644 --- a/src/base/io/ioWriteBlif.c +++ b/src/base/io/ioWriteBlif.c @@ -434,7 +434,7 @@ void Io_NtkWriteLatch( FILE * pFile, Abc_Obj_t * pLatch ) int Reset; pNetLi = Abc_ObjFanin0( Abc_ObjFanin0(pLatch) ); pNetLo = Abc_ObjFanout0( Abc_ObjFanout0(pLatch) ); - Reset = (int)(PORT_PTRUINT_T)Abc_ObjData( pLatch ); + Reset = (int)(ABC_PTRUINT_T)Abc_ObjData( pLatch ); // write the latch line fprintf( pFile, ".latch" ); fprintf( pFile, " %10s", Abc_ObjName(pNetLi) ); diff --git a/src/base/io/ioWriteBlifMv.c b/src/base/io/ioWriteBlifMv.c index 266ee95f..e1494475 100644 --- a/src/base/io/ioWriteBlifMv.c +++ b/src/base/io/ioWriteBlifMv.c @@ -341,7 +341,7 @@ void Io_NtkWriteBlifMvLatch( FILE * pFile, Abc_Obj_t * pLatch ) int Reset; pNetLi = Abc_ObjFanin0( Abc_ObjFanin0(pLatch) ); pNetLo = Abc_ObjFanout0( Abc_ObjFanout0(pLatch) ); - Reset = (int)(PORT_PTRUINT_T)Abc_ObjData( pLatch ); + Reset = (int)(ABC_PTRUINT_T)Abc_ObjData( pLatch ); // write the latch line fprintf( pFile, ".latch" ); fprintf( pFile, " %10s", Abc_ObjName(pNetLi) ); diff --git a/src/base/io/ioWriteBook.c b/src/base/io/ioWriteBook.c index 95405438..322c3ef4 100644 --- a/src/base/io/ioWriteBook.c +++ b/src/base/io/ioWriteBook.c @@ -97,7 +97,7 @@ void Io_WriteBook( Abc_Ntk_t * pNtk, char * FileName ) FILE * pFileNodes, * pFileNets, * pFileAux; FILE * pFileScl, * pFilePl, * pFileWts; - char * FileExt = (char *)calloc(strlen(FileName)+7, sizeof(char)); + char * FileExt = ABC_CALLOC( char, strlen(FileName)+7 ); unsigned coreCellArea=0; Abc_Ntk_t * pExdc, * pNtkTemp; int i; @@ -156,7 +156,7 @@ void Io_WriteBook( Abc_Ntk_t * pNtk, char * FileName ) pFilePl = fopen( strcat(FileExt,".pl"), "w" ); strcpy(FileExt, FileName); pFileWts = fopen( strcat(FileExt,".wts"), "w" ); - free(FileExt); + ABC_FREE(FileExt); Io_NtkBuildLayout( pFileScl, pFilePl, pNtk, 1.0, 10, coreCellArea ); fclose( pFileScl ); @@ -555,7 +555,7 @@ void Io_NtkWriteScl( FILE * pFile, unsigned numCoreRows, double layoutWidth ) double sitewidth=1.0; double spacing=1.0; - int rowId; + unsigned rowId; // write the forehead fprintf( pFile, "UCLA scl 1.0\n\n" ); fprintf( pFile, "Numrows : %d\n\n", numCoreRows ); @@ -596,7 +596,8 @@ void Io_NtkWritePl( FILE * pFile, Abc_Ntk_t * pNtk, unsigned numTerms, double la double nextLoc_x, nextLoc_y; double delta; unsigned termsOnTop, termsOnBottom, termsOnLeft, termsOnRight; - int i, t; + unsigned t; + int i; termsOnTop = termsOnBottom = (unsigned)(Abc_Rint(numTerms*(layoutWidth/layoutPerim))); termsOnLeft = numTerms - (termsOnTop+termsOnBottom); @@ -609,7 +610,7 @@ void Io_NtkWritePl( FILE * pFile, Abc_Ntk_t * pNtk, unsigned numTerms, double la Vec_PtrPush( vTerms, pTerm ); // Ordering Pads vOrderedTerms=Io_NtkOrderingPads( pNtk, vTerms ); - assert( termsOnTop+termsOnBottom+termsOnLeft+termsOnRight == Vec_PtrSize(vOrderedTerms) ); + assert( termsOnTop+termsOnBottom+termsOnLeft+termsOnRight == (unsigned)Vec_PtrSize(vOrderedTerms) ); printf( "Done constructing layout region\n" ); printf( "Terminals: %d\n", numTerms ); @@ -714,11 +715,11 @@ 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 = (bool *)malloc(sizeof(bool)*numTerms); + bool * pOrdered = ABC_ALLOC(bool, numTerms); bool newNeighbor=1; Vec_Ptr_t * vOrderedTerms = Vec_PtrAlloc ( numTerms ); Abc_Obj_t * pNeighbor, * pNextTerm; - int i; + unsigned i; for( i=0 ; ipCopy = (Abc_Obj_t *)(PORT_PTRUINT_T)i; + pNode->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)i; // write the cubes pProgress = Extra_ProgressBarStart( stdout, nOutputs ); @@ -142,9 +142,9 @@ int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk ) if ( !Abc_ObjIsNode(pDriver) ) { assert( Abc_ObjIsCi(pDriver) ); - pCubeIn[(int)(PORT_PTRUINT_T)pDriver->pCopy] = '1' - Abc_ObjFaninC0(pNode); + pCubeIn[(int)(ABC_PTRUINT_T)pDriver->pCopy] = '1' - Abc_ObjFaninC0(pNode); fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut ); - pCubeIn[(int)(PORT_PTRUINT_T)pDriver->pCopy] = '-'; + pCubeIn[(int)(ABC_PTRUINT_T)pDriver->pCopy] = '-'; continue; } if ( Abc_NodeIsConst(pDriver) ) @@ -164,8 +164,8 @@ int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk ) Abc_ObjForEachFanin( pDriver, pFanin, k ) { pFanin = Abc_ObjFanin0Ntk(pFanin); - assert( (int)(PORT_PTRUINT_T)pFanin->pCopy < nInputs ); - pCubeIn[(int)(PORT_PTRUINT_T)pFanin->pCopy] = pCube[k]; + assert( (int)(ABC_PTRUINT_T)pFanin->pCopy < nInputs ); + pCubeIn[(int)(ABC_PTRUINT_T)pFanin->pCopy] = pCube[k]; } fprintf( pFile, "%s %s\n", pCubeIn, pCubeOut ); } @@ -174,7 +174,7 @@ int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk ) { pFanin = Abc_ObjFanin0Ntk(pFanin); assert( Abc_ObjIsCi(pFanin) ); - pCubeIn[(int)(PORT_PTRUINT_T)pFanin->pCopy] = '-'; + pCubeIn[(int)(ABC_PTRUINT_T)pFanin->pCopy] = '-'; } Extra_ProgressBarUpdate( pProgress, i, NULL ); } @@ -184,8 +184,8 @@ int Io_WritePlaOne( FILE * pFile, Abc_Ntk_t * pNtk ) // clean the CI nodes Abc_NtkForEachCi( pNtk, pNode, i ) pNode->pCopy = NULL; - free( pCubeIn ); - free( pCubeOut ); + ABC_FREE( pCubeIn ); + ABC_FREE( pCubeOut ); return 1; } diff --git a/src/base/io/ioWriteVerilog.c b/src/base/io/ioWriteVerilog.c index 41932dca..f2ac1b1d 100644 --- a/src/base/io/ioWriteVerilog.c +++ b/src/base/io/ioWriteVerilog.c @@ -549,7 +549,7 @@ void Io_WriteVerilogObjects( FILE * pFile, Abc_Ntk_t * pNtk ) fprintf( pFile, ";\n" ); // clear the input names Abc_ObjForEachFanin( pObj, pFanin, k ) - free( Hop_IthVar(pNtk->pManFunc, k)->pData ); + ABC_FREE( Hop_IthVar(pNtk->pManFunc, k)->pData ); } Vec_VecFree( vLevels ); } diff --git a/src/base/main/libSupport.c b/src/base/main/libSupport.c index 471ea09e..6bffc2bd 100644 --- a/src/base/main/libSupport.c +++ b/src/base/main/libSupport.c @@ -18,9 +18,10 @@ ***********************************************************************/ -#include "mainInt.h" #include #include +#include "mainInt.h" +#include "abc_global.h" #ifndef WIN32 # include @@ -50,10 +51,10 @@ void open_libs() { env = getenv ("ABC_LIB_PATH"); if (env == NULL) { // printf("Warning: ABC_LIB_PATH not defined. Looking into the current directory.\n"); - init_p = malloc (2*sizeof(char)); + init_p = ABC_ALLOC( char, (2*sizeof(char)) ); init_p[0]='.'; init_p[1] = 0; } else { - init_p = malloc ((strlen(env)+1)*sizeof(char)); + init_p = ABC_ALLOC( char, ((strlen(env)+1)*sizeof(char)) ); strcpy (init_p, env); } @@ -84,8 +85,8 @@ void open_libs() { // attempt to load it else { - char* szPrefixed = malloc((strlen(dp->d_name) + strlen(p) + 2) * - sizeof(char)); + char* szPrefixed = ABC_ALLOC( char, ((strlen(dp->d_name) + strlen(p) + 2) * + sizeof(char)) ); sprintf(szPrefixed, "%s/", p); strcat(szPrefixed, dp->d_name); libHandles[curr_lib] = dlopen(szPrefixed, RTLD_NOW | RTLD_LOCAL); @@ -98,7 +99,7 @@ void open_libs() { printf("Warning: failed to load ABC library %s:\n\t%s\n", szPrefixed, dlerror()); } - free(szPrefixed); + ABC_FREE(szPrefixed); } } } @@ -106,7 +107,7 @@ void open_libs() { p = endp+1; } - free(init_p); + ABC_FREE(init_p); #endif // null terminate the list of handles diff --git a/src/base/main/main.c b/src/base/main/main.c index a9d610fd..3aee2e44 100644 --- a/src/base/main/main.c +++ b/src/base/main/main.c @@ -21,7 +21,7 @@ #include "mainInt.h" // this line should be included in the library project -//#define _LIB +//#define ABC_LIB //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -33,7 +33,7 @@ static int TypeCheck( Abc_Frame_t * pAbc, char * s); /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#ifndef _LIB +#ifndef ABC_LIB /**Function************************************************************* @@ -55,7 +55,7 @@ int main( int argc, char * argv[] ) bool fBatch, fInitSource, fInitRead, fFinalWrite; // added to detect memory leaks: -#if defined(_DEBUG) && defined(_MSC_VER) && (_MSC_VER <= 1200) // 1200 = MSVC 6.0 +#if defined(_DEBUG) && defined(_MSC_VER) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif @@ -190,7 +190,7 @@ int main( int argc, char * argv[] ) } } - else + else { // start interactive mode // print the hello line @@ -254,7 +254,7 @@ void Abc_Start() { Abc_Frame_t * pAbc; // added to detect memory leaks: -#if defined(_DEBUG) && defined(_MSC_VER) && (_MSC_VER <= 1200) // 1200 = MSVC 6.0 +#if defined(_DEBUG) && defined(_MSC_VER) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // start the glocal frame diff --git a/src/base/main/main.h b/src/base/main/main.h index 159122d2..0c5aeb3e 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -21,18 +21,10 @@ #ifndef __MAIN_H__ #define __MAIN_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// TYPEDEFS /// //////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -/// STRUCTURE DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - // the framework containing all data typedef struct Abc_Frame_t_ Abc_Frame_t; @@ -54,10 +46,18 @@ typedef struct Abc_Frame_t_ Abc_Frame_t; /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// GLOBAL VARIABLES /// //////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +/// STRUCTURE DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -66,17 +66,6 @@ typedef struct Abc_Frame_t_ Abc_Frame_t; /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - /*=== main.c ===========================================================*/ extern ABC_DLL void Abc_Start(); extern ABC_DLL void Abc_Stop(); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 23e9184e..31e0afa9 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -102,7 +102,7 @@ Abc_Frame_t * Abc_FrameAllocate() extern void define_cube_size( int n ); extern void set_espresso_flags(); // allocate and clean - p = ALLOC( Abc_Frame_t, 1 ); + p = ABC_ALLOC( Abc_Frame_t, 1 ); memset( p, 0, sizeof(Abc_Frame_t) ); // get version p->sVersion = Abc_UtilsGetVersion( p ); @@ -149,7 +149,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) if ( p->dd ) Extra_StopManager( p->dd ); if ( p->vStore ) Vec_PtrFree( p->vStore ); Abc_FrameDeleteAllNetworks( p ); - free( p ); + ABC_FREE( p ); s_GlobalFrame = NULL; } diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index cfd945b7..e234d674 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -26,7 +26,6 @@ //////////////////////////////////////////////////////////////////////// #include "main.h" -#include "port_type.h" //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// @@ -80,6 +79,7 @@ struct Abc_Frame_t_ void * pAbc8Nwk; // the current mapped network void * pAbc8Aig; // the current AIG void * pAbc8Lib; // the current LUT library + void * pAig; // the addition to keep the best Ntl that can be used to restore void * pAbc8NtlBestDelay; // the best delay, Ntl @@ -99,17 +99,6 @@ struct Abc_Frame_t_ /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - /*=== mvMain.c ===========================================================*/ extern ABC_DLL int main( int argc, char * argv[] ); /*=== mvInit.c ===================================================*/ diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c index 46469490..f6751b6b 100644 --- a/src/base/main/mainUtils.c +++ b/src/base/main/mainUtils.c @@ -76,7 +76,7 @@ char * Abc_UtilsGetUsersInput( Abc_Frame_t * pAbc ) fgets( Prompt, 999, stdin ); return Prompt; #else - if (line != NULL) free(line); + if (line != NULL) ABC_FREE(line); line = readline(Prompt); if (line == NULL){ printf("***EOF***\n"); exit(0); } add_history(line); @@ -173,8 +173,8 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) (void) Cmd_CommandExecute(pAbc, "source -s .rc"); } } - if ( sPath1 ) FREE(sPath1); - if ( sPath2 ) FREE(sPath2); + if ( sPath1 ) ABC_FREE(sPath1); + if ( sPath2 ) ABC_FREE(sPath2); /* execute the abc script which can be open with the "open_path" */ Cmd_CommandExecute( pAbc, "source -s abc.rc" ); @@ -189,10 +189,10 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) // it from the home directory. Otherwise, read it from wherever it's located. home = getenv("HOME"); if (home){ - char * sPath3 = ALLOC(char, strlen(home) + 2); + char * sPath3 = ABC_ALLOC(char, strlen(home) + 2); (void) sprintf(sPath3, "%s/", home); sPath1 = Extra_UtilFileSearch(".abc.rc", sPath3, "r"); - FREE(sPath3); + ABC_FREE(sPath3); }else sPath1 = NULL; @@ -200,30 +200,30 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) if ( sPath1 && sPath2 ) { /* ~/.rc == .rc : Source the file only once */ - char *tmp_cmd = ALLOC(char, strlen(sPath1)+12); + char *tmp_cmd = ABC_ALLOC(char, strlen(sPath1)+12); (void) sprintf(tmp_cmd, "source -s %s", sPath1); // (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc"); (void) Cmd_CommandExecute(pAbc, tmp_cmd); - FREE(tmp_cmd); + ABC_FREE(tmp_cmd); } else { if (sPath1) { - char *tmp_cmd = ALLOC(char, strlen(sPath1)+12); + char *tmp_cmd = ABC_ALLOC(char, strlen(sPath1)+12); (void) sprintf(tmp_cmd, "source -s %s", sPath1); // (void) Cmd_CommandExecute(pAbc, "source -s ~/.abc.rc"); (void) Cmd_CommandExecute(pAbc, tmp_cmd); - FREE(tmp_cmd); + ABC_FREE(tmp_cmd); } if (sPath2) { - char *tmp_cmd = ALLOC(char, strlen(sPath2)+12); + char *tmp_cmd = ABC_ALLOC(char, strlen(sPath2)+12); (void) sprintf(tmp_cmd, "source -s %s", sPath2); // (void) Cmd_CommandExecute(pAbc, "source -s .abc.rc"); (void) Cmd_CommandExecute(pAbc, tmp_cmd); - FREE(tmp_cmd); + ABC_FREE(tmp_cmd); } } - if ( sPath1 ) FREE(sPath1); - if ( sPath2 ) FREE(sPath2); + if ( sPath1 ) ABC_FREE(sPath1); + if ( sPath2 ) ABC_FREE(sPath2); /* execute the abc script which can be open with the "open_path" */ Cmd_CommandExecute( pAbc, "source -s abc.rc" ); @@ -235,7 +235,7 @@ void Abc_UtilsSource( Abc_Frame_t * pAbc ) char * pName; int i; Vec_PtrForEachEntry( pAbc->aHistory, pName, i ) - free( pName ); + ABC_FREE( pName ); pAbc->aHistory->nSize = 0; } } diff --git a/src/base/seq/seq.h b/src/base/seq/seq.h index d3c9abda..3faca29e 100644 --- a/src/base/seq/seq.h +++ b/src/base/seq/seq.h @@ -21,10 +21,6 @@ #ifndef __SEQ_H__ #define __SEQ_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/seq/seqInt.h b/src/base/seq/seqInt.h index 221efc91..daa2ab38 100644 --- a/src/base/seq/seqInt.h +++ b/src/base/seq/seqInt.h @@ -21,10 +21,6 @@ #ifndef __SEQ_INT_H__ #define __SEQ_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -41,6 +37,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define SEQ_FULL_MASK 0xFFFFFFFF // node status after updating its arrival time diff --git a/src/base/ver/ver.h b/src/base/ver/ver.h index 9c538ac4..01199863 100644 --- a/src/base/ver/ver.h +++ b/src/base/ver/ver.h @@ -21,10 +21,6 @@ #ifndef __VER_H__ #define __VER_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -36,6 +32,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/ver/verCore.c b/src/base/ver/verCore.c index 93fc7b5d..f83747cf 100644 --- a/src/base/ver/verCore.c +++ b/src/base/ver/verCore.c @@ -101,7 +101,7 @@ struct Ver_Bundle_t_ Ver_Man_t * Ver_ParseStart( char * pFileName, Abc_Lib_t * pGateLib ) { Ver_Man_t * p; - p = ALLOC( Ver_Man_t, 1 ); + p = ABC_ALLOC( Ver_Man_t, 1 ); memset( p, 0, sizeof(Ver_Man_t) ); p->pFileName = pFileName; p->pReader = Ver_StreamAlloc( pFileName ); @@ -139,7 +139,7 @@ void Ver_ParseStop( Ver_Man_t * p ) Vec_PtrFree( p->vStackFn ); Vec_IntFree( p->vStackOp ); Vec_IntFree( p->vPerm ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -274,7 +274,7 @@ void Ver_ParsePrintErrorMessage( Ver_Man_t * p ) else // print the error message with the line number fprintf( p->Output, "%s (line %d): %s\n", p->pFileName, Ver_StreamGetLineNumber(p->pReader), p->sError ); - // free the data + // ABC_FREE the data Ver_ParseFreeData( p ); } @@ -583,7 +583,7 @@ int Ver_ParseInsertsSuffix( Ver_Man_t * pMan, char * pWord, int nMsb, int nLsb ) assert( nMsb >= 0 && nMsb < 128 ); assert( nLsb >= 0 && nLsb < 128 ); Value = (nMsb << 8) | nLsb; - st_insert( pMan->tName2Suffix, Extra_UtilStrsav(pWord), (char *)(PORT_PTRUINT_T)Value ); + st_insert( pMan->tName2Suffix, Extra_UtilStrsav(pWord), (char *)(ABC_PTRUINT_T)Value ); return 1; } @@ -605,7 +605,7 @@ void Ver_ParseRemoveSuffixTable( Ver_Man_t * pMan ) if ( pMan->tName2Suffix == NULL ) return; st_foreach_item( pMan->tName2Suffix, gen, (char **)&pKey, (char **)&pValue ) - free( pKey ); + ABC_FREE( pKey ); st_free_table( pMan->tName2Suffix ); pMan->tName2Suffix = NULL; } @@ -764,7 +764,7 @@ int Ver_ParseConstant( Ver_Man_t * pMan, char * pWord ) if ( pWord[i] == 'x' ) Vec_PtrPush( pMan->vNames, (void *)0 ); else - Vec_PtrPush( pMan->vNames, (void *)(PORT_PTRUINT_T)(pWord[i]-'0') ); + Vec_PtrPush( pMan->vNames, (void *)(ABC_PTRUINT_T)(pWord[i]-'0') ); } return 1; } @@ -1211,7 +1211,7 @@ int Ver_ParseAssign( Ver_Man_t * pMan, Abc_Ntk_t * pNtk ) Ver_ParsePrintErrorMessage( pMan ); return 0; } - Vec_PtrPush( pMan->vNames, (void *)(PORT_PTRUINT_T)strlen(pEquation) ); + 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()); @@ -1248,7 +1248,7 @@ int Ver_ParseAssign( Ver_Man_t * pMan, Abc_Ntk_t * pNtk ) for ( i = 0; i < Vec_PtrSize(pMan->vNames)/2; i++ ) { // get the name of this signal - Length = (int)(PORT_PTRUINT_T)Vec_PtrEntry( pMan->vNames, 2*i ); + Length = (int)(ABC_PTRUINT_T)Vec_PtrEntry( pMan->vNames, 2*i ); pName = Vec_PtrEntry( pMan->vNames, 2*i + 1 ); pName[Length] = 0; // find the corresponding net @@ -1716,7 +1716,7 @@ int Ver_ParseBox( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkBox ) } */ // allocate the bundle (formal name + array of actual nets) - pBundle = ALLOC( Ver_Bundle_t, 1 ); + pBundle = ABC_ALLOC( Ver_Bundle_t, 1 ); pBundle->pNameFormal = NULL; pBundle->vNetsActual = Vec_PtrAlloc( 4 ); Vec_PtrPush( vBundles, pBundle ); @@ -2002,9 +2002,9 @@ int Ver_ParseBox( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkBox ) ***********************************************************************/ void Ver_ParseFreeBundle( Ver_Bundle_t * pBundle ) { - FREE( pBundle->pNameFormal ); + ABC_FREE( pBundle->pNameFormal ); Vec_PtrFree( pBundle->vNetsActual ); - free( pBundle ); + ABC_FREE( pBundle ); } /**Function************************************************************* @@ -2088,7 +2088,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox ) i--; } - // free the bundling + // ABC_FREE the bundling Vec_PtrForEachEntry( vBundles, pBundle, k ) Ver_ParseFreeBundle( pBundle ); Vec_PtrFree( vBundles ); @@ -2205,7 +2205,7 @@ int Ver_ParseConnectBox( Ver_Man_t * pMan, Abc_Obj_t * pBox ) i--; } - // free the bundling + // ABC_FREE the bundling Vec_PtrForEachEntry( vBundles, pBundle, k ) Ver_ParseFreeBundle( pBundle ); Vec_PtrFree( vBundles ); @@ -2515,7 +2515,7 @@ int Ver_ParseDriveFormal( Ver_Man_t * pMan, Abc_Ntk_t * pNtk, Ver_Bundle_t * pBu Ver_ParseFreeBundle( pBundle ); Vec_PtrWriteEntry( (Vec_Ptr_t *)pBox->pCopy, j, NULL ); } - free( pName ); + ABC_FREE( pName ); return 1; } @@ -2604,7 +2604,7 @@ int Ver_ParseDriveInputs( Ver_Man_t * pMan, Vec_Ptr_t * vUndefs ) Vec_PtrWriteEntry( (Vec_Ptr_t *)pBox->pCopy, j, NULL ); } - // free the bundles + // ABC_FREE the bundles Vec_PtrFree( (Vec_Ptr_t *)pBox->pCopy ); pBox->pCopy = NULL; } @@ -2662,7 +2662,7 @@ void Ver_ParsePrintLog( Ver_Man_t * pMan ) // open the log file pNameGeneric = Extra_FileNameGeneric( pMan->pFileName ); sprintf( Buffer, "%s.log", pNameGeneric ); - free( pNameGeneric ); + ABC_FREE( pNameGeneric ); pFile = fopen( Buffer, "w" ); // count the total number of instances and how many times they occur diff --git a/src/base/ver/verFormula.c b/src/base/ver/verFormula.c index e9588ba9..3ed5f556 100644 --- a/src/base/ver/verFormula.c +++ b/src/base/ver/verFormula.c @@ -237,7 +237,7 @@ void * Ver_FormulaParser( char * pFormula, void * pMan, Vec_Ptr_t * vNames, Vec_ v = Ver_FormulaParserFindVar( pTemp, vNames ); if ( *pTemp == '\\' ) pTemp++; - pTemp += (int)(PORT_PTRUINT_T)Vec_PtrEntry( vNames, 2*v ) - 1; + pTemp += (int)(ABC_PTRUINT_T)Vec_PtrEntry( vNames, 2*v ) - 1; // assume operation AND, if vars follow one another if ( Flag == VER_PARSE_FLAG_VAR ) @@ -404,7 +404,7 @@ int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames ) nLength = pTemp - pString; for ( i = 0; i < Vec_PtrSize(vNames)/2; i++ ) { - nLength2 = (int)(PORT_PTRUINT_T)Vec_PtrEntry( vNames, 2*i + 0 ); + nLength2 = (int)(ABC_PTRUINT_T)Vec_PtrEntry( vNames, 2*i + 0 ); if ( nLength2 != nLength ) continue; pTemp2 = Vec_PtrEntry( vNames, 2*i + 1 ); @@ -413,7 +413,7 @@ int Ver_FormulaParserFindVar( char * pString, Vec_Ptr_t * vNames ) return i; } // could not find - add and return the number - Vec_PtrPush( vNames, (void *)(PORT_PTRUINT_T)nLength ); + Vec_PtrPush( vNames, (void *)(ABC_PTRUINT_T)nLength ); Vec_PtrPush( vNames, pString ); return i; } @@ -453,7 +453,7 @@ void * Ver_FormulaReduction( char * pFormula, void * pMan, Vec_Ptr_t * vNames, c while ( *pFormula != '}' ) { v = Ver_FormulaParserFindVar( pFormula, vNames ); - pFormula += (int)(PORT_PTRUINT_T)Vec_PtrEntry( vNames, 2*v ); + pFormula += (int)(ABC_PTRUINT_T)Vec_PtrEntry( vNames, 2*v ); while ( *pFormula == ' ' || *pFormula == ',' ) pFormula++; } diff --git a/src/base/ver/verStream.c b/src/base/ver/verStream.c index 9b56bb3f..8acaf5ec 100644 --- a/src/base/ver/verStream.c +++ b/src/base/ver/verStream.c @@ -81,7 +81,7 @@ Ver_Stream_t * Ver_StreamAlloc( char * pFileName ) return NULL; } // start the file reader - p = ALLOC( Ver_Stream_t, 1 ); + p = ABC_ALLOC( Ver_Stream_t, 1 ); memset( p, 0, sizeof(Ver_Stream_t) ); p->pFileName = pFileName; p->pFile = pFile; @@ -90,7 +90,7 @@ Ver_Stream_t * Ver_StreamAlloc( char * pFileName ) p->nFileSize = ftell( pFile ); rewind( pFile ); // allocate the buffer - p->pBuffer = ALLOC( char, VER_BUFFER_SIZE+1 ); + p->pBuffer = ABC_ALLOC( char, VER_BUFFER_SIZE+1 ); p->nBufferSize = VER_BUFFER_SIZE; p->pBufferCur = p->pBuffer; // determine how many chars to read @@ -153,8 +153,8 @@ void Ver_StreamFree( Ver_Stream_t * p ) { if ( p->pFile ) fclose( p->pFile ); - FREE( p->pBuffer ); - free( p ); + ABC_FREE( p->pBuffer ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/bdd/cas/cas.h b/src/bdd/cas/cas.h index fcc9f890..68a5c3a0 100644 --- a/src/bdd/cas/cas.h +++ b/src/bdd/cas/cas.h @@ -21,10 +21,6 @@ #ifndef __CAS_H__ #define __CAS_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define MAXINPUTS 1024 #define MAXOUTPUTS 1024 diff --git a/src/bdd/cas/casCore.c b/src/bdd/cas/casCore.c index a27e994f..4010235c 100644 --- a/src/bdd/cas/casCore.c +++ b/src/bdd/cas/casCore.c @@ -265,7 +265,7 @@ int Abc_CascadeExperiment( char * pFileGeneric, DdManager * dd, DdNode ** pOutpu // release the names for ( i = 0; i < nNames; i++ ) - free( pNames[i] ); + ABC_FREE( pNames[i] ); //fprintf( pTable, "\n" ); @@ -437,7 +437,7 @@ void Experiment2( BFunc * pFunc ) // release the names for ( i = 0; i < nNames; i++ ) - free( pNames[i] ); + ABC_FREE( pNames[i] ); diff --git a/src/bdd/cas/casDec.c b/src/bdd/cas/casDec.c index 3435f30d..25309d32 100644 --- a/src/bdd/cas/casDec.c +++ b/src/bdd/cas/casDec.c @@ -151,7 +151,7 @@ int CreateDecomposedNetwork( DdManager * dd, DdNode * aFunc, char ** pNames, int nLuts = 0; do { - p = (LUT*) malloc( sizeof(LUT) ); + p = (LUT*) ABC_ALLOC( char, sizeof(LUT) ); memset( p, 0, sizeof(LUT) ); if ( nVarsRem + PrevMulti <= s_LutSize ) // this is the last LUT @@ -194,9 +194,9 @@ int CreateDecomposedNetwork( DdManager * dd, DdNode * aFunc, char ** pNames, int // there should be as many columns, codes, and nodes, as there are columns on this level - p->pbCols = (DdNode **) malloc( p->nCols * sizeof(DdNode *) ); - p->pbCodes = (DdNode **) malloc( p->nCols * sizeof(DdNode *) ); - p->paNodes = (DdNode **) malloc( p->nCols * sizeof(DdNode *) ); + p->pbCols = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); + p->pbCodes = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); + p->paNodes = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); pLuts[nLuts] = p; nLuts++; @@ -316,7 +316,7 @@ printf( "Stage %3d: In = %3d InP = %3d Cols = %5d Multi = %2d Simple = %2d DdNode ** pbTemp; int k, v; - pbTemp = (DdNode **) malloc( p->nCols * sizeof(DdNode *) ); + pbTemp = (DdNode **) ABC_ALLOC( char, p->nCols * sizeof(DdNode *) ); // create the identical permutation for ( v = 0; v < dd->size; v++ ) @@ -336,7 +336,7 @@ printf( "Stage %3d: In = %3d InP = %3d Cols = %5d Multi = %2d Simple = %2d Cudd_RecursiveDeref( dd, p->pbCodes[k] ); p->pbCodes[k] = pbTemp[k]; } - free( pbTemp ); + ABC_FREE( pbTemp ); } } if ( fVerbose ) @@ -402,10 +402,10 @@ printf( "Stage %3d: In = %3d InP = %3d Cols = %5d Multi = %2d Simple = %2d } Cudd_RecursiveDeref( dd, p->bRelation ); - free( p->pbCols ); - free( p->pbCodes ); - free( p->paNodes ); - free( p ); + ABC_FREE( p->pbCols ); + ABC_FREE( p->pbCodes ); + ABC_FREE( p->paNodes ); + ABC_FREE( p ); } return 1; @@ -490,11 +490,11 @@ void WriteLUTSintoBLIFfile( FILE * pFile, DdManager * dd, LUT ** pLuts, int nLut for ( v = 0; v < dd->size; v++ ) { if ( pNamesLocalIn[v] ) - free( pNamesLocalIn[v] ); + ABC_FREE( pNamesLocalIn[v] ); pNamesLocalIn[v] = NULL; } for ( v = 0; v < p->nMulti; v++ ) - free( pNamesLocalOut[v] ); + ABC_FREE( pNamesLocalOut[v] ); } } diff --git a/src/bdd/cudd/cuddAPI.c b/src/bdd/cudd/cuddAPI.c index a16b82cf..cbba4d95 100644 --- a/src/bdd/cudd/cuddAPI.c +++ b/src/bdd/cudd/cuddAPI.c @@ -514,7 +514,7 @@ Cudd_zddVarsFromBddVars( dd->univ[i]->index = dd->invpermZ[i]; } } else { - permutation = ALLOC(int,dd->sizeZ); + permutation = ABC_ALLOC(int,dd->sizeZ); if (permutation == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -529,7 +529,7 @@ Cudd_zddVarsFromBddVars( permutation[i] = i; } res = Cudd_zddShuffleHeap(dd, permutation); - FREE(permutation); + ABC_FREE(permutation); if (res == 0) return(0); } /* Copy and expand the variable group tree if it exists. */ @@ -549,12 +549,12 @@ Cudd_zddVarsFromBddVars( if (multiplicity > 1) { char *vmask, *lmask; - vmask = ALLOC(char, dd->size); + vmask = ABC_ALLOC(char, dd->size); if (vmask == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - lmask = ALLOC(char, dd->size); + lmask = ABC_ALLOC(char, dd->size); if (lmask == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -563,8 +563,8 @@ Cudd_zddVarsFromBddVars( vmask[i] = lmask[i] = 0; } res = addMultiplicityGroups(dd,dd->treeZ,multiplicity,vmask,lmask); - FREE(vmask); - FREE(lmask); + ABC_FREE(vmask); + ABC_FREE(lmask); if (res == 0) return(0); } return(1); @@ -653,7 +653,7 @@ Cudd_AutodynEnable( if ((unsigned) unique->nextDead > unique->deadMask) { unique->nextDead = 0; } - unique->deathRow = REALLOC(DdNodePtr, unique->deathRow, + unique->deathRow = ABC_REALLOC(DdNodePtr, unique->deathRow, unique->deathRowDepth); #endif return; @@ -1740,7 +1740,7 @@ Cudd_ReadGarbageCollectionTime( Synopsis [Returns the number of nodes freed.] - Description [Returns the number of nodes returned to the free list if the + Description [Returns the number of nodes returned to the ABC_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 +3078,7 @@ Cudd_PrintInfo( Synopsis [Reports the peak number of nodes.] Description [Reports the peak number of nodes. This number includes - node on the free list. At the peak, the number of nodes on the free + node on the ABC_FREE list. At the peak, the number of nodes on the ABC_FREE list is guaranteed to be less than DD_MEM_CHUNK.] SideEffects [None] @@ -3244,7 +3244,7 @@ Cudd_AddHook( } /* The function was not in the list. Create a new item and append it ** to the end of the list. */ - newHook = ALLOC(DdHook,1); + newHook = ABC_ALLOC(DdHook,1); if (newHook == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -3298,7 +3298,7 @@ Cudd_RemoveHook( while (nextHook != NULL) { if (nextHook->f == f) { *hook = nextHook->next; - FREE(nextHook); + ABC_FREE(nextHook); return(1); } hook = &(nextHook->next); diff --git a/src/bdd/cudd/cuddAddWalsh.c b/src/bdd/cudd/cuddAddWalsh.c index 90a57b3c..3022b73d 100644 --- a/src/bdd/cudd/cuddAddWalsh.c +++ b/src/bdd/cudd/cuddAddWalsh.c @@ -146,14 +146,14 @@ Cudd_addResidue( tc = options & CUDD_RESIDUE_TC; /* Allocate and initialize working arrays. */ - array[0] = ALLOC(DdNode *,m); + array[0] = ABC_ALLOC(DdNode *,m); if (array[0] == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } - array[1] = ALLOC(DdNode *,m); + array[1] = ABC_ALLOC(DdNode *,m); if (array[1] == NULL) { - FREE(array[0]); + ABC_FREE(array[0]); dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } @@ -168,8 +168,8 @@ Cudd_addResidue( for (j = 0; j < i; j++) { Cudd_RecursiveDeref(dd,array[1][j]); } - FREE(array[0]); - FREE(array[1]); + ABC_FREE(array[0]); + ABC_FREE(array[1]); return(NULL); } cuddRef(tmp); @@ -193,8 +193,8 @@ Cudd_addResidue( for (j = 0; j < m; j++) { Cudd_RecursiveDeref(dd,array[previous][j]); } - FREE(array[0]); - FREE(array[1]); + ABC_FREE(array[0]); + ABC_FREE(array[1]); return(NULL); } cuddRef(var); @@ -208,8 +208,8 @@ Cudd_addResidue( for (j = 0; j < m; j++) { Cudd_RecursiveDeref(dd,array[previous][j]); } - FREE(array[0]); - FREE(array[1]); + ABC_FREE(array[0]); + ABC_FREE(array[1]); return(NULL); } cuddRef(tmp); @@ -234,8 +234,8 @@ Cudd_addResidue( } res = array[(n - 1) & 1][0]; - FREE(array[0]); - FREE(array[1]); + ABC_FREE(array[0]); + ABC_FREE(array[1]); cuddDeref(res); return(res); diff --git a/src/bdd/cudd/cuddAnneal.c b/src/bdd/cudd/cuddAnneal.c index 3d8b56b9..32155603 100644 --- a/src/bdd/cudd/cuddAnneal.c +++ b/src/bdd/cudd/cuddAnneal.c @@ -153,7 +153,7 @@ cuddAnnealing( /* Keep track of the best order. */ BestCost = size; - BestOrder = ALLOC(int,nvars); + BestOrder = ABC_ALLOC(int,nvars); if (BestOrder == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -218,7 +218,7 @@ cuddAnnealing( } if (!result) { - FREE(BestOrder); + ABC_FREE(BestOrder); return(0); } @@ -245,7 +245,7 @@ cuddAnnealing( } result = restoreOrder(table,BestOrder,lower,upper); - FREE(BestOrder); + ABC_FREE(BestOrder); if (!result) return(0); #ifdef DD_STATS fprintf(table->out,"#:N_EXCHANGE %8d : total exchanges\n",ecount); diff --git a/src/bdd/cudd/cuddApa.c b/src/bdd/cudd/cuddApa.c index 47ab51e8..13e80ce2 100644 --- a/src/bdd/cudd/cuddApa.c +++ b/src/bdd/cudd/cuddApa.c @@ -121,7 +121,7 @@ DdApaNumber Cudd_NewApaNumber( int digits) { - return(ALLOC(DdApaDigit, digits)); + return(ABC_ALLOC(DdApaDigit, digits)); } /* end of Cudd_NewApaNumber */ @@ -519,9 +519,9 @@ Cudd_ApaPrintDecimal( work = Cudd_NewApaNumber(digits); if (work == NULL) return(0); - decimal = ALLOC(unsigned char, decimalDigits); + decimal = ABC_ALLOC(unsigned char, decimalDigits); if (decimal == NULL) { - FREE(work); + ABC_FREE(work); return(0); } Cudd_ApaCopy(digits,number,work); @@ -529,7 +529,7 @@ Cudd_ApaPrintDecimal( remainder = Cudd_ApaShortDivision(digits,work,(DdApaDigit) 10,work); decimal[i] = remainder; } - FREE(work); + ABC_FREE(work); leadingzero = 1; for (i = 0; i < decimalDigits; i++) { @@ -537,12 +537,12 @@ Cudd_ApaPrintDecimal( if ((!leadingzero) || (i == (decimalDigits - 1))) { result = fprintf(fp,"%1d",decimal[i]); if (result == EOF) { - FREE(decimal); + ABC_FREE(decimal); return(0); } } } - FREE(decimal); + ABC_FREE(decimal); return(1); } /* end of Cudd_ApaPrintDecimal */ @@ -576,9 +576,9 @@ Cudd_ApaPrintExponential( work = Cudd_NewApaNumber(digits); if (work == NULL) return(0); - decimal = ALLOC(unsigned char, decimalDigits); + decimal = ABC_ALLOC(unsigned char, decimalDigits); if (decimal == NULL) { - FREE(work); + ABC_FREE(work); return(0); } Cudd_ApaCopy(digits,number,work); @@ -588,17 +588,17 @@ Cudd_ApaPrintExponential( decimal[i] = remainder; if (remainder != 0) first = i; /* keep track of MS non-zero */ } - FREE(work); + ABC_FREE(work); last = ddMin(first + precision, decimalDigits); for (i = first; i < last; i++) { result = fprintf(fp,"%s%1d",i == first+1 ? "." : "", decimal[i]); if (result == EOF) { - FREE(decimal); + ABC_FREE(decimal); return(0); } } - FREE(decimal); + ABC_FREE(decimal); result = fprintf(fp,"e+%d",decimalDigits - first - 1); if (result == EOF) { return(0); @@ -647,31 +647,31 @@ Cudd_ApaCountMinterm( Cudd_ApaPowerOfTwo(*digits,max,nvars); min = Cudd_NewApaNumber(*digits); if (min == NULL) { - FREE(max); + ABC_FREE(max); return(NULL); } Cudd_ApaSetToLiteral(*digits,min,0); table = st_init_table(st_ptrcmp,st_ptrhash); if (table == NULL) { - FREE(max); - FREE(min); + ABC_FREE(max); + ABC_FREE(min); return(NULL); } i = cuddApaCountMintermAux(Cudd_Regular(node),*digits,max,min,table); if (i == NULL) { - FREE(max); - FREE(min); + ABC_FREE(max); + ABC_FREE(min); st_foreach(table, cuddApaStCountfree, NULL); st_free_table(table); return(NULL); } count = Cudd_NewApaNumber(*digits); if (count == NULL) { - FREE(max); - FREE(min); + ABC_FREE(max); + ABC_FREE(min); st_foreach(table, cuddApaStCountfree, NULL); st_free_table(table); - if (Cudd_Regular(node)->ref == 1) FREE(i); + if (Cudd_Regular(node)->ref == 1) ABC_FREE(i); return(NULL); } if (Cudd_IsComplement(node)) { @@ -679,11 +679,11 @@ Cudd_ApaCountMinterm( } else { Cudd_ApaCopy(*digits,i,count); } - FREE(max); - FREE(min); + ABC_FREE(max); + ABC_FREE(min); st_foreach(table, cuddApaStCountfree, NULL); st_free_table(table); - if (Cudd_Regular(node)->ref == 1) FREE(i); + if (Cudd_Regular(node)->ref == 1) ABC_FREE(i); return(count); } /* end of Cudd_ApaCountMinterm */ @@ -717,7 +717,7 @@ Cudd_ApaPrintMinterm( if (count == NULL) return(0); result = Cudd_ApaPrintDecimal(fp,digits,count); - FREE(count); + ABC_FREE(count); if (fprintf(fp,"\n") == EOF) { return(0); } @@ -757,7 +757,7 @@ Cudd_ApaPrintMintermExp( if (count == NULL) return(0); result = Cudd_ApaPrintExponential(fp,digits,count,precision); - FREE(count); + ABC_FREE(count); if (fprintf(fp,"\n") == EOF) { return(0); } @@ -798,8 +798,8 @@ Cudd_ApaPrintDensity( density = Cudd_NewApaNumber(digits); remainder = Cudd_ApaIntDivision(digits,count,size,density); result = Cudd_ApaPrintDecimal(fp,digits,density); - FREE(count); - FREE(density); + ABC_FREE(count); + ABC_FREE(density); fractional = (unsigned int)((double)remainder / size * 1000000); if (fprintf(fp,".%u\n", fractional) == EOF) { return(0); @@ -869,13 +869,13 @@ cuddApaCountMintermAux( if (mint1 == NULL) return(NULL); mint2 = cuddApaCountMintermAux(Cudd_Regular(Ne), digits, max, min, table); if (mint2 == NULL) { - if (Nt->ref == 1) FREE(mint1); + if (Nt->ref == 1) ABC_FREE(mint1); return(NULL); } mint = Cudd_NewApaNumber(digits); if (mint == NULL) { - if (Nt->ref == 1) FREE(mint1); - if (Cudd_Regular(Ne)->ref == 1) FREE(mint2); + if (Nt->ref == 1) ABC_FREE(mint1); + if (Cudd_Regular(Ne)->ref == 1) ABC_FREE(mint2); return(NULL); } if (Cudd_IsComplement(Ne)) { @@ -888,12 +888,12 @@ cuddApaCountMintermAux( /* If the refernce count of a child is 1, its minterm count ** hasn't been stored in table. Therefore, it must be explicitly ** freed here. */ - if (Nt->ref == 1) FREE(mint1); - if (Cudd_Regular(Ne)->ref == 1) FREE(mint2); + if (Nt->ref == 1) ABC_FREE(mint1); + if (Cudd_Regular(Ne)->ref == 1) ABC_FREE(mint2); if (node->ref > 1) { if (st_insert(table, (char *)node, (char *)mint) == ST_OUT_OF_MEM) { - FREE(mint); + ABC_FREE(mint); return(NULL); } } @@ -922,7 +922,7 @@ cuddApaStCountfree( DdApaNumber d; d = (DdApaNumber) value; - FREE(d); + ABC_FREE(d); return(ST_CONTINUE); } /* end of cuddApaStCountfree */ diff --git a/src/bdd/cudd/cuddApprox.c b/src/bdd/cudd/cuddApprox.c index debcf48b..c575b54b 100644 --- a/src/bdd/cudd/cuddApprox.c +++ b/src/bdd/cudd/cuddApprox.c @@ -510,9 +510,9 @@ cuddUnderApprox( result = UAmarkNodes(dd, f, info, threshold, safe, quality); if (result == 0) { (void) fprintf(dd->err, "Out-of-memory; Cannot subset\n"); - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } @@ -524,9 +524,9 @@ cuddUnderApprox( (void) fprintf(dd->err, "Wrong prediction: %d versus actual %d\n", info->size, Cudd_DagSize(subset)); #endif - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); #ifdef DD_DEBUG if (subset != NULL) { @@ -600,9 +600,9 @@ cuddRemapUnderApprox( result = RAmarkNodes(dd, f, info, threshold, quality); if (result == 0) { (void) fprintf(dd->err, "Out-of-memory; Cannot subset\n"); - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } @@ -614,9 +614,9 @@ cuddRemapUnderApprox( (void) fprintf(dd->err, "Wrong prediction: %d versus actual %d\n", info->size, Cudd_DagSize(subset)); #endif - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); #ifdef DD_DEBUG if (subset != NULL) { @@ -694,9 +694,9 @@ cuddBiasedUnderApprox( if (result == CARE_ERROR) { (void) fprintf(dd->err, "Out-of-memory; Cannot subset\n"); cuddHashTableQuit(cache); - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } @@ -706,9 +706,9 @@ cuddBiasedUnderApprox( result = BAmarkNodes(dd, f, info, threshold, quality1, quality0); if (result == 0) { (void) fprintf(dd->err, "Out-of-memory; Cannot subset\n"); - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } @@ -720,9 +720,9 @@ cuddBiasedUnderApprox( (void) fprintf(dd->err, "Wrong prediction: %d versus actual %d\n", info->size, Cudd_DagSize(subset)); #endif - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); #ifdef DD_DEBUG if (subset != NULL) { @@ -891,7 +891,7 @@ gatherInfo( numVars = DBL_MAX_EXP - 1; } - info = ALLOC(ApproxInfo,1); + info = ABC_ALLOC(ApproxInfo,1); if (info == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -905,17 +905,17 @@ gatherInfo( ** efficiently because we have counted the number of nodes of the ** BDD. info->index points to the next available entry in the array ** that stores the per-node information. */ - info->page = ALLOC(NodeData,info->size); + info->page = ABC_ALLOC(NodeData,info->size); if (info->page == NULL) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(info); + ABC_FREE(info); return(NULL); } memset(info->page, 0, info->size * sizeof(NodeData)); /* clear all page */ info->table = st_init_table(st_ptrcmp,st_ptrhash); if (info->table == NULL) { - FREE(info->page); - FREE(info); + ABC_FREE(info->page); + ABC_FREE(info); return(NULL); } /* We visit the DAG in post-order DFS. Hence, the constant node is @@ -923,8 +923,8 @@ gatherInfo( /* Info for the constant node: Initialize only fields different from 0. */ if (st_insert(info->table, (char *)info->one, (char *)info->page) == ST_OUT_OF_MEM) { - FREE(info->page); - FREE(info); + ABC_FREE(info->page); + ABC_FREE(info); st_free_table(info->table); return(NULL); } @@ -933,9 +933,9 @@ gatherInfo( infoTop = gatherInfoAux(node,info,parity); if (infoTop == NULL) { - FREE(info->page); + ABC_FREE(info->page); st_free_table(info->table); - FREE(info); + ABC_FREE(info); return(NULL); } if (Cudd_IsComplement(node)) { diff --git a/src/bdd/cudd/cuddBddCorr.c b/src/bdd/cudd/cuddBddCorr.c index c99324a8..a532f31d 100644 --- a/src/bdd/cudd/cuddBddCorr.c +++ b/src/bdd/cudd/cuddBddCorr.c @@ -230,7 +230,7 @@ bddCorrelationAux( } /* From now on, f is regular. */ - entry = ALLOC(HashEntry,1); + entry = ABC_ALLOC(HashEntry,1); if (entry == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(CUDD_OUT_OF_MEM); @@ -243,7 +243,7 @@ bddCorrelationAux( */ if (st_lookup(table, (char *)entry, (char **)&dummy)) { min = *dummy; - FREE(entry); + ABC_FREE(entry); return(min); } @@ -259,17 +259,17 @@ bddCorrelationAux( min1 = bddCorrelationAux(dd, Fv, Gv, table) / 2.0; if (min1 == (double)CUDD_OUT_OF_MEM) { - FREE(entry); + ABC_FREE(entry); return(CUDD_OUT_OF_MEM); } min2 = bddCorrelationAux(dd, Fnv, Gnv, table) / 2.0; if (min2 == (double)CUDD_OUT_OF_MEM) { - FREE(entry); + ABC_FREE(entry); return(CUDD_OUT_OF_MEM); } min = (min1+min2); - pmin = ALLOC(double,1); + pmin = ABC_ALLOC(double,1); if (pmin == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return((double)CUDD_OUT_OF_MEM); @@ -277,8 +277,8 @@ bddCorrelationAux( *pmin = min; if (st_insert(table,(char *)entry, (char *)pmin) == ST_OUT_OF_MEM) { - FREE(entry); - FREE(pmin); + ABC_FREE(entry); + ABC_FREE(pmin); return((double)CUDD_OUT_OF_MEM); } return(min); @@ -333,7 +333,7 @@ bddCorrelationWeightsAux( } /* From now on, f is regular. */ - entry = ALLOC(HashEntry,1); + entry = ABC_ALLOC(HashEntry,1); if (entry == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return((double)CUDD_OUT_OF_MEM); @@ -346,7 +346,7 @@ bddCorrelationWeightsAux( */ if (st_lookup(table, (char *)entry, (char **)&dummy)) { min = *dummy; - FREE(entry); + ABC_FREE(entry); return(min); } @@ -368,17 +368,17 @@ bddCorrelationWeightsAux( min1 = bddCorrelationWeightsAux(dd, Fv, Gv, prob, table) * prob[index]; if (min1 == (double)CUDD_OUT_OF_MEM) { - FREE(entry); + ABC_FREE(entry); return((double)CUDD_OUT_OF_MEM); } min2 = bddCorrelationWeightsAux(dd, Fnv, Gnv, prob, table) * (1.0 - prob[index]); if (min2 == (double)CUDD_OUT_OF_MEM) { - FREE(entry); + ABC_FREE(entry); return((double)CUDD_OUT_OF_MEM); } min = (min1+min2); - pmin = ALLOC(double,1); + pmin = ABC_ALLOC(double,1); if (pmin == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return((double)CUDD_OUT_OF_MEM); @@ -386,8 +386,8 @@ bddCorrelationWeightsAux( *pmin = min; if (st_insert(table,(char *)entry, (char *)pmin) == ST_OUT_OF_MEM) { - FREE(entry); - FREE(pmin); + ABC_FREE(entry); + ABC_FREE(pmin); return((double)CUDD_OUT_OF_MEM); } return(min); @@ -472,9 +472,9 @@ CorrelCleanUp( HashEntry *entry; entry = (HashEntry *) key; - FREE(entry); + ABC_FREE(entry); d = (double *)value; - FREE(d); + ABC_FREE(d); return ST_CONTINUE; } /* end of CorrelCleanUp */ diff --git a/src/bdd/cudd/cuddCache.c b/src/bdd/cudd/cuddCache.c index d9e40921..e4aa0299 100644 --- a/src/bdd/cudd/cuddCache.c +++ b/src/bdd/cudd/cuddCache.c @@ -118,7 +118,7 @@ cuddInitCache( ** initial cache size. */ logSize = cuddComputeFloorLog2(ddMax(cacheSize,unique->slots/2)); cacheSize = 1 << logSize; - unique->acache = ALLOC(DdCache,cacheSize+1); + unique->acache = ABC_ALLOC(DdCache,cacheSize+1); if (unique->acache == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -741,14 +741,14 @@ cuddCacheProfile( imax = imin = 0; totalcount = 0.0; - hystogramQ = ALLOC(double, nbins); + hystogramQ = ABC_ALLOC(double, nbins); if (hystogramQ == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); } - hystogramR = ALLOC(double, nbins); + hystogramR = ABC_ALLOC(double, nbins); if (hystogramR == NULL) { - FREE(hystogramQ); + ABC_FREE(hystogramQ); table->errorCode = CUDD_MEMORY_OUT; return(0); } @@ -825,8 +825,8 @@ cuddCacheProfile( if (retval == EOF) return(0); } - FREE(hystogramQ); - FREE(hystogramR); + ABC_FREE(hystogramQ); + ABC_FREE(hystogramR); #else for (i = 0; i < slots; i++) { nzeroes += cache[i].h == 0; @@ -888,7 +888,7 @@ cuddCacheResize( saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - table->acache = cache = ALLOC(DdCache,slots+1); + table->acache = cache = ABC_ALLOC(DdCache,slots+1); MMoutOfMemory = saveHandler; /* If we fail to allocate the new table we just give up. */ if (cache == NULL) { @@ -944,7 +944,7 @@ cuddCacheResize( } } - FREE(oldacache); + ABC_FREE(oldacache); /* Reinitialize measurements so as to avoid division by 0 and ** immediate resizing. diff --git a/src/bdd/cudd/cuddCompose.c b/src/bdd/cudd/cuddCompose.c index 8c858051..43d65a5d 100644 --- a/src/bdd/cudd/cuddCompose.c +++ b/src/bdd/cudd/cuddCompose.c @@ -260,7 +260,7 @@ Cudd_addSwapVariables( int i, j, k; int *permut; - permut = ALLOC(int,dd->size); + permut = ABC_ALLOC(int,dd->size); if (permut == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -274,7 +274,7 @@ Cudd_addSwapVariables( } swapped = Cudd_addPermute(dd,f,permut); - FREE(permut); + ABC_FREE(permut); return(swapped); @@ -393,7 +393,7 @@ Cudd_SetVarMap ( if (manager->map != NULL) { cuddCacheFlush(manager); } else { - manager->map = ALLOC(int,manager->maxSize); + manager->map = ABC_ALLOC(int,manager->maxSize); if (manager->map == NULL) { manager->errorCode = CUDD_MEMORY_OUT; return(0); @@ -441,7 +441,7 @@ Cudd_bddSwapVariables( int i, j, k; int *permut; - permut = ALLOC(int,dd->size); + permut = ABC_ALLOC(int,dd->size); if (permut == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -455,7 +455,7 @@ Cudd_bddSwapVariables( } swapped = Cudd_bddPermute(dd,f,permut); - FREE(permut); + ABC_FREE(permut); return(swapped); @@ -488,7 +488,7 @@ Cudd_bddAdjPermuteX( int i, j, k; int *permut; - permut = ALLOC(int,dd->size); + permut = ABC_ALLOC(int,dd->size); if (permut == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -502,7 +502,7 @@ Cudd_bddAdjPermuteX( } swapped = Cudd_bddPermute(dd,B,permut); - FREE(permut); + ABC_FREE(permut); return(swapped); @@ -1520,17 +1520,17 @@ cuddAddNonSimComposeRecur( } /* Allocate two new vectors for the cofactors of vector. */ - vect1 = ALLOC(DdNode *,lastsub); + vect1 = ABC_ALLOC(DdNode *,lastsub); if (vect1 == NULL) { dd->errorCode = CUDD_MEMORY_OUT; Cudd_RecursiveDeref(dd,key1); return(NULL); } - vect0 = ALLOC(DdNode *,lastsub); + vect0 = ABC_ALLOC(DdNode *,lastsub); if (vect0 == NULL) { dd->errorCode = CUDD_MEMORY_OUT; Cudd_RecursiveDeref(dd,key1); - FREE(vect1); + ABC_FREE(vect1); return(NULL); } @@ -1552,15 +1552,15 @@ cuddAddNonSimComposeRecur( /* Recur on children. */ T = cuddAddNonSimComposeRecur(dd,f1,vect1,key1,cube1,lastsub); - FREE(vect1); + ABC_FREE(vect1); if (T == NULL) { Cudd_RecursiveDeref(dd,key1); - FREE(vect0); + ABC_FREE(vect0); return(NULL); } cuddRef(T); E = cuddAddNonSimComposeRecur(dd,f0,vect0,key0,cube1,lastsub); - FREE(vect0); + ABC_FREE(vect0); if (E == NULL) { Cudd_RecursiveDeref(dd,key1); Cudd_RecursiveDeref(dd,T); diff --git a/src/bdd/cudd/cuddDecomp.c b/src/bdd/cudd/cuddDecomp.c index 35a77b8c..871a99bb 100644 --- a/src/bdd/cudd/cuddDecomp.c +++ b/src/bdd/cudd/cuddDecomp.c @@ -130,7 +130,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 free it. On successful completion, the conjuncts are already + to ABC_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.] @@ -182,7 +182,7 @@ Cudd_bddApproxConjDecomp( if (glocal != DD_ONE(dd)) { if (hlocal != DD_ONE(dd)) { - *conjuncts = ALLOC(DdNode *,2); + *conjuncts = ABC_ALLOC(DdNode *,2); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,glocal); Cudd_RecursiveDeref(dd,hlocal); @@ -194,7 +194,7 @@ Cudd_bddApproxConjDecomp( return(2); } else { Cudd_RecursiveDeref(dd,hlocal); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,glocal); dd->errorCode = CUDD_MEMORY_OUT; @@ -205,7 +205,7 @@ Cudd_bddApproxConjDecomp( } } else { Cudd_RecursiveDeref(dd,glocal); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,hlocal); dd->errorCode = CUDD_MEMORY_OUT; @@ -229,7 +229,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 free it. On successful completion, the disjuncts are already + to ABC_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 +268,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 free it. On successful completion, the conjuncts are already + to ABC_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.] @@ -365,7 +365,7 @@ Cudd_bddIterConjDecomp( if (old[0] != DD_ONE(dd)) { if (old[1] != DD_ONE(dd)) { - *conjuncts = ALLOC(DdNode *,2); + *conjuncts = ABC_ALLOC(DdNode *,2); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,old[0]); Cudd_RecursiveDeref(dd,old[1]); @@ -377,7 +377,7 @@ Cudd_bddIterConjDecomp( return(2); } else { Cudd_RecursiveDeref(dd,old[1]); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,old[0]); dd->errorCode = CUDD_MEMORY_OUT; @@ -388,7 +388,7 @@ Cudd_bddIterConjDecomp( } } else { Cudd_RecursiveDeref(dd,old[0]); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,old[1]); dd->errorCode = CUDD_MEMORY_OUT; @@ -412,7 +412,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 free it. On successful completion, the disjuncts are already + to ABC_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 +452,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 free it. On successful completion, the conjuncts are already + to ABC_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.] @@ -484,7 +484,7 @@ Cudd_bddGenConjDecomp( if (glocal != one) { if (hlocal != one) { - *conjuncts = ALLOC(DdNode *,2); + *conjuncts = ABC_ALLOC(DdNode *,2); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,glocal); Cudd_RecursiveDeref(dd,hlocal); @@ -496,7 +496,7 @@ Cudd_bddGenConjDecomp( return(2); } else { Cudd_RecursiveDeref(dd,hlocal); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,glocal); dd->errorCode = CUDD_MEMORY_OUT; @@ -507,7 +507,7 @@ Cudd_bddGenConjDecomp( } } else { Cudd_RecursiveDeref(dd,glocal); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,hlocal); dd->errorCode = CUDD_MEMORY_OUT; @@ -531,7 +531,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 free it. On successful completion, the disjuncts are already + to ABC_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 +571,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 free it. On successful completion, the conjuncts are already + to ABC_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.] @@ -594,7 +594,7 @@ Cudd_bddVarConjDecomp( support = Cudd_Support(dd,f); if (support == NULL) return(0); if (Cudd_IsConstant(support)) { - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -639,7 +639,7 @@ Cudd_bddVarConjDecomp( if (glocal != DD_ONE(dd)) { if (hlocal != DD_ONE(dd)) { - *conjuncts = ALLOC(DdNode *,2); + *conjuncts = ABC_ALLOC(DdNode *,2); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,glocal); Cudd_RecursiveDeref(dd,hlocal); @@ -651,7 +651,7 @@ Cudd_bddVarConjDecomp( return(2); } else { Cudd_RecursiveDeref(dd,hlocal); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,glocal); dd->errorCode = CUDD_MEMORY_OUT; @@ -662,7 +662,7 @@ Cudd_bddVarConjDecomp( } } else { Cudd_RecursiveDeref(dd,glocal); - *conjuncts = ALLOC(DdNode *,1); + *conjuncts = ABC_ALLOC(DdNode *,1); if (*conjuncts == NULL) { Cudd_RecursiveDeref(dd,hlocal); dd->errorCode = CUDD_MEMORY_OUT; @@ -689,7 +689,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 free it. On successful completion, the disjuncts are already + to ABC_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.] @@ -777,7 +777,7 @@ CreateBotDist( */ distance = (distanceNv > distanceNnv) ? (distanceNv+1) : (distanceNnv + 1); - nodeStat = ALLOC(NodeStat, 1); + nodeStat = ABC_ALLOC(NodeStat, 1); if (nodeStat == NULL) { return(0); } @@ -847,7 +847,7 @@ CountMinterms( /* store */ - dummy = ALLOC(double, 1); + dummy = ABC_ALLOC(double, 1); if (dummy == NULL) return(-1.0); *dummy = min; if (st_insert(mintermTable, (char *)node, (char *)dummy) == ST_OUT_OF_MEM) { @@ -876,7 +876,7 @@ ConjunctsFree( { Cudd_RecursiveDeref(dd, factors->g); Cudd_RecursiveDeref(dd, factors->h); - FREE(factors); + ABC_FREE(factors); return; } /* end of ConjunctsFree */ @@ -978,7 +978,7 @@ CheckTablesCacheAndReturn( /* if both dont exist in table, we know one exists(either g or h). * Therefore store the other and proceed */ - factors = ALLOC(Conjuncts, 1); + factors = ABC_ALLOC(Conjuncts, 1); if (factors == NULL) return(NULL); if ((pairValue == BOTH_H) || (pairValue == H_ST)) { if (g != one) { @@ -1041,7 +1041,7 @@ CheckTablesCacheAndReturn( /* cache the result for this node */ if (st_insert(cacheTable, (char *)node, (char *)factors) == ST_OUT_OF_MEM) { - FREE(factors); + ABC_FREE(factors); return(NULL); } @@ -1078,7 +1078,7 @@ PickOnePair( Conjuncts *factors; int oneRef, twoRef; - factors = ALLOC(Conjuncts, 1); + factors = ABC_ALLOC(Conjuncts, 1); if (factors == NULL) return(NULL); /* count the number of pointers to pair 2 */ @@ -1120,7 +1120,7 @@ PickOnePair( value |= 1; if (st_insert(ghTable, (char *)Cudd_Regular(factors->g), (char *)(long)value) == ST_OUT_OF_MEM) { - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1128,7 +1128,7 @@ PickOnePair( value = 1; if (st_insert(ghTable, (char *)Cudd_Regular(factors->g), (char *)(long)value) == ST_OUT_OF_MEM) { - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1142,7 +1142,7 @@ PickOnePair( value |= 2; if (st_insert(ghTable, (char *)Cudd_Regular(factors->h), (char *)(long)value) == ST_OUT_OF_MEM) { - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1150,7 +1150,7 @@ PickOnePair( value = 2; if (st_insert(ghTable, (char *)Cudd_Regular(factors->h), (char *)(long)value) == ST_OUT_OF_MEM) { - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1159,7 +1159,7 @@ PickOnePair( /* Store factors in cache table for later use. */ if (st_insert(cacheTable, (char *)node, (char *)factors) == ST_OUT_OF_MEM) { - FREE(factors); + ABC_FREE(factors); return(NULL); } @@ -1208,7 +1208,7 @@ CheckInTables( return NULL; } - factors = ALLOC(Conjuncts, 1); + factors = ABC_ALLOC(Conjuncts, 1); if (factors == NULL) { *outOfMem = 1; return NULL; @@ -1236,7 +1236,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(h1), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1249,7 +1249,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(h1), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1262,7 +1262,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(g1), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1275,7 +1275,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(g1), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1288,7 +1288,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(h2), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1301,7 +1301,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(h2), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1314,7 +1314,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(g2), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1327,7 +1327,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(g2), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1340,7 +1340,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(h1), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1353,7 +1353,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(g1), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1366,7 +1366,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(h2), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1379,7 +1379,7 @@ CheckInTables( if (st_insert(ghTable, (char *)Cudd_Regular(g2), (char *)(long)value) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } } @@ -1389,7 +1389,7 @@ CheckInTables( if (st_insert(cacheTable, (char *)node, (char *)factors) == ST_OUT_OF_MEM) { *outOfMem = 1; - FREE(factors); + ABC_FREE(factors); return(NULL); } return factors; @@ -1438,7 +1438,7 @@ ZeroCase( /* Seprate variable and child */ if (factorsNv->g == one) { Cudd_RecursiveDeref(dd, factorsNv->g); - factors = ALLOC(Conjuncts, 1); + factors = ABC_ALLOC(Conjuncts, 1); if (factors == NULL) { dd->errorCode = CUDD_MEMORY_OUT; Cudd_RecursiveDeref(dd, factorsNv->h); @@ -1452,7 +1452,7 @@ ZeroCase( dd->errorCode = CUDD_MEMORY_OUT; Cudd_RecursiveDeref(dd, factorsNv->h); Cudd_RecursiveDeref(dd, x); - FREE(factors); + ABC_FREE(factors); return NULL; } @@ -1472,7 +1472,7 @@ ZeroCase( /* Seprate variable and child */ if (factorsNv->h == one) { Cudd_RecursiveDeref(dd, factorsNv->h); - factors = ALLOC(Conjuncts, 1); + factors = ABC_ALLOC(Conjuncts, 1); if (factors == NULL) { dd->errorCode = CUDD_MEMORY_OUT; Cudd_RecursiveDeref(dd, factorsNv->g); @@ -1486,7 +1486,7 @@ ZeroCase( dd->errorCode = CUDD_MEMORY_OUT; Cudd_RecursiveDeref(dd, factorsNv->g); Cudd_RecursiveDeref(dd, x); - FREE(factors); + ABC_FREE(factors); return(NULL); } /* store x in h table, the other node is already in the table */ @@ -1617,7 +1617,7 @@ ZeroCase( Cudd_RecursiveDeref(dd, g2); Cudd_RecursiveDeref(dd, h2); } else { - /* now free what was created and not used */ + /* now ABC_FREE what was created and not used */ if ((factors->g == g1) || (factors->g == h1)) { Cudd_RecursiveDeref(dd, g2); Cudd_RecursiveDeref(dd, h2); @@ -1676,7 +1676,7 @@ BuildConjuncts( /* if f is constant, return (f,f) */ if (Cudd_IsConstant(node)) { - factors = ALLOC(Conjuncts, 1); + factors = ABC_ALLOC(Conjuncts, 1); if (factors == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -1705,7 +1705,7 @@ BuildConjuncts( if (((nodeStat->localRef > maxLocalRef*2/3) && (distance < approxDistance*2/3)) || (distance <= approxDistance/4)) { - factors = ALLOC(Conjuncts, 1); + factors = ABC_ALLOC(Conjuncts, 1); if (factors == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -1737,7 +1737,7 @@ BuildConjuncts( value = 1; if (st_insert(ghTable, (char *)Cudd_Regular(node), (char *)(long)value) == ST_OUT_OF_MEM) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(factors); + ABC_FREE(factors); return NULL; } } else { @@ -1747,7 +1747,7 @@ BuildConjuncts( value = 2; if (st_insert(ghTable, (char *)Cudd_Regular(node), (char *)(long)value) == ST_OUT_OF_MEM) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(factors); + ABC_FREE(factors); return NULL; } } @@ -1804,7 +1804,7 @@ BuildConjuncts( /* is responsible for freeing factorsNv */ factors = ZeroCase(dd, node, factorsNv, ghTable, cacheTable, switched); - if (freeNv) FREE(factorsNv); + if (freeNv) ABC_FREE(factorsNv); return(factors); } } @@ -1817,7 +1817,7 @@ BuildConjuncts( if (factorsNnv == NULL) { Cudd_RecursiveDeref(dd, factorsNv->g); Cudd_RecursiveDeref(dd, factorsNv->h); - if (freeNv) FREE(factorsNv); + if (freeNv) ABC_FREE(factorsNv); return(NULL); } freeNnv = FactorsNotStored(factorsNnv); @@ -1830,7 +1830,7 @@ BuildConjuncts( /* is responsible for freeing factorsNv */ factors = ZeroCase(dd, node, factorsNnv, ghTable, cacheTable, switched); - if (freeNnv) FREE(factorsNnv); + if (freeNnv) ABC_FREE(factorsNnv); return(factors); } } @@ -1857,8 +1857,8 @@ BuildConjuncts( Cudd_RecursiveDeref(dd, factorsNv->h); Cudd_RecursiveDeref(dd, factorsNnv->g); Cudd_RecursiveDeref(dd, factorsNnv->h); - if (freeNv) FREE(factorsNv); - if (freeNnv) FREE(factorsNnv); + if (freeNv) ABC_FREE(factorsNv); + if (freeNnv) ABC_FREE(factorsNnv); return(NULL); } @@ -1871,8 +1871,8 @@ BuildConjuncts( Cudd_RecursiveDeref(dd, factorsNnv->g); Cudd_RecursiveDeref(dd, factorsNnv->h); Cudd_RecursiveDeref(dd, g1); - if (freeNv) FREE(factorsNv); - if (freeNnv) FREE(factorsNnv); + if (freeNv) ABC_FREE(factorsNv); + if (freeNnv) ABC_FREE(factorsNnv); return(NULL); } @@ -1886,8 +1886,8 @@ BuildConjuncts( Cudd_RecursiveDeref(dd, factorsNnv->h); Cudd_RecursiveDeref(dd, g1); Cudd_RecursiveDeref(dd, h1); - if (freeNv) FREE(factorsNv); - if (freeNnv) FREE(factorsNnv); + if (freeNv) ABC_FREE(factorsNv); + if (freeNnv) ABC_FREE(factorsNnv); return(NULL); } cuddRef(g2); @@ -1903,15 +1903,15 @@ BuildConjuncts( Cudd_RecursiveDeref(dd, g1); Cudd_RecursiveDeref(dd, h1); Cudd_RecursiveDeref(dd, g2); - if (freeNv) FREE(factorsNv); - if (freeNnv) FREE(factorsNnv); + if (freeNv) ABC_FREE(factorsNv); + if (freeNnv) ABC_FREE(factorsNnv); return(NULL); } cuddRef(h2); Cudd_RecursiveDeref(dd, factorsNv->h); Cudd_RecursiveDeref(dd, factorsNnv->g); - if (freeNv) FREE(factorsNv); - if (freeNnv) FREE(factorsNnv); + if (freeNv) ABC_FREE(factorsNv); + if (freeNnv) ABC_FREE(factorsNnv); /* check for each pair in tables and choose one */ factors = CheckInTables(node, g1, h1, g2, h2, ghTable, cacheTable, &outOfMem); @@ -1943,7 +1943,7 @@ BuildConjuncts( Cudd_RecursiveDeref(dd, g2); Cudd_RecursiveDeref(dd, h2); } else { - /* now free what was created and not used */ + /* now ABC_FREE what was created and not used */ if ((factors->g == g1) || (factors->g == h1)) { Cudd_RecursiveDeref(dd, g2); Cudd_RecursiveDeref(dd, h2); @@ -2000,7 +2000,7 @@ cuddConjunctsAux( if (distanceTable == NULL) goto outOfMem; /* make the entry for the constant */ - nodeStat = ALLOC(NodeStat, 1); + nodeStat = ABC_ALLOC(NodeStat, 1); if (nodeStat == NULL) goto outOfMem; nodeStat->distance = 0; nodeStat->localRef = 1; @@ -2024,7 +2024,7 @@ cuddConjunctsAux( stGen = st_init_gen(distanceTable); if (stGen == NULL) goto outOfMem; while(st_gen(stGen, (char **)&key, (char **)&value)) { - FREE(value); + ABC_FREE(value); } st_free_gen(stGen); stGen = NULL; st_free_table(distanceTable); @@ -2061,11 +2061,11 @@ cuddConjunctsAux( approxDistance, maxLocalRef, ghTable, mintermTable); if (factors == NULL) goto outOfMem; - /* free up tables */ + /* ABC_FREE up tables */ stGen = st_init_gen(distanceTable); if (stGen == NULL) goto outOfMem; while(st_gen(stGen, (char **)&key, (char **)&value)) { - FREE(value); + ABC_FREE(value); } st_free_gen(stGen); stGen = NULL; st_free_table(distanceTable); distanceTable = NULL; @@ -2074,7 +2074,7 @@ cuddConjunctsAux( stGen = st_init_gen(mintermTable); if (stGen == NULL) goto outOfMem; while(st_gen(stGen, (char **)&key, (char **)&value)) { - FREE(value); + ABC_FREE(value); } st_free_gen(stGen); stGen = NULL; st_free_table(mintermTable); mintermTable = NULL; @@ -2086,7 +2086,7 @@ cuddConjunctsAux( *c2 = factors->h; cuddRef(*c1); cuddRef(*c2); - if (freeFactors) FREE(factors); + if (freeFactors) ABC_FREE(factors); #if 0 if ((*c1 == f) && (!Cudd_IsConstant(f))) { @@ -2121,7 +2121,7 @@ outOfMem: stGen = st_init_gen(distanceTable); if (stGen == NULL) goto outOfMem; while(st_gen(stGen, (char **)&key, (char **)&value)) { - FREE(value); + ABC_FREE(value); } st_free_gen(stGen); stGen = NULL; st_free_table(distanceTable); distanceTable = NULL; @@ -2130,7 +2130,7 @@ outOfMem: stGen = st_init_gen(mintermTable); if (stGen == NULL) goto outOfMem; while(st_gen(stGen, (char **)&key, (char **)&value)) { - FREE(value); + ABC_FREE(value); } st_free_gen(stGen); stGen = NULL; st_free_table(mintermTable); mintermTable = NULL; diff --git a/src/bdd/cudd/cuddExact.c b/src/bdd/cudd/cuddExact.c index 6852be68..9472dd8b 100644 --- a/src/bdd/cudd/cuddExact.c +++ b/src/bdd/cudd/cuddExact.c @@ -188,19 +188,19 @@ cuddExact( newOrder = getMatrix(maxBinomial, size); if (newOrder == NULL) goto cuddExactOutOfMem; - newCost = ALLOC(int, maxBinomial); + newCost = ABC_ALLOC(int, maxBinomial); if (newCost == NULL) goto cuddExactOutOfMem; oldOrder = getMatrix(maxBinomial, size); if (oldOrder == NULL) goto cuddExactOutOfMem; - oldCost = ALLOC(int, maxBinomial); + oldCost = ABC_ALLOC(int, maxBinomial); if (oldCost == NULL) goto cuddExactOutOfMem; - bestOrder = ALLOC(DdHalfWord, size); + bestOrder = ABC_ALLOC(DdHalfWord, size); if (bestOrder == NULL) goto cuddExactOutOfMem; - mask = ALLOC(char, nvars); + mask = ABC_ALLOC(char, nvars); if (mask == NULL) goto cuddExactOutOfMem; symmInfo = initSymmInfo(table, lower, upper); @@ -289,22 +289,22 @@ cuddExact( freeMatrix(newOrder); freeMatrix(oldOrder); - FREE(bestOrder); - FREE(oldCost); - FREE(newCost); - FREE(symmInfo); - FREE(mask); + ABC_FREE(bestOrder); + ABC_FREE(oldCost); + ABC_FREE(newCost); + ABC_FREE(symmInfo); + ABC_FREE(mask); return(1); cuddExactOutOfMem: if (newOrder != NULL) freeMatrix(newOrder); if (oldOrder != NULL) freeMatrix(oldOrder); - if (bestOrder != NULL) FREE(bestOrder); - if (oldCost != NULL) FREE(oldCost); - if (newCost != NULL) FREE(newCost); - if (symmInfo != NULL) FREE(symmInfo); - if (mask != NULL) FREE(mask); + if (bestOrder != NULL) ABC_FREE(bestOrder); + if (oldCost != NULL) ABC_FREE(oldCost); + if (newCost != NULL) ABC_FREE(newCost); + if (symmInfo != NULL) ABC_FREE(symmInfo); + if (mask != NULL) ABC_FREE(mask); table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -335,7 +335,7 @@ getMaxBinomial( k = (n & ~1) >> 1; - numerator = ALLOC(int,k); + numerator = ABC_ALLOC(int,k); if (numerator == NULL) return(-1); for (i = 0; i < k; i++) @@ -358,7 +358,7 @@ getMaxBinomial( for (i = 0; i < k; i++) result *= numerator[i]; - FREE(numerator); + ABC_FREE(numerator); return(result); } /* end of getMaxBinomial */ @@ -440,9 +440,9 @@ getMatrix( int i; if (cols*rows == 0) return(NULL); - matrix = ALLOC(DdHalfWord *, rows); + matrix = ABC_ALLOC(DdHalfWord *, rows); if (matrix == NULL) return(NULL); - matrix[0] = ALLOC(DdHalfWord, cols*rows); + matrix[0] = ABC_ALLOC(DdHalfWord, cols*rows); if (matrix[0] == NULL) return(NULL); for (i = 1; i < rows; i++) { matrix[i] = matrix[i-1] + cols; @@ -467,8 +467,8 @@ static void freeMatrix( DdHalfWord ** matrix) { - FREE(matrix[0]); - FREE(matrix); + ABC_FREE(matrix[0]); + ABC_FREE(matrix); return; } /* end of freeMatrix */ @@ -956,7 +956,7 @@ initSymmInfo( int level, index, next, nextindex; DdHalfWord *symmInfo; - symmInfo = ALLOC(DdHalfWord, table->size); + symmInfo = ABC_ALLOC(DdHalfWord, table->size); if (symmInfo == NULL) return(NULL); for (level = lower; level <= upper; level++) { diff --git a/src/bdd/cudd/cuddExport.c b/src/bdd/cudd/cuddExport.c index d148be42..18caeaa0 100644 --- a/src/bdd/cudd/cuddExport.c +++ b/src/bdd/cudd/cuddExport.c @@ -119,7 +119,7 @@ Cudd_DumpBlif( int i; /* Build a bit array with the support of f. */ - sorted = ALLOC(int,nvars); + sorted = ABC_ALLOC(int,nvars); if (sorted == NULL) { dd->errorCode = CUDD_MEMORY_OUT; goto failure; @@ -136,7 +136,7 @@ Cudd_DumpBlif( scan = cuddT(scan); } Cudd_RecursiveDeref(dd,support); - support = NULL; /* so that we do not try to free it in case of failure */ + support = NULL; /* so that we do not try to ABC_FREE it in case of failure */ /* Write the header (.model .inputs .outputs). */ if (mname == NULL) { @@ -157,7 +157,7 @@ Cudd_DumpBlif( if (retval == EOF) goto failure; } } - FREE(sorted); + ABC_FREE(sorted); sorted = NULL; /* Write the .output line. */ @@ -184,7 +184,7 @@ Cudd_DumpBlif( return(1); failure: - if (sorted != NULL) FREE(sorted); + if (sorted != NULL) ABC_FREE(sorted); if (support != NULL) Cudd_RecursiveDeref(dd,support); return(0); @@ -325,7 +325,7 @@ Cudd_DumpDot( long refAddr, diff, mask; /* Build a bit array with the support of f. */ - sorted = ALLOC(int,nvars); + sorted = ABC_ALLOC(int,nvars); if (sorted == NULL) { dd->errorCode = CUDD_MEMORY_OUT; goto failure; @@ -342,7 +342,7 @@ Cudd_DumpDot( scan = cuddT(scan); } Cudd_RecursiveDeref(dd,support); - support = NULL; /* so that we do not try to free it in case of failure */ + support = NULL; /* so that we do not try to ABC_FREE it in case of failure */ /* Initialize symbol table for visited nodes. */ visited = st_init_table(st_ptrcmp, st_ptrhash); @@ -549,11 +549,11 @@ Cudd_DumpDot( if (retval == EOF) goto failure; st_free_table(visited); - FREE(sorted); + ABC_FREE(sorted); return(1); failure: - if (sorted != NULL) FREE(sorted); + if (sorted != NULL) ABC_FREE(sorted); if (support != NULL) Cudd_RecursiveDeref(dd,support); if (visited != NULL) st_free_table(visited); return(0); @@ -750,7 +750,7 @@ Cudd_DumpDDcal( st_free_table(visited); /* Build a bit array with the support of f. */ - sorted = ALLOC(int,nvars); + sorted = ABC_ALLOC(int,nvars); if (sorted == NULL) { dd->errorCode = CUDD_MEMORY_OUT; goto failure; @@ -767,7 +767,7 @@ Cudd_DumpDDcal( scan = cuddT(scan); } Cudd_RecursiveDeref(dd,support); - support = NULL; /* so that we do not try to free it in case of failure */ + support = NULL; /* so that we do not try to ABC_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) { @@ -780,7 +780,7 @@ Cudd_DumpDDcal( retval = fprintf(fp,"%s", i == nvars - 1 ? "\n" : " * "); if (retval == EOF) goto failure; } - FREE(sorted); + ABC_FREE(sorted); sorted = NULL; /* Initialize symbol table for visited nodes. */ @@ -822,7 +822,7 @@ Cudd_DumpDDcal( return(1); failure: - if (sorted != NULL) FREE(sorted); + if (sorted != NULL) ABC_FREE(sorted); if (support != NULL) Cudd_RecursiveDeref(dd,support); if (visited != NULL) st_free_table(visited); return(0); diff --git a/src/bdd/cudd/cuddGenCof.c b/src/bdd/cudd/cuddGenCof.c index 142ee27e..660526ee 100644 --- a/src/bdd/cudd/cuddGenCof.c +++ b/src/bdd/cudd/cuddGenCof.c @@ -302,7 +302,7 @@ Cudd_bddConstrainDecomp( int i; /* Create an initialize decomposition array. */ - decomp = ALLOC(DdNode *,dd->size); + decomp = ABC_ALLOC(DdNode *,dd->size); if (decomp == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -322,7 +322,7 @@ Cudd_bddConstrainDecomp( res = cuddBddConstrainDecomp(dd,f,decomp); } while (dd->reordered == 1); if (res == 0) { - FREE(decomp); + ABC_FREE(decomp); return(NULL); } /* Missing components are constant ones. */ @@ -442,7 +442,7 @@ Cudd_bddCharToVect( if (f == Cudd_Not(DD_ONE(dd))) return(NULL); - vect = ALLOC(DdNode *, dd->size); + vect = ABC_ALLOC(DdNode *, dd->size); if (vect == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -464,7 +464,7 @@ Cudd_bddCharToVect( } } while (dd->reordered == 1); if (res == NULL) { - FREE(vect); + ABC_FREE(vect); return(NULL); } return(vect); @@ -1460,14 +1460,14 @@ cuddBddLICMarkEdges( */ /* Check the cache. */ - key = ALLOC(MarkCacheKey, 1); + key = ABC_ALLOC(MarkCacheKey, 1); if (key == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(CUDD_OUT_OF_MEM); } key->f = f; key->c = c; if (st_lookup(cache, (char *)key, (char **)&res)) { - FREE(key); + ABC_FREE(key); if (comple) { if (res == DD_LIC_0) res = DD_LIC_1; else if (res == DD_LIC_1) res = DD_LIC_0; @@ -1498,12 +1498,12 @@ cuddBddLICMarkEdges( resT = cuddBddLICMarkEdges(dd, Fv, Cv, table, cache); if (resT == CUDD_OUT_OF_MEM) { - FREE(key); + ABC_FREE(key); return(CUDD_OUT_OF_MEM); } resE = cuddBddLICMarkEdges(dd, Fnv, Cnv, table, cache); if (resE == CUDD_OUT_OF_MEM) { - FREE(key); + ABC_FREE(key); return(CUDD_OUT_OF_MEM); } @@ -1515,7 +1515,7 @@ cuddBddLICMarkEdges( } else if (retval == 1) { *slot = (char *) (ptrint)((int)((ptrint) *slot) | (resT << 2) | resE); } else { - FREE(key); + ABC_FREE(key); return(CUDD_OUT_OF_MEM); } } @@ -1523,7 +1523,7 @@ cuddBddLICMarkEdges( /* Cache result. */ res = resT | resE; if (st_insert(cache, (char *)key, (char *)(ptrint)res) == ST_OUT_OF_MEM) { - FREE(key); + ABC_FREE(key); return(CUDD_OUT_OF_MEM); } @@ -1730,7 +1730,7 @@ MarkCacheCleanUp( MarkCacheKey *entry; entry = (MarkCacheKey *) key; - FREE(entry); + ABC_FREE(entry); return ST_CONTINUE; } /* end of MarkCacheCleanUp */ diff --git a/src/bdd/cudd/cuddGenetic.c b/src/bdd/cudd/cuddGenetic.c index 9fe03dad..3b10aecb 100644 --- a/src/bdd/cudd/cuddGenetic.c +++ b/src/bdd/cudd/cuddGenetic.c @@ -176,7 +176,7 @@ cuddGa( if (popsize < 4) popsize = 4; /* enforce minimum population size */ /* Allocate population table. */ - storedd = ALLOC(int,(popsize+2)*(numvars+1)); + storedd = ABC_ALLOC(int,(popsize+2)*(numvars+1)); if (storedd == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -190,10 +190,10 @@ cuddGa( ** one has a repeat count greater than 1. This copy is the one pointed ** by the computed table. */ - repeat = ALLOC(int,popsize); + repeat = ABC_ALLOC(int,popsize); if (repeat == NULL) { table->errorCode = CUDD_MEMORY_OUT; - FREE(storedd); + ABC_FREE(storedd); return(0); } for (i = 0; i < popsize; i++) { @@ -202,8 +202,8 @@ cuddGa( computed = st_init_table(array_compare,array_hash); if (computed == NULL) { table->errorCode = CUDD_MEMORY_OUT; - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); return(0); } @@ -215,8 +215,8 @@ cuddGa( /* Store the initial order in the computed table. */ if (st_insert(computed,(char *)storedd,(char *) 0) == ST_OUT_OF_MEM) { - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -234,16 +234,16 @@ cuddGa( */ if (!make_random(table,lower)) { table->errorCode = CUDD_MEMORY_OUT; - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } for (i = 1; i < popsize; i++) { result = build_dd(table,i,lower,upper); /* build and sift order */ if (!result) { - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -252,8 +252,8 @@ cuddGa( } else { if (st_insert(computed,(char *)&STOREDD(i,0),(char *)(long)i) == ST_OUT_OF_MEM) { - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -295,8 +295,8 @@ cuddGa( for (m = 0; m < cross; m++) { if (!PMX(table->size)) { /* perform one crossover */ table->errorCode = CUDD_MEMORY_OUT; - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -306,8 +306,8 @@ cuddGa( for (i = popsize; i <= popsize+1; i++) { result = build_dd(table,i,lower,upper); /* build and sift child */ if (!result) { - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -325,8 +325,8 @@ cuddGa( result = st_lookup(computed,(char *)&STOREDD(large,0),(char **)&index); if (!result) { - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -335,8 +335,8 @@ cuddGa( int *pointer = &STOREDD(index,0); result = st_delete(computed, (char **)&pointer,NULL); if (!result) { - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -354,8 +354,8 @@ cuddGa( } else { if (st_insert(computed,(char *)&STOREDD(large,0), (char *)(long)large) == ST_OUT_OF_MEM) { - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); st_free_table(computed); return(0); } @@ -380,8 +380,8 @@ cuddGa( st_free_table(computed); computed = NULL; result = build_dd(table,small,lower,upper); - FREE(storedd); - FREE(repeat); + ABC_FREE(storedd); + ABC_FREE(repeat); return(result); } /* end of cuddGa */ @@ -413,7 +413,7 @@ make_random( int *used; /* is a number already in a permutation */ int next; /* next random number without repetitions */ - used = ALLOC(int,numvars); + used = ABC_ALLOC(int,numvars); if (used == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -453,7 +453,7 @@ make_random( #endif #endif } - FREE(used); + ABC_FREE(used); return(1); } /* end of make_random */ @@ -761,20 +761,20 @@ PMX( int i; /* loop vars */ int u,v; /* aux vars */ - inv1 = ALLOC(int,maxvar); + inv1 = ABC_ALLOC(int,maxvar); if (inv1 == NULL) { return(0); } - inv2 = ALLOC(int,maxvar); + inv2 = ABC_ALLOC(int,maxvar); if (inv2 == NULL) { - FREE(inv1); + ABC_FREE(inv1); return(0); } /* Choose two orders from the population using roulette wheel. */ if (!roulette(&mom,&dad)) { - FREE(inv1); - FREE(inv2); + ABC_FREE(inv1); + ABC_FREE(inv2); return(0); } @@ -851,8 +851,8 @@ PMX( (void) fprintf(table->out,"\n"); #endif - FREE(inv1); - FREE(inv2); + ABC_FREE(inv1); + ABC_FREE(inv2); return(1); } /* end of PMX */ @@ -879,7 +879,7 @@ roulette( double spin; int i; - wheel = ALLOC(double,popsize); + wheel = ABC_ALLOC(double,popsize); if (wheel == NULL) { return(0); } @@ -914,7 +914,7 @@ roulette( } while (i == *p1); *p2 = i; - FREE(wheel); + ABC_FREE(wheel); return(1); } /* end of roulette */ diff --git a/src/bdd/cudd/cuddGroup.c b/src/bdd/cudd/cuddGroup.c index fbf8b6dd..3d987400 100644 --- a/src/bdd/cudd/cuddGroup.c +++ b/src/bdd/cudd/cuddGroup.c @@ -697,17 +697,17 @@ ddGroupSifting( /* Order variables to sift. */ entry = NULL; sifted = NULL; - var = ALLOC(int,nvars); + var = ABC_ALLOC(int,nvars); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto ddGroupSiftingOutOfMem; } - entry = ALLOC(int,nvars); + entry = ABC_ALLOC(int,nvars); if (entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto ddGroupSiftingOutOfMem; } - sifted = ALLOC(int,nvars); + sifted = ABC_ALLOC(int,nvars); if (sifted == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto ddGroupSiftingOutOfMem; @@ -838,16 +838,16 @@ ddGroupSifting( if (lazyFlag) ddSetVarHandled(table, xindex); } /* for */ - FREE(sifted); - FREE(var); - FREE(entry); + ABC_FREE(sifted); + ABC_FREE(var); + ABC_FREE(entry); return(1); ddGroupSiftingOutOfMem: - if (entry != NULL) FREE(entry); - if (var != NULL) FREE(var); - if (sifted != NULL) FREE(sifted); + if (entry != NULL) ABC_FREE(entry); + if (var != NULL) ABC_FREE(var); + if (sifted != NULL) ABC_FREE(sifted); return(0); diff --git a/src/bdd/cudd/cuddHarwell.c b/src/bdd/cudd/cuddHarwell.c index 59394ce4..45ff736c 100644 --- a/src/bdd/cudd/cuddHarwell.c +++ b/src/bdd/cudd/cuddHarwell.c @@ -223,12 +223,12 @@ Cudd_addHarwell( /* Allocate or reallocate arrays for variables as needed */ if (*nx == 0) { if (lnx > 0) { - *x = lx = ALLOC(DdNode *,lnx); + *x = lx = ABC_ALLOC(DdNode *,lnx); if (lx == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - *xn = lxn = ALLOC(DdNode *,lnx); + *xn = lxn = ABC_ALLOC(DdNode *,lnx); if (lxn == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -237,12 +237,12 @@ Cudd_addHarwell( *x = *xn = NULL; } } else if (lnx > *nx) { - *x = lx = REALLOC(DdNode *, *x, lnx); + *x = lx = ABC_REALLOC(DdNode *, *x, lnx); if (lx == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - *xn = lxn = REALLOC(DdNode *, *xn, lnx); + *xn = lxn = ABC_REALLOC(DdNode *, *xn, lnx); if (lxn == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -253,12 +253,12 @@ Cudd_addHarwell( } if (*ny == 0) { if (lny >0) { - *y = ly = ALLOC(DdNode *,lny); + *y = ly = ABC_ALLOC(DdNode *,lny); if (ly == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - *yn_ = lyn = ALLOC(DdNode *,lny); + *yn_ = lyn = ABC_ALLOC(DdNode *,lny); if (lyn == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -267,12 +267,12 @@ Cudd_addHarwell( *y = *yn_ = NULL; } } else if (lny > *ny) { - *y = ly = REALLOC(DdNode *, *y, lny); + *y = ly = ABC_REALLOC(DdNode *, *y, lny); if (ly == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - *yn_ = lyn = REALLOC(DdNode *, *yn_, lny); + *yn_ = lyn = ABC_REALLOC(DdNode *, *yn_, lny); if (lyn == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -323,12 +323,12 @@ Cudd_addHarwell( } /* Read structure data */ - colptr = ALLOC(int, ncol+1); + colptr = ABC_ALLOC(int, ncol+1); if (colptr == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - rowind = ALLOC(int, nnzero); + rowind = ABC_ALLOC(int, nnzero); if (rowind == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -337,12 +337,12 @@ Cudd_addHarwell( for (i=0; ierr,"%s: Unexpected colptr[0] (%d)\n", key,colptr[0]); - FREE(colptr); - FREE(rowind); + ABC_FREE(colptr); + ABC_FREE(rowind); return(0); } for (i=0; istash = ALLOC(char,(maxMemory / DD_STASH_FRACTION) + 4); + unique->stash = ABC_ALLOC(char,(maxMemory / DD_STASH_FRACTION) + 4); MMoutOfMemory = saveHandler; if (unique->stash == NULL) { (void) fprintf(unique->err,"Unable to set aside memory\n"); @@ -155,7 +155,7 @@ Cudd_Init( one = unique->one; zero = Cudd_Not(one); /* Create the projection functions. */ - unique->vars = ALLOC(DdNodePtr,unique->maxSize); + unique->vars = ABC_ALLOC(DdNodePtr,unique->maxSize); if (unique->vars == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -193,7 +193,7 @@ void Cudd_Quit( DdManager * unique) { - if (unique->stash != NULL) FREE(unique->stash); + if (unique->stash != NULL) ABC_FREE(unique->stash); cuddFreeTable(unique); } /* end of Cudd_Quit */ @@ -223,7 +223,7 @@ cuddZddInitUniv( DdNode *p, *res; int i; - zdd->univ = ALLOC(DdNodePtr, zdd->sizeZ); + zdd->univ = ABC_ALLOC(DdNodePtr, zdd->sizeZ); if (zdd->univ == NULL) { zdd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -237,7 +237,7 @@ cuddZddInitUniv( res = cuddUniqueInterZdd(zdd, index, p, p); if (res == NULL) { Cudd_RecursiveDerefZdd(zdd,p); - FREE(zdd->univ); + ABC_FREE(zdd->univ); return(0); } cuddRef(res); @@ -271,7 +271,7 @@ cuddZddFreeUniv( { if (zdd->univ) { Cudd_RecursiveDerefZdd(zdd, zdd->univ[0]); - FREE(zdd->univ); + ABC_FREE(zdd->univ); } } /* end of cuddZddFreeUniv */ diff --git a/src/bdd/cudd/cuddInt.h b/src/bdd/cudd/cuddInt.h index a5d0cf16..df843e33 100644 --- a/src/bdd/cudd/cuddInt.h +++ b/src/bdd/cudd/cuddInt.h @@ -346,7 +346,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 free nodes */ + DdNode *nextFree; /* list of ABC_FREE nodes */ char *stash; /* memory reserve */ #ifndef DD_NO_DEATH_ROW DdNode **deathRow; /* queue for dereferencing */ @@ -410,7 +410,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 free list */ + double nodesFreed; /* number of nodes returned to the ABC_FREE list */ double nodesDropped; /* number of nodes killed by dereferencing */ #endif unsigned int peakLiveNodes; /* maximum number of live nodes */ @@ -481,10 +481,10 @@ typedef struct DdLevelQueue { /**Macro*********************************************************************** - Synopsis [Adds node to the head of the free list.] + Synopsis [Adds node to the head of the ABC_FREE list.] - Description [Adds node to the head of the free list. Does not - deallocate memory chunks that become free. This function is also + Description [Adds node to the head of the ABC_FREE list. Does not + deallocate memory chunks that become ABC_FREE. This function is also used by the dynamic reordering functions.] SideEffects [None] diff --git a/src/bdd/cudd/cuddInteract.c b/src/bdd/cudd/cuddInteract.c index 96613639..3745b408 100644 --- a/src/bdd/cudd/cuddInteract.c +++ b/src/bdd/cudd/cuddInteract.c @@ -217,7 +217,7 @@ cuddInitInteract( int n = table->size; words = ((n * (n-1)) >> (1 + LOGBPL)) + 1; - table->interact = interact = ALLOC(long,words); + table->interact = interact = ABC_ALLOC(long,words); if (interact == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -226,10 +226,10 @@ cuddInitInteract( interact[i] = 0; } - support = ALLOC(int,n); + support = ABC_ALLOC(int,n); if (support == NULL) { table->errorCode = CUDD_MEMORY_OUT; - FREE(interact); + ABC_FREE(interact); return(0); } @@ -259,7 +259,7 @@ cuddInitInteract( } ddClearGlobal(table); - FREE(support); + ABC_FREE(support); return(1); } /* end of cuddInitInteract */ diff --git a/src/bdd/cudd/cuddLCache.c b/src/bdd/cudd/cuddLCache.c index 8bd37ba0..97546cda 100644 --- a/src/bdd/cudd/cuddLCache.c +++ b/src/bdd/cudd/cuddLCache.c @@ -158,7 +158,7 @@ cuddLocalCacheInit( DdLocalCache *cache; int logSize; - cache = ALLOC(DdLocalCache,1); + cache = ABC_ALLOC(DdLocalCache,1); if (cache == NULL) { manager->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -172,10 +172,10 @@ cuddLocalCacheInit( logSize = cuddComputeFloorLog2(ddMax(cacheSize,manager->slots/2)); cacheSize = 1 << logSize; cache->item = (DdLocalCacheItem *) - ALLOC(char, cacheSize * cache->itemsize); + ABC_ALLOC(char, cacheSize * cache->itemsize); if (cache->item == NULL) { manager->errorCode = CUDD_MEMORY_OUT; - FREE(cache); + ABC_FREE(cache); return(NULL); } cache->slots = cacheSize; @@ -218,8 +218,8 @@ cuddLocalCacheQuit( cache->manager->memused -= cache->slots * cache->itemsize + sizeof(DdLocalCache); cuddLocalCacheRemoveFromList(cache); - FREE(cache->item); - FREE(cache); + ABC_FREE(cache->item); + ABC_FREE(cache); return; @@ -422,7 +422,7 @@ cuddLocalCacheProfile( imax = imin = nzeroes = 0; totalcount = 0.0; - hystogram = ALLOC(long, nbins); + hystogram = ABC_ALLOC(long, nbins); if (hystogram == NULL) { return(0); } @@ -482,7 +482,7 @@ cuddLocalCacheProfile( if (retval == EOF) return(0); } - FREE(hystogram); + ABC_FREE(hystogram); return(1); } /* end of cuddLocalCacheProfile */ @@ -514,7 +514,7 @@ cuddHashTableInit( #pragma pointer_size save #pragma pointer_size short #endif - hash = ALLOC(DdHashTable, 1); + hash = ABC_ALLOC(DdHashTable, 1); if (hash == NULL) { manager->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -530,10 +530,10 @@ cuddHashTableInit( logSize = cuddComputeFloorLog2(initSize); hash->numBuckets = 1 << logSize; hash->shift = sizeof(int) * 8 - logSize; - hash->bucket = ALLOC(DdHashItem *, hash->numBuckets); + hash->bucket = ABC_ALLOC(DdHashItem *, hash->numBuckets); if (hash->bucket == NULL) { manager->errorCode = CUDD_MEMORY_OUT; - FREE(hash); + ABC_FREE(hash); return(NULL); } memset(hash->bucket, 0, hash->numBuckets * sizeof(DdHashItem *)); @@ -583,12 +583,12 @@ cuddHashTableQuit( memlist = hash->memoryList; while (memlist != NULL) { nextmem = (DdHashItem **) memlist[0]; - FREE(memlist); + ABC_FREE(memlist); memlist = nextmem; } - FREE(hash->bucket); - FREE(hash); + ABC_FREE(hash->bucket); + ABC_FREE(hash); #ifdef __osf__ #pragma pointer_size restore #endif @@ -658,7 +658,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 free list.] + dereferenced, and the entry is returned to the ABC_FREE list.] SideEffects [None] @@ -773,7 +773,7 @@ cuddHashTableInsert1( Returns the value associated to the key if there 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 free + value of the entry is dereferenced, and the entry is returned to the ABC_FREE list.] SideEffects [None] @@ -882,7 +882,7 @@ cuddHashTableInsert2( Returns the value associated to the key if there 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 free + value of the entry is dereferenced, and the entry is returned to the ABC_FREE list.] SideEffects [None] @@ -994,7 +994,7 @@ cuddHashTableInsert3( Returns the value associated to the key if there 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 free + value of the entry is dereferenced, and the entry is returned to the ABC_FREE list.] SideEffects [None] @@ -1090,7 +1090,7 @@ cuddLocalCacheResize( saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; cache->item = item = - (DdLocalCacheItem *) ALLOC(char, slots * cache->itemsize); + (DdLocalCacheItem *) ABC_ALLOC(char, slots * cache->itemsize); MMoutOfMemory = saveHandler; /* If we fail to allocate the new table we just give up. */ if (item == NULL) { @@ -1121,7 +1121,7 @@ cuddLocalCacheResize( } } - FREE(olditem); + ABC_FREE(olditem); /* Reinitialize measurements so as to avoid division by 0 and ** immediate resizing. @@ -1272,7 +1272,7 @@ cuddHashTableResize( #pragma pointer_size save #pragma pointer_size short #endif - buckets = ALLOC(DdHashItem *, numBuckets); + buckets = ABC_ALLOC(DdHashItem *, numBuckets); MMoutOfMemory = saveHandler; if (buckets == NULL) { hash->maxsize <<= 1; @@ -1335,7 +1335,7 @@ cuddHashTableResize( } } } - FREE(oldBuckets); + ABC_FREE(oldBuckets); return(1); } /* end of cuddHashTableResize */ @@ -1373,14 +1373,14 @@ cuddHashTableAlloc( if (hash->nextFree == NULL) { saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - mem = (DdHashItem **) ALLOC(char,(DD_MEM_CHUNK+1) * itemsize); + mem = (DdHashItem **) ABC_ALLOC(char,(DD_MEM_CHUNK+1) * itemsize); MMoutOfMemory = saveHandler; #ifdef __osf__ #pragma pointer_size restore #endif if (mem == NULL) { if (hash->manager->stash != NULL) { - FREE(hash->manager->stash); + ABC_FREE(hash->manager->stash); hash->manager->stash = NULL; /* Inhibit resizing of tables. */ hash->manager->maxCacheHard = hash->manager->cacheSlots - 1; @@ -1395,7 +1395,7 @@ cuddHashTableAlloc( #pragma pointer_size save #pragma pointer_size short #endif - mem = (DdHashItem **) ALLOC(char,(DD_MEM_CHUNK+1) * itemsize); + mem = (DdHashItem **) ABC_ALLOC(char,(DD_MEM_CHUNK+1) * itemsize); #ifdef __osf__ #pragma pointer_size restore #endif diff --git a/src/bdd/cudd/cuddLevelQ.c b/src/bdd/cudd/cuddLevelQ.c index 3cc8e8d8..28823a83 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 - free list for efficiency. + ABC_FREE list for efficiency. Internal procedures provided by this module:
    @@ -125,7 +125,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 free list when dequeued for + BDD top-down. Queue items are kept in a ABC_FREE list when dequeued for efficiency. Returns a pointer to the new queue if successful; NULL otherwise.] @@ -143,7 +143,7 @@ cuddLevelQueueInit( DdLevelQueue *queue; int logSize; - queue = ALLOC(DdLevelQueue,1); + queue = ABC_ALLOC(DdLevelQueue,1); if (queue == NULL) return(NULL); #ifdef __osf__ @@ -151,12 +151,12 @@ cuddLevelQueueInit( #pragma pointer_size short #endif /* Keep pointers to the insertion points for all levels. */ - queue->last = ALLOC(DdQueueItem *, levels); + queue->last = ABC_ALLOC(DdQueueItem *, levels); #ifdef __osf__ #pragma pointer_size restore #endif if (queue->last == NULL) { - FREE(queue); + ABC_FREE(queue); return(NULL); } /* Use a hash table to test for uniqueness. */ @@ -168,13 +168,13 @@ cuddLevelQueueInit( #pragma pointer_size save #pragma pointer_size short #endif - queue->buckets = ALLOC(DdQueueItem *, queue->numBuckets); + queue->buckets = ABC_ALLOC(DdQueueItem *, queue->numBuckets); #ifdef __osf__ #pragma pointer_size restore #endif if (queue->buckets == NULL) { - FREE(queue->last); - FREE(queue); + ABC_FREE(queue->last); + ABC_FREE(queue); return(NULL); } #ifdef __osf__ @@ -218,16 +218,16 @@ cuddLevelQueueQuit( while (queue->freelist != NULL) { item = queue->freelist; queue->freelist = item->next; - FREE(item); + ABC_FREE(item); } while (queue->first != NULL) { item = (DdQueueItem *) queue->first; queue->first = item->next; - FREE(item); + ABC_FREE(item); } - FREE(queue->buckets); - FREE(queue->last); - FREE(queue); + ABC_FREE(queue->buckets); + ABC_FREE(queue->last); + ABC_FREE(queue); return; } /* end of cuddLevelQueueQuit */ @@ -263,9 +263,9 @@ cuddLevelQueueEnqueue( item = hashLookup(queue,key); if (item != NULL) return(item); - /* Get a free item from either the free list or the memory manager. */ + /* Get a ABC_FREE item from either the ABC_FREE list or the memory manager. */ if (queue->freelist == NULL) { - item = (DdQueueItem *) ALLOC(char, queue->itemsize); + item = (DdQueueItem *) ABC_ALLOC(char, queue->itemsize); if (item == NULL) return(NULL); } else { @@ -335,7 +335,7 @@ cuddLevelQueueDequeue( queue->last[level] = NULL; queue->first = item->next; - /* Put item on the free list. */ + /* Put item on the ABC_FREE list. */ item->next = queue->freelist; queue->freelist = item; /* Update stats. */ @@ -504,7 +504,7 @@ hashResize( #pragma pointer_size save #pragma pointer_size short #endif - buckets = queue->buckets = ALLOC(DdQueueItem *, numBuckets); + buckets = queue->buckets = ABC_ALLOC(DdQueueItem *, numBuckets); if (buckets == NULL) { queue->maxsize <<= 1; return(1); @@ -527,7 +527,7 @@ hashResize( item = next; } } - FREE(oldBuckets); + ABC_FREE(oldBuckets); return(1); } /* end of hashResize */ diff --git a/src/bdd/cudd/cuddLinear.c b/src/bdd/cudd/cuddLinear.c index 95624a9e..30537e6c 100644 --- a/src/bdd/cudd/cuddLinear.c +++ b/src/bdd/cudd/cuddLinear.c @@ -251,12 +251,12 @@ cuddLinearAndSifting( } /* Find order in which to sift variables. */ - entry = ALLOC(int,size); + entry = ABC_ALLOC(int,size); if (entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddLinearAndSiftingOutOfMem; } - var = ALLOC(int,size); + var = ABC_ALLOC(int,size); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddLinearAndSiftingOutOfMem; @@ -295,8 +295,8 @@ cuddLinearAndSifting( #endif } - FREE(var); - FREE(entry); + ABC_FREE(var); + ABC_FREE(entry); #ifdef DD_STATS (void) fprintf(table->out,"\n#:L_LINSIFT %8d: linear trans.", @@ -307,8 +307,8 @@ cuddLinearAndSifting( cuddLinearAndSiftingOutOfMem: - if (entry != NULL) FREE(entry); - if (var != NULL) FREE(var); + if (entry != NULL) ABC_FREE(entry); + if (var != NULL) ABC_FREE(var); return(0); @@ -1220,7 +1220,7 @@ cuddInitLinear( nvars = table->size; wordsPerRow = ((nvars - 1) >> LOGBPL) + 1; words = wordsPerRow * nvars; - table->linear = linear = ALLOC(long,words); + table->linear = linear = ABC_ALLOC(long,words); if (linear == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -1269,7 +1269,7 @@ cuddResizeLinear( nvars = table->size; wordsPerRow = ((nvars - 1) >> LOGBPL) + 1; words = wordsPerRow * nvars; - table->linear = linear = ALLOC(long,words); + table->linear = linear = ABC_ALLOC(long,words); if (linear == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -1285,7 +1285,7 @@ cuddResizeLinear( linear[word] = oldLinear[oldWord]; } } - FREE(oldLinear); + ABC_FREE(oldLinear); /* Add elements to the diagonal. */ for (i = oldNvars; i < nvars; i++) { diff --git a/src/bdd/cudd/cuddMatMult.c b/src/bdd/cudd/cuddMatMult.c index 345e7921..75e5a732 100644 --- a/src/bdd/cudd/cuddMatMult.c +++ b/src/bdd/cudd/cuddMatMult.c @@ -110,7 +110,7 @@ Cudd_addMatrixMultiply( /* Array vars says what variables are "summation" variables. */ nvars = dd->size; - vars = ALLOC(int,nvars); + vars = ABC_ALLOC(int,nvars); if (vars == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -126,7 +126,7 @@ Cudd_addMatrixMultiply( dd->reordered = 0; res = addMMRecur(dd,A,B,-1,vars); } while (dd->reordered == 1); - FREE(vars); + ABC_FREE(vars); return(res); } /* end of Cudd_addMatrixMultiply */ @@ -220,7 +220,7 @@ Cudd_addTriangle( DdNode *res, *cube; nvars = dd->size; - vars = ALLOC(int, nvars); + vars = ABC_ALLOC(int, nvars); if (vars == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -229,7 +229,7 @@ Cudd_addTriangle( for (i = 0; i < nz; i++) vars[z[i]->index] = i; cube = Cudd_addComputeCube(dd, z, NULL, nz); if (cube == NULL) { - FREE(vars); + ABC_FREE(vars); return(NULL); } cuddRef(cube); @@ -241,7 +241,7 @@ Cudd_addTriangle( if (res != NULL) cuddRef(res); Cudd_RecursiveDeref(dd,cube); if (res != NULL) cuddDeref(res); - FREE(vars); + ABC_FREE(vars); return(res); } /* end of Cudd_addTriangle */ diff --git a/src/bdd/cudd/cuddPriority.c b/src/bdd/cudd/cuddPriority.c index 2895fa0b..af07c7f0 100644 --- a/src/bdd/cudd/cuddPriority.c +++ b/src/bdd/cudd/cuddPriority.c @@ -157,7 +157,7 @@ Cudd_PrioritySelect( /* Create z variables if needed. */ if (z == NULL) { if (Pi != NULL) return(NULL); - z = ALLOC(DdNode *,n); + z = ABC_ALLOC(DdNode *,n); if (z == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -212,7 +212,7 @@ Cudd_PrioritySelect( endgame: if (zcube != NULL) Cudd_RecursiveDeref(dd,zcube); if (createdZ) { - FREE(z); + ABC_FREE(z); } if (createdPi) { Cudd_RecursiveDeref(dd,Pi); diff --git a/src/bdd/cudd/cuddRead.c b/src/bdd/cudd/cuddRead.c index 2c4a86d8..8e4ea60c 100644 --- a/src/bdd/cudd/cuddRead.c +++ b/src/bdd/cudd/cuddRead.c @@ -154,16 +154,16 @@ Cudd_addRead( for (lnx=0; u > 0; lnx++) { u >>= 1; } - /* Here we rely on the fact that REALLOC of a null pointer is - ** translates to an ALLOC. + /* Here we rely on the fact that ABC_REALLOC of a null pointer is + ** translates to an ABC_ALLOC. */ if (lnx > *nx) { - *x = lx = REALLOC(DdNode *, *x, lnx); + *x = lx = ABC_REALLOC(DdNode *, *x, lnx); if (lx == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - *xn = lxn = REALLOC(DdNode *, *xn, lnx); + *xn = lxn = ABC_REALLOC(DdNode *, *xn, lnx); if (lxn == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -177,16 +177,16 @@ Cudd_addRead( for (lny=0; v > 0; lny++) { v >>= 1; } - /* Here we rely on the fact that REALLOC of a null pointer is - ** translates to an ALLOC. + /* Here we rely on the fact that ABC_REALLOC of a null pointer is + ** translates to an ABC_ALLOC. */ if (lny > *ny) { - *y = ly = REALLOC(DdNode *, *y, lny); + *y = ly = ABC_REALLOC(DdNode *, *y, lny); if (ly == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - *yn_ = lyn = REALLOC(DdNode *, *yn_, lny); + *yn_ = lyn = ABC_REALLOC(DdNode *, *yn_, lny); if (lyn == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -375,7 +375,7 @@ Cudd_bddRead( u >>= 1; } if (lnx > *nx) { - *x = lx = REALLOC(DdNode *, *x, lnx); + *x = lx = ABC_REALLOC(DdNode *, *x, lnx); if (lx == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); @@ -390,7 +390,7 @@ Cudd_bddRead( v >>= 1; } if (lny > *ny) { - *y = ly = REALLOC(DdNode *, *y, lny); + *y = ly = ABC_REALLOC(DdNode *, *y, lny); if (ly == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); diff --git a/src/bdd/cudd/cuddRef.c b/src/bdd/cudd/cuddRef.c index a9241f3d..7cb5d41b 100644 --- a/src/bdd/cudd/cuddRef.c +++ b/src/bdd/cudd/cuddRef.c @@ -312,7 +312,7 @@ Cudd_DelayedDerefBdd( void (*saveHandler)(long) = MMoutOfMemory; DdNodePtr *newRow; MMoutOfMemory = Cudd_OutOfMem; - newRow = REALLOC(DdNodePtr,table->deathRow,2*table->deathRowDepth); + newRow = ABC_REALLOC(DdNodePtr,table->deathRow,2*table->deathRowDepth); MMoutOfMemory = saveHandler; if (newRow == NULL) { table->nextDead = 0; @@ -671,7 +671,7 @@ cuddShrinkDeathRow( if ((unsigned) table->nextDead > table->deadMask) { table->nextDead = 0; } - table->deathRow = REALLOC(DdNodePtr, table->deathRow, + table->deathRow = ABC_REALLOC(DdNodePtr, table->deathRow, table->deathRowDepth); } #endif diff --git a/src/bdd/cudd/cuddReorder.c b/src/bdd/cudd/cuddReorder.c index 4e62ce34..7c2fac39 100644 --- a/src/bdd/cudd/cuddReorder.c +++ b/src/bdd/cudd/cuddReorder.c @@ -329,18 +329,18 @@ Cudd_ShuffleHeap( table->peakLiveNodes = table->keys; } - perm = ALLOC(int, table->size); + perm = ABC_ALLOC(int, table->size); for (i = 0; i < table->size; i++) perm[permutation[i]] = i; if (!ddCheckPermuation(table,table->tree,perm,permutation)) { - FREE(perm); + ABC_FREE(perm); return(0); } if (!ddUpdateMtrTree(table,table->tree,perm,permutation)) { - FREE(perm); + ABC_FREE(perm); return(0); } - FREE(perm); + ABC_FREE(perm); result = ddShuffle(table,permutation); @@ -381,14 +381,14 @@ cuddDynamicAllocNode( extern void (*MMoutOfMemory)(long); void (*saveHandler)(long); - if (table->nextFree == NULL) { /* free list is empty */ + if (table->nextFree == NULL) { /* ABC_FREE list is empty */ /* Try to allocate a new block. */ saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - mem = (DdNodePtr *) ALLOC(DdNode, DD_MEM_CHUNK + 1); + mem = (DdNodePtr *) ABC_ALLOC(DdNode, DD_MEM_CHUNK + 1); MMoutOfMemory = saveHandler; if (mem == NULL && table->stash != NULL) { - FREE(table->stash); + ABC_FREE(table->stash); table->stash = NULL; /* Inhibit resizing of tables. */ table->maxCacheHard = table->cacheSlots - 1; @@ -396,7 +396,7 @@ cuddDynamicAllocNode( for (i = 0; i < table->size; i++) { table->subtables[i].maxKeys <<= 2; } - mem = (DdNodePtr *) ALLOC(DdNode,DD_MEM_CHUNK + 1); + mem = (DdNodePtr *) ABC_ALLOC(DdNode,DD_MEM_CHUNK + 1); } if (mem == NULL) { /* Out of luck. Call the default handler to do @@ -438,7 +438,7 @@ cuddDynamicAllocNode( table->nextFree = &list[0]; } - } /* if free list empty */ + } /* if ABC_FREE list empty */ node = table->nextFree; table->nextFree = node->next; @@ -485,12 +485,12 @@ cuddSifting( /* Find order in which to sift variables. */ var = NULL; - entry = ALLOC(int,size); + entry = ABC_ALLOC(int,size); if (entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddSiftingOutOfMem; } - var = ALLOC(int,size); + var = ABC_ALLOC(int,size); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddSiftingOutOfMem; @@ -530,15 +530,15 @@ cuddSifting( #endif } - FREE(var); - FREE(entry); + ABC_FREE(var); + ABC_FREE(entry); return(1); cuddSiftingOutOfMem: - if (entry != NULL) FREE(entry); - if (var != NULL) FREE(var); + if (entry != NULL) ABC_FREE(entry); + if (var != NULL) ABC_FREE(var); return(0); @@ -858,7 +858,7 @@ cuddSwapInPlace( /* Try to allocate new table. Be ready to back off. */ saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - newxlist = ALLOC(DdNodePtr, newxslots); + newxlist = ABC_ALLOC(DdNodePtr, newxslots); MMoutOfMemory = saveHandler; if (newxlist == NULL) { (void) fprintf(table->err, "Unable to resize subtable %d for lack of memory\n", i); @@ -873,7 +873,7 @@ cuddSwapInPlace( ddMin(table->maxCacheHard, DD_MAX_CACHE_TO_SLOTS_RATIO * table->slots) - 2 * (int) table->cacheSlots; table->memused += (newxslots - xslots) * sizeof(DdNodePtr); - FREE(xlist); + ABC_FREE(xlist); xslots = newxslots; xshift = newxshift; xlist = newxlist; @@ -1224,7 +1224,7 @@ cuddBddAlignToZdd( if (M * table->size != table->sizeZ) return(0); /* Create and initialize the inverse permutation array. */ - invperm = ALLOC(int,table->size); + invperm = ABC_ALLOC(int,table->size); if (invperm == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -1250,9 +1250,9 @@ cuddBddAlignToZdd( if (result == 0) return(0); result = ddShuffle(table, invperm); - FREE(invperm); + ABC_FREE(invperm); /* Free interaction matrix. */ - FREE(table->interact); + ABC_FREE(table->interact); /* Fix the BDD variable group tree. */ bddFixTree(table,table->tree); return(result); @@ -1827,7 +1827,7 @@ ddReorderPostprocess( #endif /* Free interaction matrix. */ - FREE(table->interact); + ABC_FREE(table->interact); return(1); diff --git a/src/bdd/cudd/cuddSat.c b/src/bdd/cudd/cuddSat.c index 1755a1c1..a1fb79f7 100644 --- a/src/bdd/cudd/cuddSat.c +++ b/src/bdd/cudd/cuddSat.c @@ -933,7 +933,7 @@ freePathPair( cuddPathPair *pair; pair = (cuddPathPair *) value; - FREE(pair); + ABC_FREE(pair); return(ST_CONTINUE); } /* end of freePathPair */ @@ -1010,7 +1010,7 @@ getShortest( } } - my_pair = ALLOC(cuddPathPair, 1); + my_pair = ABC_ALLOC(cuddPathPair, 1); if (my_pair == NULL) { if (Cudd_IsComplement(root)) { int tmp = res_pair.pos; @@ -1190,7 +1190,7 @@ getLargest( res_pair.neg = ddMin(pair_T.neg, pair_E.neg) + 1; } - my_pair = ALLOC(cuddPathPair, 1); + my_pair = ABC_ALLOC(cuddPathPair, 1); if (my_pair == NULL) { /* simlpy do not cache this result */ if (Cudd_IsComplement(root)) { int tmp = res_pair.pos; diff --git a/src/bdd/cudd/cuddSign.c b/src/bdd/cudd/cuddSign.c index fcaa65c4..d58c1b43 100644 --- a/src/bdd/cudd/cuddSign.c +++ b/src/bdd/cudd/cuddSign.c @@ -123,7 +123,7 @@ Cudd_CofMinterm( size = dd->size; values = ddCofMintermAux(dd, node, table); if (values != NULL) { - result = ALLOC(double,size + 1); + result = ABC_ALLOC(double,size + 1); if (result != NULL) { #ifdef DD_STATS table_mem += (size + 1) * sizeof(double); @@ -148,7 +148,7 @@ Cudd_CofMinterm( #ifdef DD_STATS table_mem += table->num_bins * sizeof(st_table_entry *); #endif - if (Cudd_Regular(node)->ref == 1) FREE(values); + if (Cudd_Regular(node)->ref == 1) ABC_FREE(values); st_foreach(table, cuddStCountfree, NULL); st_free_table(table); #ifdef DD_STATS @@ -226,7 +226,7 @@ ddCofMintermAux( } else { localSize = size - cuddI(dd,N->index) + 1; } - values = ALLOC(double, localSize); + values = ABC_ALLOC(double, localSize); if (values == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -273,13 +273,13 @@ ddCofMintermAux( } values[i] = (vT + vE) / 2.0; } - if (Cudd_Regular(Nv)->ref == 1) FREE(valuesT); - if (Cudd_Regular(Nnv)->ref == 1) FREE(valuesE); + if (Cudd_Regular(Nv)->ref == 1) ABC_FREE(valuesT); + if (Cudd_Regular(Nnv)->ref == 1) ABC_FREE(valuesE); } if (N->ref > 1) { if (st_add_direct(table, (char *) node, (char *) values) == ST_OUT_OF_MEM) { - FREE(values); + ABC_FREE(values); return(NULL); } #ifdef DD_STATS diff --git a/src/bdd/cudd/cuddSolve.c b/src/bdd/cudd/cuddSolve.c index d9c4a2e7..a78055f3 100644 --- a/src/bdd/cudd/cuddSolve.c +++ b/src/bdd/cudd/cuddSolve.c @@ -103,7 +103,7 @@ Cudd_SolveEqn( DdNode *res; int *temp; - *yIndex = temp = ALLOC(int, n); + *yIndex = temp = ABC_ALLOC(int, n); if (temp == NULL) { bdd->errorCode = CUDD_MEMORY_OUT; (void) fprintf(bdd->out, @@ -149,7 +149,7 @@ Cudd_VerifySol( res = cuddVerifySol(bdd, F, G, yIndex, n); } while (bdd->reordered == 1); - FREE(yIndex); + ABC_FREE(yIndex); return(res); diff --git a/src/bdd/cudd/cuddSplit.c b/src/bdd/cudd/cuddSplit.c index e21ea7cb..1f9a0425 100644 --- a/src/bdd/cudd/cuddSplit.c +++ b/src/bdd/cudd/cuddSplit.c @@ -129,7 +129,7 @@ Cudd_SplitSet( /* varSeen is used to mark the variables that are encountered ** while traversing the BDD S. */ - varSeen = ALLOC(int, size); + varSeen = ABC_ALLOC(int, size); if (varSeen == NULL) { manager->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -148,13 +148,13 @@ Cudd_SplitSet( result = selectMintermsFromUniverse(manager,varSeen,m); if (result) cuddRef(result); - FREE(varSeen); + ABC_FREE(varSeen); } else { mtable = st_init_table(st_ptrcmp,st_ptrhash); if (mtable == NULL) { (void) fprintf(manager->out, "Cudd_SplitSet: out-of-memory.\n"); - FREE(varSeen); + ABC_FREE(varSeen); manager->errorCode = CUDD_MEMORY_OUT; return(NULL); } @@ -166,7 +166,7 @@ Cudd_SplitSet( if (m == num) { st_foreach(mtable,cuddStCountfree,NIL(char)); st_free_table(mtable); - FREE(varSeen); + ABC_FREE(varSeen); return(S); } @@ -175,7 +175,7 @@ Cudd_SplitSet( cuddRef(result); st_foreach(mtable,cuddStCountfree,NULL); st_free_table(mtable); - FREE(varSeen); + ABC_FREE(varSeen); } } while (manager->reordered == 1); @@ -485,7 +485,7 @@ selectMintermsFromUniverse( if(varSeen[i] == 0) numVars++; } - vars = ALLOC(DdNode *, numVars); + vars = ABC_ALLOC(DdNode *, numVars); if (!vars) { manager->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -509,7 +509,7 @@ selectMintermsFromUniverse( for (i = 0; i < numVars; i++) Cudd_RecursiveDeref(manager,vars[i]); - FREE(vars); + ABC_FREE(vars); return(result); @@ -640,7 +640,7 @@ bddAnnotateMintermCount( return ((double)CUDD_OUT_OF_MEM); min_N = min_v + min_nv; - pmin = ALLOC(double,1); + pmin = ABC_ALLOC(double,1); if (pmin == NULL) { manager->errorCode = CUDD_MEMORY_OUT; return((double)CUDD_OUT_OF_MEM); @@ -648,7 +648,7 @@ bddAnnotateMintermCount( *pmin = min_N; if (st_insert(table,(char *)node, (char *)pmin) == ST_OUT_OF_MEM) { - FREE(pmin); + ABC_FREE(pmin); return((double)CUDD_OUT_OF_MEM); } diff --git a/src/bdd/cudd/cuddSubsetHB.c b/src/bdd/cudd/cuddSubsetHB.c index 24d41ce5..59f8e6d2 100644 --- a/src/bdd/cudd/cuddSubsetHB.c +++ b/src/bdd/cudd/cuddSubsetHB.c @@ -336,7 +336,7 @@ cuddSubsetHeavyBranch( dd->errorCode = CUDD_INTERNAL_ERROR; } - size = ALLOC(int, 1); + size = ABC_ALLOC(int, 1); if (size == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -385,23 +385,23 @@ cuddSubsetHeavyBranch( st_free_table(storeTable); for (i = 0; i <= page; i++) { - FREE(mintermPages[i]); + ABC_FREE(mintermPages[i]); } - FREE(mintermPages); + ABC_FREE(mintermPages); for (i = 0; i <= page; i++) { - FREE(nodePages[i]); + ABC_FREE(nodePages[i]); } - FREE(nodePages); + ABC_FREE(nodePages); for (i = 0; i <= page; i++) { - FREE(lightNodePages[i]); + ABC_FREE(lightNodePages[i]); } - FREE(lightNodePages); + ABC_FREE(lightNodePages); for (i = 0; i <= nodeDataPage; i++) { - FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages[i]); } - FREE(nodeDataPages); + ABC_FREE(nodeDataPages); st_free_table(visitedTable); - FREE(size); + ABC_FREE(size); #if 0 (void) Cudd_DebugCheck(dd); (void) Cudd_CheckKeys(dd); @@ -455,10 +455,10 @@ ResizeNodeDataPages( * INITIAL_PAGES */ if (nodeDataPage == maxNodeDataPages) { - newNodeDataPages = ALLOC(NodeData_t *,maxNodeDataPages + INITIAL_PAGES); + newNodeDataPages = ABC_ALLOC(NodeData_t *,maxNodeDataPages + INITIAL_PAGES); if (newNodeDataPages == NULL) { - for (i = 0; i < nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i < nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); memOut = 1; return; } else { @@ -467,16 +467,16 @@ ResizeNodeDataPages( } /* Increase total page count */ maxNodeDataPages += INITIAL_PAGES; - FREE(nodeDataPages); + ABC_FREE(nodeDataPages); nodeDataPages = newNodeDataPages; } } /* Allocate a new page */ currentNodeDataPage = nodeDataPages[nodeDataPage] = - ALLOC(NodeData_t ,nodeDataPageSize); + ABC_ALLOC(NodeData_t ,nodeDataPageSize); if (currentNodeDataPage == NULL) { - for (i = 0; i < nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i < nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); memOut = 1; return; } @@ -515,10 +515,10 @@ ResizeCountMintermPages( * INITIAL_PAGES */ if (page == maxPages) { - newMintermPages = ALLOC(double *,maxPages + INITIAL_PAGES); + newMintermPages = ABC_ALLOC(double *,maxPages + INITIAL_PAGES); if (newMintermPages == NULL) { - for (i = 0; i < page; i++) FREE(mintermPages[i]); - FREE(mintermPages); + for (i = 0; i < page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); memOut = 1; return; } else { @@ -527,15 +527,15 @@ ResizeCountMintermPages( } /* Increase total page count */ maxPages += INITIAL_PAGES; - FREE(mintermPages); + ABC_FREE(mintermPages); mintermPages = newMintermPages; } } /* Allocate a new page */ - currentMintermPage = mintermPages[page] = ALLOC(double,pageSize); + currentMintermPage = mintermPages[page] = ABC_ALLOC(double,pageSize); if (currentMintermPage == NULL) { - for (i = 0; i < page; i++) FREE(mintermPages[i]); - FREE(mintermPages); + for (i = 0; i < page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); memOut = 1; return; } @@ -574,57 +574,57 @@ ResizeCountNodePages( * by INITIAL_PAGES. */ if (page == maxPages) { - newNodePages = ALLOC(int *,maxPages + INITIAL_PAGES); + newNodePages = ABC_ALLOC(int *,maxPages + INITIAL_PAGES); if (newNodePages == NULL) { - for (i = 0; i < page; i++) FREE(nodePages[i]); - FREE(nodePages); - for (i = 0; i < page; i++) FREE(lightNodePages[i]); - FREE(lightNodePages); + for (i = 0; i < page; i++) ABC_FREE(nodePages[i]); + ABC_FREE(nodePages); + for (i = 0; i < page; i++) ABC_FREE(lightNodePages[i]); + ABC_FREE(lightNodePages); memOut = 1; return; } else { for (i = 0; i < maxPages; i++) { newNodePages[i] = nodePages[i]; } - FREE(nodePages); + ABC_FREE(nodePages); nodePages = newNodePages; } - newNodePages = ALLOC(int *,maxPages + INITIAL_PAGES); + newNodePages = ABC_ALLOC(int *,maxPages + INITIAL_PAGES); if (newNodePages == NULL) { - for (i = 0; i < page; i++) FREE(nodePages[i]); - FREE(nodePages); - for (i = 0; i < page; i++) FREE(lightNodePages[i]); - FREE(lightNodePages); + for (i = 0; i < page; i++) ABC_FREE(nodePages[i]); + ABC_FREE(nodePages); + for (i = 0; i < page; i++) ABC_FREE(lightNodePages[i]); + ABC_FREE(lightNodePages); memOut = 1; return; } else { for (i = 0; i < maxPages; i++) { newNodePages[i] = lightNodePages[i]; } - FREE(lightNodePages); + ABC_FREE(lightNodePages); lightNodePages = newNodePages; } /* Increase total page count */ maxPages += INITIAL_PAGES; } /* Allocate a new page */ - currentNodePage = nodePages[page] = ALLOC(int,pageSize); + currentNodePage = nodePages[page] = ABC_ALLOC(int,pageSize); if (currentNodePage == NULL) { - for (i = 0; i < page; i++) FREE(nodePages[i]); - FREE(nodePages); - for (i = 0; i < page; i++) FREE(lightNodePages[i]); - FREE(lightNodePages); + for (i = 0; i < page; i++) ABC_FREE(nodePages[i]); + ABC_FREE(nodePages); + for (i = 0; i < page; i++) ABC_FREE(lightNodePages[i]); + ABC_FREE(lightNodePages); memOut = 1; return; } /* Allocate a new page */ - currentLightNodePage = lightNodePages[page] = ALLOC(int,pageSize); + currentLightNodePage = lightNodePages[page] = ABC_ALLOC(int,pageSize); if (currentLightNodePage == NULL) { - for (i = 0; i <= page; i++) FREE(nodePages[i]); - FREE(nodePages); - for (i = 0; i < page; i++) FREE(lightNodePages[i]); - FREE(lightNodePages); + for (i = 0; i <= page; i++) ABC_FREE(nodePages[i]); + ABC_FREE(nodePages); + for (i = 0; i < page; i++) ABC_FREE(lightNodePages[i]); + ABC_FREE(lightNodePages); memOut = 1; return; } @@ -703,8 +703,8 @@ SubsetCountMintermAux( /* if page index is at the bottom, then create a new page */ if (pageIndex == pageSize) ResizeCountMintermPages(); if (memOut) { - for (i = 0; i <= nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i <= nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); st_free_table(table); return(0.0); } @@ -719,8 +719,8 @@ SubsetCountMintermAux( /* Note I allocate the struct here. Freeing taken care of later */ if (nodeDataPageIndex == nodeDataPageSize) ResizeNodeDataPages(); if (memOut) { - for (i = 0; i <= page; i++) FREE(mintermPages[i]); - FREE(mintermPages); + for (i = 0; i <= page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); st_free_table(table); return(0.0); } @@ -736,10 +736,10 @@ SubsetCountMintermAux( /* insert entry for the node in the table */ if (st_insert(table,(char *)node, (char *)newEntry) == ST_OUT_OF_MEM) { memOut = 1; - for (i = 0; i <= page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i <= nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i <= page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i <= nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); st_free_table(table); return(0.0); } @@ -780,35 +780,35 @@ SubsetCountMinterm( table = st_init_table(st_ptrcmp,st_ptrhash); if (table == NULL) goto OUT_OF_MEM; maxPages = INITIAL_PAGES; - mintermPages = ALLOC(double *,maxPages); + mintermPages = ABC_ALLOC(double *,maxPages); if (mintermPages == NULL) { st_free_table(table); goto OUT_OF_MEM; } page = 0; - currentMintermPage = ALLOC(double,pageSize); + currentMintermPage = ABC_ALLOC(double,pageSize); mintermPages[page] = currentMintermPage; if (currentMintermPage == NULL) { - FREE(mintermPages); + ABC_FREE(mintermPages); st_free_table(table); goto OUT_OF_MEM; } pageIndex = 0; maxNodeDataPages = INITIAL_PAGES; - nodeDataPages = ALLOC(NodeData_t *, maxNodeDataPages); + nodeDataPages = ABC_ALLOC(NodeData_t *, maxNodeDataPages); if (nodeDataPages == NULL) { - for (i = 0; i <= page ; i++) FREE(mintermPages[i]); - FREE(mintermPages); + for (i = 0; i <= page ; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); st_free_table(table); goto OUT_OF_MEM; } nodeDataPage = 0; - currentNodeDataPage = ALLOC(NodeData_t ,nodeDataPageSize); + currentNodeDataPage = ABC_ALLOC(NodeData_t ,nodeDataPageSize); nodeDataPages[nodeDataPage] = currentNodeDataPage; if (currentNodeDataPage == NULL) { - for (i = 0; i <= page ; i++) FREE(mintermPages[i]); - FREE(mintermPages); - FREE(nodeDataPages); + for (i = 0; i <= page ; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + ABC_FREE(nodeDataPages); st_free_table(table); goto OUT_OF_MEM; } @@ -915,10 +915,10 @@ SubsetCountNodesAux( /* store the node count of the lighter child. */ if (pageIndex == pageSize) ResizeCountNodePages(); if (memOut) { - for (i = 0; i <= page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i <= nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i <= page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i <= nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); st_free_table(table); return(0); } @@ -935,10 +935,10 @@ SubsetCountNodesAux( /* store the node count of the lighter child. */ if (pageIndex == pageSize) ResizeCountNodePages(); if (memOut) { - for (i = 0; i <= page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i <= nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i <= page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i <= nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); st_free_table(table); return(0); } @@ -962,10 +962,10 @@ SubsetCountNodesAux( if (st_lookup(table, (char *)Cudd_Not(node), (char **)&dummyNBar) == 1) { if (pageIndex == pageSize) ResizeCountNodePages(); if (memOut) { - for (i = 0; i < page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i < nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i < page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i < nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); st_free_table(table); return(0); } @@ -977,10 +977,10 @@ SubsetCountNodesAux( */ if (pageIndex == pageSize) ResizeCountNodePages(); if (memOut) { - for (i = 0; i < page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i < nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); + for (i = 0; i < page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i < nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); st_free_table(table); return(0); } @@ -1023,42 +1023,42 @@ SubsetCountNodes( max = pow(2.0,(double) nvars); maxPages = INITIAL_PAGES; - nodePages = ALLOC(int *,maxPages); + nodePages = ABC_ALLOC(int *,maxPages); if (nodePages == NULL) { goto OUT_OF_MEM; } - lightNodePages = ALLOC(int *,maxPages); + lightNodePages = ABC_ALLOC(int *,maxPages); if (lightNodePages == NULL) { - for (i = 0; i <= page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i <= nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); - FREE(nodePages); + for (i = 0; i <= page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i <= nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); + ABC_FREE(nodePages); goto OUT_OF_MEM; } page = 0; - currentNodePage = nodePages[page] = ALLOC(int,pageSize); + currentNodePage = nodePages[page] = ABC_ALLOC(int,pageSize); if (currentNodePage == NULL) { - for (i = 0; i <= page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i <= nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); - FREE(lightNodePages); - FREE(nodePages); + for (i = 0; i <= page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i <= nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); + ABC_FREE(lightNodePages); + ABC_FREE(nodePages); goto OUT_OF_MEM; } - currentLightNodePage = lightNodePages[page] = ALLOC(int,pageSize); + currentLightNodePage = lightNodePages[page] = ABC_ALLOC(int,pageSize); if (currentLightNodePage == NULL) { - for (i = 0; i <= page; i++) FREE(mintermPages[i]); - FREE(mintermPages); - for (i = 0; i <= nodeDataPage; i++) FREE(nodeDataPages[i]); - FREE(nodeDataPages); - FREE(currentNodePage); - FREE(lightNodePages); - FREE(nodePages); + for (i = 0; i <= page; i++) ABC_FREE(mintermPages[i]); + ABC_FREE(mintermPages); + for (i = 0; i <= nodeDataPage; i++) ABC_FREE(nodeDataPages[i]); + ABC_FREE(nodeDataPages); + ABC_FREE(currentNodePage); + ABC_FREE(lightNodePages); + ABC_FREE(nodePages); goto OUT_OF_MEM; } diff --git a/src/bdd/cudd/cuddSubsetSP.c b/src/bdd/cudd/cuddSubsetSP.c index e3d39a0e..25c22b88 100644 --- a/src/bdd/cudd/cuddSubsetSP.c +++ b/src/bdd/cudd/cuddSubsetSP.c @@ -311,7 +311,7 @@ cuddSubsetShortPaths( if (Cudd_IsConstant(f)) return (f); - pathLengthArray = ALLOC(unsigned int, numVars+1); + pathLengthArray = ABC_ALLOC(unsigned int, numVars+1); for (i = 0; i < numVars+1; i++) pathLengthArray[i] = 0; @@ -324,18 +324,18 @@ cuddSubsetShortPaths( if ((pathTable == NULL) || (memOut)) { if (pathTable != NULL) st_free_table(pathTable); - FREE(pathLengthArray); + ABC_FREE(pathLengthArray); return (NIL(DdNode)); } - excess = ALLOC(unsigned int, 1); + excess = ABC_ALLOC(unsigned int, 1); *excess = 0; maxpath = AssessPathLength(pathLengthArray, threshold, numVars, excess, dd->err); if (maxpath != (unsigned) (numVars + 1)) { - info = ALLOC(struct AssortedInfo, 1); + info = ABC_ALLOC(struct AssortedInfo, 1); info->maxpath = maxpath; info->findShortestPath = 0; info->thresholdReached = *excess; @@ -412,17 +412,17 @@ cuddSubsetShortPaths( st_free_table(info->maxpathTable); st_foreach(pathTable, stPathTableDdFree, (char *)dd); - FREE(info); + ABC_FREE(info); } else {/* if threshold larger than size of dd */ subset = f; cuddRef(subset); } - FREE(excess); + ABC_FREE(excess); st_free_table(pathTable); - FREE(pathLengthArray); - for (i = 0; i <= nodeDistPage; i++) FREE(nodeDistPages[i]); - FREE(nodeDistPages); + ABC_FREE(pathLengthArray); + for (i = 0; i <= nodeDistPage; i++) ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); #ifdef DD_DEBUG /* check containment of subset in f */ @@ -483,10 +483,10 @@ ResizeNodeDistPages( * INITIAL_PAGES */ if (nodeDistPage == maxNodeDistPages) { - newNodeDistPages = ALLOC(NodeDist_t *,maxNodeDistPages + INITIAL_PAGES); + newNodeDistPages = ABC_ALLOC(NodeDist_t *,maxNodeDistPages + INITIAL_PAGES); if (newNodeDistPages == NULL) { - for (i = 0; i < nodeDistPage; i++) FREE(nodeDistPages[i]); - FREE(nodeDistPages); + for (i = 0; i < nodeDistPage; i++) ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); memOut = 1; return; } else { @@ -495,16 +495,16 @@ ResizeNodeDistPages( } /* Increase total page count */ maxNodeDistPages += INITIAL_PAGES; - FREE(nodeDistPages); + ABC_FREE(nodeDistPages); nodeDistPages = newNodeDistPages; } } /* Allocate a new page */ - currentNodeDistPage = nodeDistPages[nodeDistPage] = ALLOC(NodeDist_t, + currentNodeDistPage = nodeDistPages[nodeDistPage] = ABC_ALLOC(NodeDist_t, nodeDistPageSize); if (currentNodeDistPage == NULL) { - for (i = 0; i < nodeDistPage; i++) FREE(nodeDistPages[i]); - FREE(nodeDistPages); + for (i = 0; i < nodeDistPage; i++) ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); memOut = 1; return; } @@ -544,10 +544,10 @@ ResizeQueuePages( * INITIAL_PAGES */ if (queuePage == maxQueuePages) { - newQueuePages = ALLOC(DdNode **,maxQueuePages + INITIAL_PAGES); + newQueuePages = ABC_ALLOC(DdNode **,maxQueuePages + INITIAL_PAGES); if (newQueuePages == NULL) { - for (i = 0; i < queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + for (i = 0; i < queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); memOut = 1; return; } else { @@ -556,15 +556,15 @@ ResizeQueuePages( } /* Increase total page count */ maxQueuePages += INITIAL_PAGES; - FREE(queuePages); + ABC_FREE(queuePages); queuePages = newQueuePages; } } /* Allocate a new page */ - currentQueuePage = queuePages[queuePage] = ALLOC(DdNode *,queuePageSize); + currentQueuePage = queuePages[queuePage] = ABC_ALLOC(DdNode *,queuePageSize); if (currentQueuePage == NULL) { - for (i = 0; i < queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + for (i = 0; i < queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); memOut = 1; return; } @@ -667,8 +667,8 @@ CreateTopDist( if (nodeDistPageIndex == nodeDistPageSize) ResizeNodeDistPages(); if (memOut) { - for (i = 0; i <= queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + for (i = 0; i <= queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); st_free_table(pathTable); return; } @@ -697,10 +697,10 @@ CreateTopDist( (char *)nodeStat) == ST_OUT_OF_MEM) { memOut = 1; for (i = 0; i <= nodeDistPage; i++) - FREE(nodeDistPages[i]); - FREE(nodeDistPages); - for (i = 0; i <= queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); + for (i = 0; i <= queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); st_free_table(pathTable); return; } @@ -714,8 +714,8 @@ CreateTopDist( if (queuePageIndex == queuePageSize) ResizeQueuePages(); if (memOut) { for (i = 0; i <= nodeDistPage; i++) - FREE(nodeDistPages[i]); - FREE(nodeDistPages); + ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); st_free_table(pathTable); return; } @@ -733,8 +733,8 @@ CreateTopDist( if (queuePageIndex == queuePageSize) ResizeQueuePages(); if (memOut) { for (i = 0; i <= nodeDistPage; i++) - FREE(nodeDistPages[i]); - FREE(nodeDistPages); + ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); st_free_table(pathTable); return; @@ -1000,31 +1000,31 @@ CreatePathTable( /* initializing pages for info about each node */ maxNodeDistPages = INITIAL_PAGES; - nodeDistPages = ALLOC(NodeDist_t *, maxNodeDistPages); + nodeDistPages = ABC_ALLOC(NodeDist_t *, maxNodeDistPages); if (nodeDistPages == NULL) { goto OUT_OF_MEM; } nodeDistPage = 0; currentNodeDistPage = nodeDistPages[nodeDistPage] = - ALLOC(NodeDist_t, nodeDistPageSize); + ABC_ALLOC(NodeDist_t, nodeDistPageSize); if (currentNodeDistPage == NULL) { - for (i = 0; i <= nodeDistPage; i++) FREE(nodeDistPages[i]); - FREE(nodeDistPages); + for (i = 0; i <= nodeDistPage; i++) ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); goto OUT_OF_MEM; } nodeDistPageIndex = 0; /* Initializing pages for the BFS search queue, implemented as an array. */ maxQueuePages = INITIAL_PAGES; - queuePages = ALLOC(DdNode **, maxQueuePages); + queuePages = ABC_ALLOC(DdNode **, maxQueuePages); if (queuePages == NULL) { goto OUT_OF_MEM; } queuePage = 0; - currentQueuePage = queuePages[queuePage] = ALLOC(DdNode *, queuePageSize); + currentQueuePage = queuePages[queuePage] = ABC_ALLOC(DdNode *, queuePageSize); if (currentQueuePage == NULL) { - for (i = 0; i <= queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + for (i = 0; i <= queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); goto OUT_OF_MEM; } queuePageIndex = 0; @@ -1042,10 +1042,10 @@ CreatePathTable( if (nodeDistPageIndex == nodeDistPageSize) ResizeNodeDistPages(); if (memOut) { - for (i = 0; i <= nodeDistPage; i++) FREE(nodeDistPages[i]); - FREE(nodeDistPages); - for (i = 0; i <= queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + for (i = 0; i <= nodeDistPage; i++) ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); + for (i = 0; i <= queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); st_free_table(pathTable); goto OUT_OF_MEM; } @@ -1063,10 +1063,10 @@ CreatePathTable( insertValue = st_insert(pathTable, (char *)N, (char *)nodeStat); if (insertValue == ST_OUT_OF_MEM) { memOut = 1; - for (i = 0; i <= nodeDistPage; i++) FREE(nodeDistPages[i]); - FREE(nodeDistPages); - for (i = 0; i <= queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + for (i = 0; i <= nodeDistPage; i++) ABC_FREE(nodeDistPages[i]); + ABC_FREE(nodeDistPages); + for (i = 0; i <= queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); st_free_table(pathTable); goto OUT_OF_MEM; } else if (insertValue == 1) { @@ -1101,9 +1101,9 @@ CreatePathTable( */ if (!CreateBotDist(node, pathTable, pathLengthArray, fp)) return(NULL); - /* free BFS queue pages as no longer required */ - for (i = 0; i <= queuePage; i++) FREE(queuePages[i]); - FREE(queuePages); + /* ABC_FREE BFS queue pages as no longer required */ + for (i = 0; i <= queuePage; i++) ABC_FREE(queuePages[i]); + ABC_FREE(queuePages); return(pathTable); OUT_OF_MEM: @@ -1595,7 +1595,7 @@ BuildSubsetBdd( /**Function******************************************************************** - Synopsis [Procedure to free te result dds stored in the NodeDist pages.] + Synopsis [Procedure to ABC_FREE te result dds stored in the NodeDist pages.] Description [None] diff --git a/src/bdd/cudd/cuddSymmetry.c b/src/bdd/cudd/cuddSymmetry.c index aef6abc6..a608a21f 100644 --- a/src/bdd/cudd/cuddSymmetry.c +++ b/src/bdd/cudd/cuddSymmetry.c @@ -308,12 +308,12 @@ cuddSymmSifting( /* Find order in which to sift variables. */ var = NULL; - entry = ALLOC(int,size); + entry = ABC_ALLOC(int,size); if (entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto ddSymmSiftingOutOfMem; } - var = ALLOC(int,size); + var = ABC_ALLOC(int,size); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto ddSymmSiftingOutOfMem; @@ -357,8 +357,8 @@ cuddSymmSifting( } } - FREE(var); - FREE(entry); + ABC_FREE(var); + ABC_FREE(entry); ddSymmSummary(table, lower, upper, &symvars, &symgroups); @@ -373,8 +373,8 @@ cuddSymmSifting( ddSymmSiftingOutOfMem: - if (entry != NULL) FREE(entry); - if (var != NULL) FREE(var); + if (entry != NULL) ABC_FREE(entry); + if (var != NULL) ABC_FREE(var); return(0); @@ -429,12 +429,12 @@ cuddSymmSiftingConv( /* Find order in which to sift variables. */ var = NULL; - entry = ALLOC(int,size); + entry = ABC_ALLOC(int,size); if (entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto ddSymmSiftingConvOutOfMem; } - var = ALLOC(int,size); + var = ABC_ALLOC(int,size); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto ddSymmSiftingConvOutOfMem; @@ -538,15 +538,15 @@ cuddSymmSiftingConv( symgroups); #endif - FREE(var); - FREE(entry); + ABC_FREE(var); + ABC_FREE(entry); return(1+symvars); ddSymmSiftingConvOutOfMem: - if (entry != NULL) FREE(entry); - if (var != NULL) FREE(var); + if (entry != NULL) ABC_FREE(entry); + if (var != NULL) ABC_FREE(var); return(0); diff --git a/src/bdd/cudd/cuddTable.c b/src/bdd/cudd/cuddTable.c index 458f19e6..3c76c1af 100644 --- a/src/bdd/cudd/cuddTable.c +++ b/src/bdd/cudd/cuddTable.c @@ -205,7 +205,7 @@ cuddAllocNode( extern void (*MMoutOfMemory)(long); void (*saveHandler)(long); - if (unique->nextFree == NULL) { /* free list is empty */ + if (unique->nextFree == NULL) { /* ABC_FREE list is empty */ /* Check for exceeded limits. */ if ((unique->keys - unique->dead) + (unique->keysZ - unique->deadZ) > unique->maxLive) { @@ -224,7 +224,7 @@ cuddAllocNode( /* Try to allocate a new block. */ saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - mem = (DdNodePtr *) ALLOC(DdNode,DD_MEM_CHUNK + 1); + mem = (DdNodePtr *) ABC_ALLOC(DdNode,DD_MEM_CHUNK + 1); MMoutOfMemory = saveHandler; if (mem == NULL) { /* No more memory: Try collecting garbage. If this succeeds, @@ -235,12 +235,12 @@ cuddAllocNode( ** any. If this succeeeds, mem != NULL and ** unique->nextFree still NULL. */ if (unique->stash != NULL) { - FREE(unique->stash); + ABC_FREE(unique->stash); unique->stash = NULL; /* Inhibit resizing of tables. */ cuddSlowTableGrowth(unique); /* Now try again. */ - mem = (DdNodePtr *) ALLOC(DdNode,DD_MEM_CHUNK + 1); + mem = (DdNodePtr *) ABC_ALLOC(DdNode,DD_MEM_CHUNK + 1); } if (mem == NULL) { /* Out of luck. Call the default handler to do @@ -310,7 +310,7 @@ cuddInitTable( unsigned int numSlots /* Initial size of the BDD subtables */, unsigned int looseUpTo /* Limit for fast table growth */) { - DdManager *unique = ALLOC(DdManager,1); + DdManager *unique = ABC_ALLOC(DdManager,1); int i, j; DdNodePtr *nodelist; DdNode *sentinel; @@ -355,38 +355,38 @@ cuddInitTable( unique->gcEnabled = 1; unique->allocated = 0; unique->reclaimed = 0; - unique->subtables = ALLOC(DdSubtable,unique->maxSize); + unique->subtables = ABC_ALLOC(DdSubtable,unique->maxSize); if (unique->subtables == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - unique->subtableZ = ALLOC(DdSubtable,unique->maxSizeZ); + unique->subtableZ = ABC_ALLOC(DdSubtable,unique->maxSizeZ); if (unique->subtableZ == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - unique->perm = ALLOC(int,unique->maxSize); + unique->perm = ABC_ALLOC(int,unique->maxSize); if (unique->perm == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - unique->invperm = ALLOC(int,unique->maxSize); + unique->invperm = ABC_ALLOC(int,unique->maxSize); if (unique->invperm == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - unique->permZ = ALLOC(int,unique->maxSizeZ); + unique->permZ = ABC_ALLOC(int,unique->maxSizeZ); if (unique->permZ == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - unique->invpermZ = ALLOC(int,unique->maxSizeZ); + unique->invpermZ = ABC_ALLOC(int,unique->maxSizeZ); if (unique->invpermZ == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } unique->map = NULL; - unique->stack = ALLOC(DdNodePtr,ddMax(unique->maxSize,unique->maxSizeZ)+1); + unique->stack = ABC_ALLOC(DdNodePtr,ddMax(unique->maxSize,unique->maxSizeZ)+1); if (unique->stack == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -395,7 +395,7 @@ cuddInitTable( #ifndef DD_NO_DEATH_ROW unique->deathRowDepth = 1 << cuddComputeFloorLog2(unique->looseUpTo >> 2); - unique->deathRow = ALLOC(DdNodePtr,unique->deathRowDepth); + unique->deathRow = ABC_ALLOC(DdNodePtr,unique->deathRowDepth); if (unique->deathRow == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -419,7 +419,7 @@ cuddInitTable( unique->subtables[i].varHandled = 0; unique->subtables[i].varToBeGrouped = CUDD_LAZY_NONE; - nodelist = unique->subtables[i].nodelist = ALLOC(DdNodePtr,slots); + nodelist = unique->subtables[i].nodelist = ABC_ALLOC(DdNodePtr,slots); if (nodelist == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -436,7 +436,7 @@ cuddInitTable( unique->subtableZ[i].keys = 0; unique->subtableZ[i].dead = 0; unique->subtableZ[i].maxKeys = slots * DD_MAX_SUBTABLE_DENSITY; - nodelist = unique->subtableZ[i].nodelist = ALLOC(DdNodePtr,slots); + nodelist = unique->subtableZ[i].nodelist = ABC_ALLOC(DdNodePtr,slots); if (nodelist == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -452,7 +452,7 @@ cuddInitTable( unique->constants.keys = 0; unique->constants.dead = 0; unique->constants.maxKeys = slots * DD_MAX_SUBTABLE_DENSITY; - nodelist = unique->constants.nodelist = ALLOC(DdNodePtr,slots); + nodelist = unique->constants.nodelist = ABC_ALLOC(DdNodePtr,slots); if (nodelist == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -558,35 +558,35 @@ cuddFreeTable( if (unique->univ != NULL) cuddZddFreeUniv(unique); while (memlist != NULL) { next = (DdNodePtr *) memlist[0]; /* link to next block */ - FREE(memlist); + ABC_FREE(memlist); memlist = next; } unique->nextFree = NULL; unique->memoryList = NULL; for (i = 0; i < unique->size; i++) { - FREE(unique->subtables[i].nodelist); + ABC_FREE(unique->subtables[i].nodelist); } for (i = 0; i < unique->sizeZ; i++) { - FREE(unique->subtableZ[i].nodelist); - } - FREE(unique->constants.nodelist); - FREE(unique->subtables); - FREE(unique->subtableZ); - FREE(unique->acache); - FREE(unique->perm); - FREE(unique->permZ); - FREE(unique->invperm); - FREE(unique->invpermZ); - FREE(unique->vars); - if (unique->map != NULL) FREE(unique->map); - FREE(unique->stack); + ABC_FREE(unique->subtableZ[i].nodelist); + } + ABC_FREE(unique->constants.nodelist); + ABC_FREE(unique->subtables); + ABC_FREE(unique->subtableZ); + ABC_FREE(unique->acache); + ABC_FREE(unique->perm); + ABC_FREE(unique->permZ); + ABC_FREE(unique->invperm); + ABC_FREE(unique->invpermZ); + ABC_FREE(unique->vars); + if (unique->map != NULL) ABC_FREE(unique->map); + ABC_FREE(unique->stack); #ifndef DD_NO_DEATH_ROW - FREE(unique->deathRow); + ABC_FREE(unique->deathRow); #endif if (unique->tree != NULL) Mtr_FreeTree(unique->tree); if (unique->treeZ != NULL) Mtr_FreeTree(unique->treeZ); - if (unique->linear != NULL) FREE(unique->linear); + if (unique->linear != NULL) ABC_FREE(unique->linear); while (unique->preGCHook != NULL) Cudd_RemoveHook(unique,unique->preGCHook->f,CUDD_PRE_GC_HOOK); while (unique->postGCHook != NULL) @@ -597,7 +597,7 @@ cuddFreeTable( while (unique->postReorderingHook != NULL) Cudd_RemoveHook(unique,unique->postReorderingHook->f, CUDD_POST_REORDERING_HOOK); - FREE(unique); + ABC_FREE(unique); } /* end of cuddFreeTable */ @@ -699,7 +699,7 @@ cuddGarbageCollect( cuddLocalCacheClearDead(unique); } - /* Now return dead nodes to free list. Count them for sanity check. */ + /* Now return dead nodes to ABC_FREE list. Count them for sanity check. */ totalDeleted = 0; #ifndef DD_UNSORTED_FREE_LIST tree = NULL; @@ -905,7 +905,7 @@ cuddGarbageCollectZdd( } } - /* Now return dead nodes to free list. Count them for sanity check. */ + /* Now return dead nodes to ABC_FREE list. Count them for sanity check. */ totalDeleted = 0; #ifndef DD_UNSORTED_FREE_LIST tree = NULL; @@ -1535,7 +1535,7 @@ cuddRehash( saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - nodelist = ALLOC(DdNodePtr, slots); + nodelist = ABC_ALLOC(DdNodePtr, slots); MMoutOfMemory = saveHandler; if (nodelist == NULL) { (void) fprintf(unique->err, @@ -1544,7 +1544,7 @@ cuddRehash( /* Prevent frequent resizing attempts. */ (void) cuddGarbageCollect(unique,1); if (unique->stash != NULL) { - FREE(unique->stash); + ABC_FREE(unique->stash); unique->stash = NULL; /* Inhibit resizing of tables. */ cuddSlowTableGrowth(unique); @@ -1580,7 +1580,7 @@ cuddRehash( } *evenP = *oddP = sentinel; } - FREE(oldnodelist); + ABC_FREE(oldnodelist); #ifdef DD_VERBOSE (void) fprintf(unique->err, @@ -1602,7 +1602,7 @@ cuddRehash( shift = oldshift - 1; saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - nodelist = ALLOC(DdNodePtr, slots); + nodelist = ABC_ALLOC(DdNodePtr, slots); MMoutOfMemory = saveHandler; if (nodelist == NULL) { int j; @@ -1633,7 +1633,7 @@ cuddRehash( node = next; } } - FREE(oldnodelist); + ABC_FREE(oldnodelist); #ifdef DD_VERBOSE (void) fprintf(unique->err, @@ -1681,7 +1681,7 @@ cuddShrinkSubtable( slots = oldslots >> 1; saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - nodelist = ALLOC(DdNodePtr, slots); + nodelist = ABC_ALLOC(DdNodePtr, slots); MMoutOfMemory = saveHandler; if (nodelist == NULL) { return; @@ -1730,7 +1730,7 @@ cuddShrinkSubtable( node = next; } } - FREE(oldnodelist); + ABC_FREE(oldnodelist); unique->memused += ((long) slots - (long) oldslots) * sizeof(DdNode *); unique->slots += slots - oldslots; @@ -1815,7 +1815,7 @@ cuddInsertSubtables( unique->perm[oldsize+i] = level + i; unique->invperm[level+i] = oldsize + i; newnodelist = unique->subtables[level+i].nodelist = - ALLOC(DdNodePtr, numSlots); + ABC_ALLOC(DdNodePtr, numSlots); if (newnodelist == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -1841,40 +1841,40 @@ cuddInsertSubtables( unique->maxSize, newsize); #endif /* Allocate memory for new arrays (except nodelists). */ - newsubtables = ALLOC(DdSubtable,newsize); + newsubtables = ABC_ALLOC(DdSubtable,newsize); if (newsubtables == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - newvars = ALLOC(DdNodePtr,newsize); + newvars = ABC_ALLOC(DdNodePtr,newsize); if (newvars == NULL) { unique->errorCode = CUDD_MEMORY_OUT; - FREE(newsubtables); + ABC_FREE(newsubtables); return(0); } - newperm = ALLOC(int,newsize); + newperm = ABC_ALLOC(int,newsize); if (newperm == NULL) { unique->errorCode = CUDD_MEMORY_OUT; - FREE(newsubtables); - FREE(newvars); + ABC_FREE(newsubtables); + ABC_FREE(newvars); return(0); } - newinvperm = ALLOC(int,newsize); + newinvperm = ABC_ALLOC(int,newsize); if (newinvperm == NULL) { unique->errorCode = CUDD_MEMORY_OUT; - FREE(newsubtables); - FREE(newvars); - FREE(newperm); + ABC_FREE(newsubtables); + ABC_FREE(newvars); + ABC_FREE(newperm); return(0); } if (unique->map != NULL) { - newmap = ALLOC(int,newsize); + newmap = ABC_ALLOC(int,newsize); if (newmap == NULL) { unique->errorCode = CUDD_MEMORY_OUT; - FREE(newsubtables); - FREE(newvars); - FREE(newperm); - FREE(newinvperm); + ABC_FREE(newsubtables); + ABC_FREE(newvars); + ABC_FREE(newperm); + ABC_FREE(newinvperm); return(0); } unique->memused += (newsize - unique->maxSize) * sizeof(int); @@ -1919,7 +1919,7 @@ cuddInsertSubtables( newperm[oldsize + i - level] = i; newinvperm[i] = oldsize + i - level; - newnodelist = newsubtables[i].nodelist = ALLOC(DdNodePtr, numSlots); + newnodelist = newsubtables[i].nodelist = ABC_ALLOC(DdNodePtr, numSlots); if (newnodelist == NULL) { /* We are going to leak some memory. We should clean up. */ unique->errorCode = CUDD_MEMORY_OUT; @@ -1957,23 +1957,23 @@ cuddInsertSubtables( for (i = oldsize; i < oldsize + n; i++) { newmap[i] = i; } - FREE(unique->map); + ABC_FREE(unique->map); unique->map = newmap; } - /* Install the new tables and free the old ones. */ - FREE(unique->subtables); + /* Install the new tables and ABC_FREE the old ones. */ + ABC_FREE(unique->subtables); unique->subtables = newsubtables; unique->maxSize = newsize; - FREE(unique->vars); + ABC_FREE(unique->vars); unique->vars = newvars; - FREE(unique->perm); + ABC_FREE(unique->perm); unique->perm = newperm; - FREE(unique->invperm); + ABC_FREE(unique->invperm); unique->invperm = newinvperm; /* Update the stack for iterative procedures. */ if (newsize > unique->maxSizeZ) { - FREE(unique->stack); - unique->stack = ALLOC(DdNodePtr,newsize + 1); + ABC_FREE(unique->stack); + unique->stack = ABC_ALLOC(DdNodePtr,newsize + 1); if (unique->stack == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2016,7 +2016,7 @@ cuddInsertSubtables( unique->subtables[j].maxKeys = unique->subtables[j+n].maxKeys; unique->subtables[j].dead = unique->subtables[j+n].dead; - FREE(unique->subtables[j].nodelist); + ABC_FREE(unique->subtables[j].nodelist); unique->subtables[j].nodelist = unique->subtables[j+n].nodelist; unique->subtables[j+n].nodelist = NULL; @@ -2134,7 +2134,7 @@ cuddDestroySubtables( #ifdef DD_DEBUG assert(subtables[level].keys == 0); #endif - FREE(nodelist); + ABC_FREE(nodelist); unique->memused -= sizeof(DdNodePtr) * subtables[level].slots; unique->slots -= subtables[level].slots; unique->dead -= subtables[level].dead; @@ -2174,7 +2174,7 @@ cuddDestroySubtables( ** an out-of-bounds access to unique->vars would result. */ if (unique->map != NULL) { cuddCacheFlush(unique); - FREE(unique->map); + ABC_FREE(unique->map); unique->map = NULL; } @@ -2228,7 +2228,7 @@ cuddResizeTableZdd( unique->permZ[i] = i; unique->invpermZ[i] = i; newnodelist = unique->subtableZ[i].nodelist = - ALLOC(DdNodePtr, numSlots); + ABC_ALLOC(DdNodePtr, numSlots); if (newnodelist == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2248,17 +2248,17 @@ cuddResizeTableZdd( "Increasing the ZDD table size from %d to %d\n", unique->maxSizeZ, newsize); #endif - newsubtables = ALLOC(DdSubtable,newsize); + newsubtables = ABC_ALLOC(DdSubtable,newsize); if (newsubtables == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - newperm = ALLOC(int,newsize); + newperm = ABC_ALLOC(int,newsize); if (newperm == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - newinvperm = ALLOC(int,newsize); + newinvperm = ABC_ALLOC(int,newsize); if (newinvperm == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2266,8 +2266,8 @@ cuddResizeTableZdd( unique->memused += (newsize - unique->maxSizeZ) * ((numSlots+1) * sizeof(DdNode *) + 2 * sizeof(int) + sizeof(DdSubtable)); if (newsize > unique->maxSize) { - FREE(unique->stack); - unique->stack = ALLOC(DdNodePtr,newsize + 1); + ABC_FREE(unique->stack); + unique->stack = ABC_ALLOC(DdNodePtr,newsize + 1); if (unique->stack == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2296,7 +2296,7 @@ cuddResizeTableZdd( newsubtables[i].dead = 0; newperm[i] = i; newinvperm[i] = i; - newnodelist = newsubtables[i].nodelist = ALLOC(DdNodePtr, numSlots); + newnodelist = newsubtables[i].nodelist = ABC_ALLOC(DdNodePtr, numSlots); if (newnodelist == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2305,12 +2305,12 @@ cuddResizeTableZdd( newnodelist[j] = NULL; } } - FREE(unique->subtableZ); + ABC_FREE(unique->subtableZ); unique->subtableZ = newsubtables; unique->maxSizeZ = newsize; - FREE(unique->permZ); + ABC_FREE(unique->permZ); unique->permZ = newperm; - FREE(unique->invpermZ); + ABC_FREE(unique->invpermZ); unique->invpermZ = newinvperm; } unique->slots += (index + 1 - unique->sizeZ) * numSlots; @@ -2428,7 +2428,7 @@ ddRehashZdd( saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - nodelist = ALLOC(DdNodePtr, slots); + nodelist = ABC_ALLOC(DdNodePtr, slots); MMoutOfMemory = saveHandler; if (nodelist == NULL) { int j; @@ -2458,7 +2458,7 @@ ddRehashZdd( node = next; } } - FREE(oldnodelist); + ABC_FREE(oldnodelist); #ifdef DD_VERBOSE (void) fprintf(unique->err, @@ -2523,10 +2523,10 @@ ddResizeTable( unique->perm[i] = i; unique->invperm[i] = i; newnodelist = unique->subtables[i].nodelist = - ALLOC(DdNodePtr, numSlots); + ABC_ALLOC(DdNodePtr, numSlots); if (newnodelist == NULL) { for (j = oldsize; j < i; j++) { - FREE(unique->subtables[j].nodelist); + ABC_FREE(unique->subtables[j].nodelist); } unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2551,39 +2551,39 @@ ddResizeTable( "Increasing the table size from %d to %d\n", unique->maxSize, newsize); #endif - newsubtables = ALLOC(DdSubtable,newsize); + newsubtables = ABC_ALLOC(DdSubtable,newsize); if (newsubtables == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); } - newvars = ALLOC(DdNodePtr,newsize); + newvars = ABC_ALLOC(DdNodePtr,newsize); if (newvars == NULL) { - FREE(newsubtables); + ABC_FREE(newsubtables); unique->errorCode = CUDD_MEMORY_OUT; return(0); } - newperm = ALLOC(int,newsize); + newperm = ABC_ALLOC(int,newsize); if (newperm == NULL) { - FREE(newsubtables); - FREE(newvars); + ABC_FREE(newsubtables); + ABC_FREE(newvars); unique->errorCode = CUDD_MEMORY_OUT; return(0); } - newinvperm = ALLOC(int,newsize); + newinvperm = ABC_ALLOC(int,newsize); if (newinvperm == NULL) { - FREE(newsubtables); - FREE(newvars); - FREE(newperm); + ABC_FREE(newsubtables); + ABC_FREE(newvars); + ABC_FREE(newperm); unique->errorCode = CUDD_MEMORY_OUT; return(0); } if (unique->map != NULL) { - newmap = ALLOC(int,newsize); + newmap = ABC_ALLOC(int,newsize); if (newmap == NULL) { - FREE(newsubtables); - FREE(newvars); - FREE(newperm); - FREE(newinvperm); + ABC_FREE(newsubtables); + ABC_FREE(newvars); + ABC_FREE(newperm); + ABC_FREE(newinvperm); unique->errorCode = CUDD_MEMORY_OUT; return(0); } @@ -2592,15 +2592,15 @@ ddResizeTable( unique->memused += (newsize - unique->maxSize) * ((numSlots+1) * sizeof(DdNode *) + 2 * sizeof(int) + sizeof(DdSubtable)); if (newsize > unique->maxSizeZ) { - FREE(unique->stack); - unique->stack = ALLOC(DdNodePtr,newsize + 1); + ABC_FREE(unique->stack); + unique->stack = ABC_ALLOC(DdNodePtr,newsize + 1); if (unique->stack == NULL) { - FREE(newsubtables); - FREE(newvars); - FREE(newperm); - FREE(newinvperm); + ABC_FREE(newsubtables); + ABC_FREE(newvars); + ABC_FREE(newperm); + ABC_FREE(newinvperm); if (unique->map != NULL) { - FREE(newmap); + ABC_FREE(newmap); } unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2642,7 +2642,7 @@ ddResizeTable( newperm[i] = i; newinvperm[i] = i; - newnodelist = newsubtables[i].nodelist = ALLOC(DdNodePtr, numSlots); + newnodelist = newsubtables[i].nodelist = ABC_ALLOC(DdNodePtr, numSlots); if (newnodelist == NULL) { unique->errorCode = CUDD_MEMORY_OUT; return(0); @@ -2658,17 +2658,17 @@ ddResizeTable( for (i = oldsize; i <= index; i++) { newmap[i] = i; } - FREE(unique->map); + ABC_FREE(unique->map); unique->map = newmap; } - FREE(unique->subtables); + ABC_FREE(unique->subtables); unique->subtables = newsubtables; unique->maxSize = newsize; - FREE(unique->vars); + ABC_FREE(unique->vars); unique->vars = newvars; - FREE(unique->perm); + ABC_FREE(unique->perm); unique->perm = newperm; - FREE(unique->invperm); + ABC_FREE(unique->invperm); unique->invperm = newinvperm; } @@ -2695,7 +2695,7 @@ ddResizeTable( unique->vars[j] = NULL; } for (j = oldsize; j <= index; j++) { - FREE(unique->subtables[j].nodelist); + ABC_FREE(unique->subtables[j].nodelist); unique->subtables[j].nodelist = NULL; } unique->size = oldsize; diff --git a/src/bdd/cudd/cuddUtil.c b/src/bdd/cudd/cuddUtil.c index bc1a17eb..7e0eb22a 100644 --- a/src/bdd/cudd/cuddUtil.c +++ b/src/bdd/cudd/cuddUtil.c @@ -180,14 +180,14 @@ Cudd_PrintMinterm( background = manager->background; zero = Cudd_Not(manager->one); - list = ALLOC(int,manager->size); + list = ABC_ALLOC(int,manager->size); if (list == NULL) { manager->errorCode = CUDD_MEMORY_OUT; return(0); } for (i = 0; i < manager->size; i++) list[i] = 2; ddPrintMintermAux(manager,node,list); - FREE(list); + ABC_FREE(list); return(1); } /* end of Cudd_PrintMinterm */ @@ -221,7 +221,7 @@ Cudd_bddPrintCover( DdNode *cover; #endif - array = ALLOC(int, Cudd_ReadSize(dd)); + array = ABC_ALLOC(int, Cudd_ReadSize(dd)); if (array == NULL) return(0); lb = l; cuddRef(lb); @@ -235,7 +235,7 @@ Cudd_bddPrintCover( implicant = Cudd_LargestCube(dd,lb,&length); if (implicant == NULL) { Cudd_RecursiveDeref(dd,lb); - FREE(array); + ABC_FREE(array); return(0); } cuddRef(implicant); @@ -243,7 +243,7 @@ Cudd_bddPrintCover( if (prime == NULL) { Cudd_RecursiveDeref(dd,lb); Cudd_RecursiveDeref(dd,implicant); - FREE(array); + ABC_FREE(array); return(0); } cuddRef(prime); @@ -252,7 +252,7 @@ Cudd_bddPrintCover( if (tmp == NULL) { Cudd_RecursiveDeref(dd,lb); Cudd_RecursiveDeref(dd,prime); - FREE(array); + ABC_FREE(array); return(0); } cuddRef(tmp); @@ -262,7 +262,7 @@ Cudd_bddPrintCover( if (result == 0) { Cudd_RecursiveDeref(dd,lb); Cudd_RecursiveDeref(dd,prime); - FREE(array); + ABC_FREE(array); return(0); } for (q = 0; q < dd->size; q++) { @@ -287,7 +287,7 @@ Cudd_bddPrintCover( Cudd_RecursiveDeref(dd,cover); Cudd_RecursiveDeref(dd,lb); Cudd_RecursiveDeref(dd,prime); - FREE(array); + ABC_FREE(array); return(0); } cuddRef(tmp); @@ -298,7 +298,7 @@ Cudd_bddPrintCover( } (void) fprintf(dd->out, "\n"); Cudd_RecursiveDeref(dd,lb); - FREE(array); + ABC_FREE(array); #ifdef DD_DEBUG if (!Cudd_bddLeq(dd,cover,u) || !Cudd_bddLeq(dd,l,cover)) { Cudd_RecursiveDeref(dd,cover); @@ -707,7 +707,7 @@ Cudd_Support( /* Allocate and initialize support array for ddSupportStep. */ size = ddMax(dd->size, dd->sizeZ); - support = ALLOC(int,size); + support = ABC_ALLOC(int,size); if (support == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -745,7 +745,7 @@ Cudd_Support( } } while (dd->reordered == 1); - FREE(support); + ABC_FREE(support); if (res != NULL) cuddDeref(res); return(res); @@ -775,7 +775,7 @@ Cudd_SupportIndex( /* Allocate and initialize support array for ddSupportStep. */ size = ddMax(dd->size, dd->sizeZ); - support = ALLOC(int,size); + support = ABC_ALLOC(int,size); if (support == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -818,7 +818,7 @@ Cudd_SupportSize( /* Allocate and initialize support array for ddSupportStep. */ size = ddMax(dd->size, dd->sizeZ); - support = ALLOC(int,size); + support = ABC_ALLOC(int,size); if (support == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(CUDD_OUT_OF_MEM); @@ -837,7 +837,7 @@ Cudd_SupportSize( if (support[i] == 1) count++; } - FREE(support); + ABC_FREE(support); return(count); } /* end of Cudd_SupportSize */ @@ -870,7 +870,7 @@ Cudd_VectorSupport( /* Allocate and initialize support array for ddSupportStep. */ size = ddMax(dd->size, dd->sizeZ); - support = ALLOC(int,size); + support = ABC_ALLOC(int,size); if (support == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -899,7 +899,7 @@ Cudd_VectorSupport( if (tmp == NULL) { Cudd_RecursiveDeref(dd,res); Cudd_RecursiveDeref(dd,var); - FREE(support); + ABC_FREE(support); return(NULL); } cuddRef(tmp); @@ -909,7 +909,7 @@ Cudd_VectorSupport( } } - FREE(support); + ABC_FREE(support); cuddDeref(res); return(res); @@ -941,7 +941,7 @@ Cudd_VectorSupportIndex( /* Allocate and initialize support array for ddSupportStep. */ size = ddMax(dd->size, dd->sizeZ); - support = ALLOC(int,size); + support = ABC_ALLOC(int,size); if (support == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -990,7 +990,7 @@ Cudd_VectorSupportSize( /* Allocate and initialize support array for ddSupportStep. */ size = ddMax(dd->size, dd->sizeZ); - support = ALLOC(int,size); + support = ABC_ALLOC(int,size); if (support == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(CUDD_OUT_OF_MEM); @@ -1013,7 +1013,7 @@ Cudd_VectorSupportSize( if (support[i] == 1) count++; } - FREE(support); + ABC_FREE(support); return(count); } /* end of Cudd_VectorSupportSize */ @@ -1050,15 +1050,15 @@ Cudd_ClassifySupport( /* Allocate and initialize support arrays for ddSupportStep. */ size = ddMax(dd->size, dd->sizeZ); - supportF = ALLOC(int,size); + supportF = ABC_ALLOC(int,size); if (supportF == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(0); } - supportG = ALLOC(int,size); + supportG = ABC_ALLOC(int,size); if (supportG == NULL) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(supportF); + ABC_FREE(supportF); return(0); } for (i = 0; i < size; i++) { @@ -1087,7 +1087,7 @@ Cudd_ClassifySupport( Cudd_RecursiveDeref(dd,*onlyF); Cudd_RecursiveDeref(dd,*onlyG); Cudd_RecursiveDeref(dd,var); - FREE(supportF); FREE(supportG); + ABC_FREE(supportF); ABC_FREE(supportG); return(0); } cuddRef(tmp); @@ -1100,7 +1100,7 @@ Cudd_ClassifySupport( Cudd_RecursiveDeref(dd,*onlyF); Cudd_RecursiveDeref(dd,*onlyG); Cudd_RecursiveDeref(dd,var); - FREE(supportF); FREE(supportG); + ABC_FREE(supportF); ABC_FREE(supportG); return(0); } cuddRef(tmp); @@ -1113,7 +1113,7 @@ Cudd_ClassifySupport( Cudd_RecursiveDeref(dd,*onlyF); Cudd_RecursiveDeref(dd,*onlyG); Cudd_RecursiveDeref(dd,var); - FREE(supportF); FREE(supportG); + ABC_FREE(supportF); ABC_FREE(supportG); return(0); } cuddRef(tmp); @@ -1123,7 +1123,7 @@ Cudd_ClassifySupport( Cudd_RecursiveDeref(dd,var); } - FREE(supportF); FREE(supportG); + ABC_FREE(supportF); ABC_FREE(supportG); cuddDeref(*common); cuddDeref(*onlyF); cuddDeref(*onlyG); return(1); @@ -1254,15 +1254,15 @@ Cudd_bddPickOneMinterm( DdNode *old, *neW; size = dd->size; - string = ALLOC(char, size); + string = ABC_ALLOC(char, size); if (string == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } - indices = ALLOC(int,n); + indices = ABC_ALLOC(int,n); if (indices == NULL) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(string); + ABC_FREE(string); return(NULL); } @@ -1272,8 +1272,8 @@ Cudd_bddPickOneMinterm( result = Cudd_bddPickOneCube(dd,f,string); if (result == 0) { - FREE(string); - FREE(indices); + ABC_FREE(string); + ABC_FREE(indices); return(NULL); } @@ -1290,8 +1290,8 @@ Cudd_bddPickOneMinterm( for (i = n-1; i >= 0; i--) { neW = Cudd_bddAnd(dd,old,Cudd_NotCond(vars[i],string[indices[i]]==0)); if (neW == NULL) { - FREE(string); - FREE(indices); + ABC_FREE(string); + ABC_FREE(indices); Cudd_RecursiveDeref(dd,old); return(NULL); } @@ -1312,8 +1312,8 @@ Cudd_bddPickOneMinterm( cuddDeref(old); #endif - FREE(string); - FREE(indices); + ABC_FREE(string); + ABC_FREE(indices); return(old); } /* end of Cudd_bddPickOneMinterm */ @@ -1366,29 +1366,29 @@ Cudd_bddPickArbitraryMinterms( } size = dd->size; - string = ALLOC(char *, k); + string = ABC_ALLOC(char *, k); if (string == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } for (i = 0; i < k; i++) { - string[i] = ALLOC(char, size + 1); + string[i] = ABC_ALLOC(char, size + 1); if (string[i] == NULL) { for (j = 0; j < i; j++) - FREE(string[i]); - FREE(string); + ABC_FREE(string[i]); + ABC_FREE(string); dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } for (j = 0; j < size; j++) string[i][j] = '2'; string[i][size] = '\0'; } - indices = ALLOC(int,n); + indices = ABC_ALLOC(int,n); if (indices == NULL) { dd->errorCode = CUDD_MEMORY_OUT; for (i = 0; i < k; i++) - FREE(string[i]); - FREE(string); + ABC_FREE(string[i]); + ABC_FREE(string); return(NULL); } @@ -1399,29 +1399,29 @@ Cudd_bddPickArbitraryMinterms( result = ddPickArbitraryMinterms(dd,f,n,k,string); if (result == 0) { for (i = 0; i < k; i++) - FREE(string[i]); - FREE(string); - FREE(indices); + ABC_FREE(string[i]); + ABC_FREE(string); + ABC_FREE(indices); return(NULL); } - old = ALLOC(DdNode *, k); + old = ABC_ALLOC(DdNode *, k); if (old == NULL) { dd->errorCode = CUDD_MEMORY_OUT; for (i = 0; i < k; i++) - FREE(string[i]); - FREE(string); - FREE(indices); + ABC_FREE(string[i]); + ABC_FREE(string); + ABC_FREE(indices); return(NULL); } - saveString = ALLOC(char, size + 1); + saveString = ABC_ALLOC(char, size + 1); if (saveString == NULL) { dd->errorCode = CUDD_MEMORY_OUT; for (i = 0; i < k; i++) - FREE(string[i]); - FREE(string); - FREE(indices); - FREE(old); + ABC_FREE(string[i]); + ABC_FREE(string); + ABC_FREE(indices); + ABC_FREE(old); return(NULL); } saveFlag = 0; @@ -1488,14 +1488,14 @@ Cudd_bddPickArbitraryMinterms( neW = Cudd_bddAnd(dd,old[i],vars[j]); } if (neW == NULL) { - FREE(saveString); + ABC_FREE(saveString); for (l = 0; l < k; l++) - FREE(string[l]); - FREE(string); - FREE(indices); + ABC_FREE(string[l]); + ABC_FREE(string); + ABC_FREE(indices); for (l = 0; l <= i; l++) Cudd_RecursiveDeref(dd,old[l]); - FREE(old); + ABC_FREE(old); return(NULL); } cuddRef(neW); @@ -1505,25 +1505,25 @@ Cudd_bddPickArbitraryMinterms( /* Test. */ if (!Cudd_bddLeq(dd,old[i],f)) { - FREE(saveString); + ABC_FREE(saveString); for (l = 0; l < k; l++) - FREE(string[l]); - FREE(string); - FREE(indices); + ABC_FREE(string[l]); + ABC_FREE(string); + ABC_FREE(indices); for (l = 0; l <= i; l++) Cudd_RecursiveDeref(dd,old[l]); - FREE(old); + ABC_FREE(old); return(NULL); } } - FREE(saveString); + ABC_FREE(saveString); for (i = 0; i < k; i++) { cuddDeref(old[i]); - FREE(string[i]); + ABC_FREE(string[i]); } - FREE(string); - FREE(indices); + ABC_FREE(string); + ABC_FREE(indices); return(old); } /* end of Cudd_bddPickArbitraryMinterms */ @@ -1576,7 +1576,7 @@ Cudd_SubsetWithMaskVars( zero = Cudd_Not(dd->one); size = dd->size; - weight = ALLOC(double,size); + weight = ABC_ALLOC(double,size); if (weight == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -1596,15 +1596,15 @@ Cudd_SubsetWithMaskVars( Cudd_RecursiveDeref(dd,cof); } - string = ALLOC(char, size + 1); + string = ABC_ALLOC(char, size + 1); if (string == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); } - mask = ALLOC(int, size); + mask = ABC_ALLOC(int, size); if (mask == NULL) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(string); + ABC_FREE(string); return(NULL); } for (i = 0; i < size; i++) { @@ -1612,11 +1612,11 @@ Cudd_SubsetWithMaskVars( mask[i] = 0; } string[size] = '\0'; - indices = ALLOC(int,nvars); + indices = ABC_ALLOC(int,nvars); if (indices == NULL) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(string); - FREE(mask); + ABC_FREE(string); + ABC_FREE(mask); return(NULL); } for (i = 0; i < nvars; i++) { @@ -1625,9 +1625,9 @@ Cudd_SubsetWithMaskVars( result = ddPickRepresentativeCube(dd,f,nvars,weight,string); if (result == 0) { - FREE(string); - FREE(mask); - FREE(indices); + ABC_FREE(string); + ABC_FREE(mask); + ABC_FREE(indices); return(NULL); } @@ -1642,9 +1642,9 @@ Cudd_SubsetWithMaskVars( } else continue; if (newCube == NULL) { - FREE(string); - FREE(mask); - FREE(indices); + ABC_FREE(string); + ABC_FREE(mask); + ABC_FREE(indices); Cudd_RecursiveDeref(dd,cube); return(NULL); } @@ -1683,9 +1683,9 @@ Cudd_SubsetWithMaskVars( } else continue; if (newCube == NULL) { - FREE(string); - FREE(mask); - FREE(indices); + ABC_FREE(string); + ABC_FREE(mask); + ABC_FREE(indices); Cudd_RecursiveDeref(dd,cube); return(NULL); } @@ -1706,10 +1706,10 @@ Cudd_SubsetWithMaskVars( subset = NULL; } - FREE(string); - FREE(mask); - FREE(indices); - FREE(weight); + ABC_FREE(string); + ABC_FREE(mask); + ABC_FREE(indices); + ABC_FREE(weight); return(subset); } /* end of Cudd_SubsetWithMaskVars */ @@ -1757,7 +1757,7 @@ Cudd_FirstCube( if (dd == NULL || f == NULL) return(NULL); /* Allocate generator an initialize it. */ - gen = ALLOC(DdGen,1); + gen = ABC_ALLOC(DdGen,1); if (gen == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -1773,10 +1773,10 @@ Cudd_FirstCube( gen->node = NULL; nvars = dd->size; - gen->gen.cubes.cube = ALLOC(int,nvars); + gen->gen.cubes.cube = ABC_ALLOC(int,nvars); if (gen->gen.cubes.cube == NULL) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(gen); + ABC_FREE(gen); return(NULL); } for (i = 0; i < nvars; i++) gen->gen.cubes.cube[i] = 2; @@ -1785,11 +1785,11 @@ Cudd_FirstCube( ** because a path may have nodes at all levels, including the ** constant level. */ - gen->stack.stack = ALLOC(DdNode *, nvars+1); + gen->stack.stack = ABC_ALLOC(DdNode *, nvars+1); if (gen->stack.stack == NULL) { dd->errorCode = CUDD_MEMORY_OUT; - FREE(gen->gen.cubes.cube); - FREE(gen); + ABC_FREE(gen->gen.cubes.cube); + ABC_FREE(gen); return(NULL); } for (i = 0; i <= nvars; i++) gen->stack.stack[i] = NULL; @@ -2172,7 +2172,7 @@ Cudd_FirstNode( if (dd == NULL || f == NULL) return(NULL); /* Allocate generator an initialize it. */ - gen = ALLOC(DdGen,1); + gen = ABC_ALLOC(DdGen,1); if (gen == NULL) { dd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -2189,7 +2189,7 @@ Cudd_FirstNode( gen->gen.nodes.visited = st_init_table(st_ptrcmp,st_ptrhash); if (gen->gen.nodes.visited == NULL) { - FREE(gen); + ABC_FREE(gen); return(NULL); } @@ -2197,7 +2197,7 @@ Cudd_FirstNode( retval = cuddCollectNodes(Cudd_Regular(f),gen->gen.nodes.visited); if (retval == 0) { st_free_table(gen->gen.nodes.visited); - FREE(gen); + ABC_FREE(gen); return(NULL); } @@ -2205,7 +2205,7 @@ Cudd_FirstNode( gen->gen.nodes.stGen = st_init_gen(gen->gen.nodes.visited); if (gen->gen.nodes.stGen == NULL) { st_free_table(gen->gen.nodes.visited); - FREE(gen); + ABC_FREE(gen); return(NULL); } @@ -2276,8 +2276,8 @@ Cudd_GenFree( switch (gen->type) { case CUDD_GEN_CUBES: case CUDD_GEN_ZDD_PATHS: - FREE(gen->gen.cubes.cube); - FREE(gen->stack.stack); + ABC_FREE(gen->gen.cubes.cube); + ABC_FREE(gen->stack.stack); break; case CUDD_GEN_NODES: st_free_gen(gen->gen.nodes.stGen); @@ -2286,7 +2286,7 @@ Cudd_GenFree( default: return(0); } - FREE(gen); + ABC_FREE(gen); return(0); } /* end of Cudd_GenFree */ @@ -2679,7 +2679,7 @@ cuddStCountfree( double *d; d = (double *)value; - FREE(d); + ABC_FREE(d); return(ST_CONTINUE); } /* end of cuddStCountfree */ @@ -3233,7 +3233,7 @@ ddCountPathAux( if (paths2 == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM); paths = paths1 + paths2; - ppaths = ALLOC(double,1); + ppaths = ABC_ALLOC(double,1); if (ppaths == NULL) { return((double)CUDD_OUT_OF_MEM); } @@ -3241,7 +3241,7 @@ ddCountPathAux( *ppaths = paths; if (st_add_direct(table,(char *)node, (char *)ppaths) == ST_OUT_OF_MEM) { - FREE(ppaths); + ABC_FREE(ppaths); return((double)CUDD_OUT_OF_MEM); } return(paths); @@ -3371,7 +3371,7 @@ ddCountPathsToNonZero( if (paths2 == (double)CUDD_OUT_OF_MEM) return((double)CUDD_OUT_OF_MEM); paths = paths1 + paths2; - ppaths = ALLOC(double,1); + ppaths = ABC_ALLOC(double,1); if (ppaths == NULL) { return((double)CUDD_OUT_OF_MEM); } @@ -3379,7 +3379,7 @@ ddCountPathsToNonZero( *ppaths = paths; if (st_add_direct(table,(char *)N, (char *)ppaths) == ST_OUT_OF_MEM) { - FREE(ppaths); + ABC_FREE(ppaths); return((double)CUDD_OUT_OF_MEM); } return(paths); diff --git a/src/bdd/cudd/cuddWindow.c b/src/bdd/cudd/cuddWindow.c index 9ceb79b2..b97e3358 100644 --- a/src/bdd/cudd/cuddWindow.c +++ b/src/bdd/cudd/cuddWindow.c @@ -253,7 +253,7 @@ ddWindowConv2( if (high-low < 1) return(ddWindowConv2(table,low,high)); nwin = high-low; - events = ALLOC(int,nwin); + events = ABC_ALLOC(int,nwin); if (events == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -270,13 +270,13 @@ ddWindowConv2( size = res; res = cuddSwapInPlace(table,x+low,x+low+1); if (res == 0) { - FREE(events); + ABC_FREE(events); return(0); } if (res >= size) { /* no improvement: undo permutation */ res = cuddSwapInPlace(table,x+low,x+low+1); if (res == 0) { - FREE(events); + ABC_FREE(events); return(0); } } @@ -304,7 +304,7 @@ ddWindowConv2( #endif } while (newevent); - FREE(events); + ABC_FREE(events); return(1); @@ -487,7 +487,7 @@ ddWindowConv3( if (high-low < 2) return(ddWindowConv2(table,low,high)); nwin = high-low-1; - events = ALLOC(int,nwin); + events = ABC_ALLOC(int,nwin); if (events == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -524,7 +524,7 @@ ddWindowConv3( newevent = 1; break; default: - FREE(events); + ABC_FREE(events); return(0); } events[x] = 0; @@ -546,7 +546,7 @@ ddWindowConv3( #endif } while (newevent); - FREE(events); + ABC_FREE(events); return(1); @@ -888,7 +888,7 @@ ddWindowConv4( if (high-low < 3) return(ddWindowConv3(table,low,high)); nwin = high-low-2; - events = ALLOC(int,nwin); + events = ABC_ALLOC(int,nwin); if (events == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -967,7 +967,7 @@ ddWindowConv4( newevent = 1; break; default: - FREE(events); + ABC_FREE(events); return(0); } events[x] = 0; @@ -989,7 +989,7 @@ ddWindowConv4( #endif } while (newevent); - FREE(events); + ABC_FREE(events); return(1); diff --git a/src/bdd/cudd/cuddZddCount.c b/src/bdd/cudd/cuddZddCount.c index 6c6ec1df..bc8a1ee4 100644 --- a/src/bdd/cudd/cuddZddCount.c +++ b/src/bdd/cudd/cuddZddCount.c @@ -205,13 +205,13 @@ cuddZddCountStep( res = cuddZddCountStep(cuddE(P), table, base, empty) + cuddZddCountStep(cuddT(P), table, base, empty); - dummy = ALLOC(int, 1); + dummy = ABC_ALLOC(int, 1); if (dummy == NULL) { return(CUDD_OUT_OF_MEM); } *dummy = res; if (st_insert(table, (char *)P, (char *)dummy) == ST_OUT_OF_MEM) { - FREE(dummy); + ABC_FREE(dummy); return(CUDD_OUT_OF_MEM); } @@ -255,13 +255,13 @@ cuddZddCountDoubleStep( res = cuddZddCountDoubleStep(cuddE(P), table, base, empty) + cuddZddCountDoubleStep(cuddT(P), table, base, empty); - dummy = ALLOC(double, 1); + dummy = ABC_ALLOC(double, 1); if (dummy == NULL) { return((double)CUDD_OUT_OF_MEM); } *dummy = res; if (st_insert(table, (char *)P, (char *)dummy) == ST_OUT_OF_MEM) { - FREE(dummy); + ABC_FREE(dummy); return((double)CUDD_OUT_OF_MEM); } @@ -291,7 +291,7 @@ st_zdd_countfree( int *d; d = (int *)value; - FREE(d); + ABC_FREE(d); return(ST_CONTINUE); } /* end of st_zdd_countfree */ @@ -318,7 +318,7 @@ st_zdd_count_dbl_free( double *d; d = (double *)value; - FREE(d); + ABC_FREE(d); return(ST_CONTINUE); } /* end of st_zdd_count_dbl_free */ diff --git a/src/bdd/cudd/cuddZddGroup.c b/src/bdd/cudd/cuddZddGroup.c index c26ea533..8845dc49 100644 --- a/src/bdd/cudd/cuddZddGroup.c +++ b/src/bdd/cudd/cuddZddGroup.c @@ -624,17 +624,17 @@ zddGroupSifting( /* Order variables to sift. */ entry = NULL; sifted = NULL; - var = ALLOC(int,nvars); + var = ABC_ALLOC(int,nvars); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto zddGroupSiftingOutOfMem; } - entry = ALLOC(int,nvars); + entry = ABC_ALLOC(int,nvars); if (entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto zddGroupSiftingOutOfMem; } - sifted = ALLOC(int,nvars); + sifted = ABC_ALLOC(int,nvars); if (sifted == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto zddGroupSiftingOutOfMem; @@ -700,16 +700,16 @@ zddGroupSifting( #endif } /* for */ - FREE(sifted); - FREE(var); - FREE(entry); + ABC_FREE(sifted); + ABC_FREE(var); + ABC_FREE(entry); return(1); zddGroupSiftingOutOfMem: - if (entry != NULL) FREE(entry); - if (var != NULL) FREE(var); - if (sifted != NULL) FREE(sifted); + if (entry != NULL) ABC_FREE(entry); + if (var != NULL) ABC_FREE(var); + if (sifted != NULL) ABC_FREE(sifted); return(0); diff --git a/src/bdd/cudd/cuddZddLin.c b/src/bdd/cudd/cuddZddLin.c index ef2cd298..4d4135d1 100644 --- a/src/bdd/cudd/cuddZddLin.c +++ b/src/bdd/cudd/cuddZddLin.c @@ -140,12 +140,12 @@ cuddZddLinearSifting( /* Find order in which to sift variables. */ var = NULL; - zdd_entry = ALLOC(int, size); + zdd_entry = ABC_ALLOC(int, size); if (zdd_entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSiftingOutOfMem; } - var = ALLOC(int, size); + var = ABC_ALLOC(int, size); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSiftingOutOfMem; @@ -184,15 +184,15 @@ cuddZddLinearSifting( #endif } - FREE(var); - FREE(zdd_entry); + ABC_FREE(var); + ABC_FREE(zdd_entry); return(1); cuddZddSiftingOutOfMem: - if (zdd_entry != NULL) FREE(zdd_entry); - if (var != NULL) FREE(var); + if (zdd_entry != NULL) ABC_FREE(zdd_entry); + if (var != NULL) ABC_FREE(var); return(0); diff --git a/src/bdd/cudd/cuddZddReord.c b/src/bdd/cudd/cuddZddReord.c index 6e7d3438..4c6e394b 100644 --- a/src/bdd/cudd/cuddZddReord.c +++ b/src/bdd/cudd/cuddZddReord.c @@ -338,7 +338,7 @@ cuddZddAlignToBdd( if (M * table->size != table->sizeZ) return(0); /* Create and initialize the inverse permutation array. */ - invpermZ = ALLOC(int,table->sizeZ); + invpermZ = ABC_ALLOC(int,table->sizeZ); if (invpermZ == NULL) { table->errorCode = CUDD_MEMORY_OUT; return(0); @@ -358,7 +358,7 @@ cuddZddAlignToBdd( cuddGarbageCollectZdd(table,0); result = zddShuffle(table, invpermZ); - FREE(invpermZ); + ABC_FREE(invpermZ); /* Fix the ZDD variable group tree. */ zddFixTree(table,table->treeZ); return(result); @@ -852,12 +852,12 @@ cuddZddSifting( /* Find order in which to sift variables. */ var = NULL; - zdd_entry = ALLOC(int, size); + zdd_entry = ABC_ALLOC(int, size); if (zdd_entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSiftingOutOfMem; } - var = ALLOC(int, size); + var = ABC_ALLOC(int, size); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSiftingOutOfMem; @@ -896,15 +896,15 @@ cuddZddSifting( #endif } - FREE(var); - FREE(zdd_entry); + ABC_FREE(var); + ABC_FREE(zdd_entry); return(1); cuddZddSiftingOutOfMem: - if (zdd_entry != NULL) FREE(zdd_entry); - if (var != NULL) FREE(var); + if (zdd_entry != NULL) ABC_FREE(zdd_entry); + if (var != NULL) ABC_FREE(var); return(0); @@ -1438,7 +1438,7 @@ zddReorderPostprocess( slots = oldslots >> 1; saveHandler = MMoutOfMemory; MMoutOfMemory = Cudd_OutOfMem; - nodelist = ALLOC(DdNodePtr, slots); + nodelist = ABC_ALLOC(DdNodePtr, slots); MMoutOfMemory = saveHandler; if (nodelist == NULL) { return(1); @@ -1467,7 +1467,7 @@ zddReorderPostprocess( node = next; } } - FREE(oldnodelist); + ABC_FREE(oldnodelist); table->memused += (slots - oldslots) * sizeof(DdNode *); table->slots += slots - oldslots; diff --git a/src/bdd/cudd/cuddZddSymm.c b/src/bdd/cudd/cuddZddSymm.c index 0930e077..c752c394 100644 --- a/src/bdd/cudd/cuddZddSymm.c +++ b/src/bdd/cudd/cuddZddSymm.c @@ -292,12 +292,12 @@ cuddZddSymmSifting( /* Find order in which to sift variables. */ var = NULL; - zdd_entry = ALLOC(int, nvars); + zdd_entry = ABC_ALLOC(int, nvars); if (zdd_entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSymmSiftingOutOfMem; } - var = ALLOC(int, nvars); + var = ABC_ALLOC(int, nvars); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSymmSiftingOutOfMem; @@ -344,8 +344,8 @@ cuddZddSymmSifting( } } - FREE(var); - FREE(zdd_entry); + ABC_FREE(var); + ABC_FREE(zdd_entry); cuddZddSymmSummary(table, lower, upper, &symvars, &symgroups); @@ -359,9 +359,9 @@ cuddZddSymmSifting( cuddZddSymmSiftingOutOfMem: if (zdd_entry != NULL) - FREE(zdd_entry); + ABC_FREE(zdd_entry); if (var != NULL) - FREE(var); + ABC_FREE(var); return(0); @@ -417,12 +417,12 @@ cuddZddSymmSiftingConv( /* Find order in which to sift variables. */ var = NULL; - zdd_entry = ALLOC(int, nvars); + zdd_entry = ABC_ALLOC(int, nvars); if (zdd_entry == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSymmSiftingConvOutOfMem; } - var = ALLOC(int, nvars); + var = ABC_ALLOC(int, nvars); if (var == NULL) { table->errorCode = CUDD_MEMORY_OUT; goto cuddZddSymmSiftingConvOutOfMem; @@ -532,17 +532,17 @@ cuddZddSymmSiftingConv( symgroups); #endif - FREE(var); - FREE(zdd_entry); + ABC_FREE(var); + ABC_FREE(zdd_entry); return(1+symvars); cuddZddSymmSiftingConvOutOfMem: if (zdd_entry != NULL) - FREE(zdd_entry); + ABC_FREE(zdd_entry); if (var != NULL) - FREE(var); + ABC_FREE(var); return(0); diff --git a/src/bdd/cudd/cuddZddUtil.c b/src/bdd/cudd/cuddZddUtil.c index 616d16d4..efa73d15 100644 --- a/src/bdd/cudd/cuddZddUtil.c +++ b/src/bdd/cudd/cuddZddUtil.c @@ -105,14 +105,14 @@ Cudd_zddPrintMinterm( int *list; size = (int)zdd->sizeZ; - list = ALLOC(int, size); + list = ABC_ALLOC(int, size); if (list == NULL) { zdd->errorCode = CUDD_MEMORY_OUT; return(0); } for (i = 0; i < size; i++) list[i] = 3; /* bogus value should disappear */ zdd_print_minterm_aux(zdd, node, 0, list); - FREE(list); + ABC_FREE(list); return(1); } /* end of Cudd_zddPrintMinterm */ @@ -140,14 +140,14 @@ Cudd_zddPrintCover( size = (int)zdd->sizeZ; if (size % 2 != 0) return(0); /* number of variables should be even */ - list = ALLOC(int, size); + list = ABC_ALLOC(int, size); if (list == NULL) { zdd->errorCode = CUDD_MEMORY_OUT; return(0); } for (i = 0; i < size; i++) list[i] = 3; /* bogus value should disappear */ zddPrintCoverAux(zdd, node, 0, list); - FREE(list); + ABC_FREE(list); return(1); } /* end of Cudd_zddPrintCover */ @@ -251,7 +251,7 @@ Cudd_zddFirstPath( if (zdd == NULL || f == NULL) return(NULL); /* Allocate generator an initialize it. */ - gen = ALLOC(DdGen,1); + gen = ABC_ALLOC(DdGen,1); if (gen == NULL) { zdd->errorCode = CUDD_MEMORY_OUT; return(NULL); @@ -267,10 +267,10 @@ Cudd_zddFirstPath( gen->node = NULL; nvars = zdd->sizeZ; - gen->gen.cubes.cube = ALLOC(int,nvars); + gen->gen.cubes.cube = ABC_ALLOC(int,nvars); if (gen->gen.cubes.cube == NULL) { zdd->errorCode = CUDD_MEMORY_OUT; - FREE(gen); + ABC_FREE(gen); return(NULL); } for (i = 0; i < nvars; i++) gen->gen.cubes.cube[i] = 2; @@ -279,11 +279,11 @@ Cudd_zddFirstPath( ** because a path may have nodes at all levels, including the ** constant level. */ - gen->stack.stack = ALLOC(DdNode *, nvars+1); + gen->stack.stack = ABC_ALLOC(DdNode *, nvars+1); if (gen->stack.stack == NULL) { zdd->errorCode = CUDD_MEMORY_OUT; - FREE(gen->gen.cubes.cube); - FREE(gen); + ABC_FREE(gen->gen.cubes.cube); + ABC_FREE(gen); return(NULL); } for (i = 0; i <= nvars; i++) gen->stack.stack[i] = NULL; @@ -450,7 +450,7 @@ Cudd_zddCoverPathToString( if (nvars & 1) return(NULL); nvars >>= 1; if (str == NULL) { - res = ALLOC(char, nvars+1); + res = ABC_ALLOC(char, nvars+1); if (res == NULL) return(NULL); } else { res = str; @@ -532,7 +532,7 @@ Cudd_zddDumpDot( long refAddr, diff, mask; /* Build a bit array with the support of f. */ - sorted = ALLOC(int,nvars); + sorted = ABC_ALLOC(int,nvars); if (sorted == NULL) { dd->errorCode = CUDD_MEMORY_OUT; goto failure; @@ -551,7 +551,7 @@ Cudd_zddDumpDot( } Cudd_RecursiveDeref(dd,support); } - support = NULL; /* so that we do not try to free it in case of failure */ + support = NULL; /* so that we do not try to ABC_FREE it in case of failure */ /* Initialize symbol table for visited nodes. */ visited = st_init_table(st_ptrcmp, st_ptrhash); @@ -744,11 +744,11 @@ Cudd_zddDumpDot( if (retval == EOF) goto failure; st_free_table(visited); - FREE(sorted); + ABC_FREE(sorted); return(1); failure: - if (sorted != NULL) FREE(sorted); + if (sorted != NULL) ABC_FREE(sorted); if (support != NULL) Cudd_RecursiveDeref(dd,support); if (visited != NULL) st_free_table(visited); return(0); diff --git a/src/bdd/dsd/dsd.h b/src/bdd/dsd/dsd.h index 4a16bfc1..affdbe6f 100644 --- a/src/bdd/dsd/dsd.h +++ b/src/bdd/dsd/dsd.h @@ -28,18 +28,6 @@ #ifndef __DSD_H__ #define __DSD_H__ -#ifdef __cplusplus -extern "C" { -#endif - -//////////////////////////////////////////////////////////////////////// -/// TYPEDEF DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -typedef struct Dsd_Manager_t_ Dsd_Manager_t; -typedef struct Dsd_Node_t_ Dsd_Node_t; -typedef enum Dsd_Type_t_ Dsd_Type_t; - //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -48,6 +36,10 @@ typedef enum Dsd_Type_t_ Dsd_Type_t; /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + // types of DSD nodes enum Dsd_Type_t_ { DSD_NODE_NONE = 0, @@ -58,15 +50,23 @@ enum Dsd_Type_t_ { DSD_NODE_PRIME = 5, }; +//////////////////////////////////////////////////////////////////////// +/// TYPEDEF DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +typedef struct Dsd_Manager_t_ Dsd_Manager_t; +typedef struct Dsd_Node_t_ Dsd_Node_t; +typedef enum Dsd_Type_t_ Dsd_Type_t; + //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// // complementation and testing for pointers for decomposition entries -#define Dsd_IsComplement(p) (((int)((PORT_PTRUINT_T) (p) & 01))) -#define Dsd_Regular(p) ((Dsd_Node_t *)((PORT_PTRUINT_T)(p) & ~01)) -#define Dsd_Not(p) ((Dsd_Node_t *)((PORT_PTRUINT_T)(p) ^ 01)) -#define Dsd_NotCond(p,c) ((Dsd_Node_t *)((PORT_PTRUINT_T)(p) ^ (c))) +#define Dsd_IsComplement(p) (((int)((ABC_PTRUINT_T) (p) & 01))) +#define Dsd_Regular(p) ((Dsd_Node_t *)((ABC_PTRUINT_T)(p) & ~01)) +#define Dsd_Not(p) ((Dsd_Node_t *)((ABC_PTRUINT_T)(p) ^ 01)) +#define Dsd_NotCond(p,c) ((Dsd_Node_t *)((ABC_PTRUINT_T)(p) ^ (c))) //////////////////////////////////////////////////////////////////////// /// ITERATORS /// diff --git a/src/bdd/dsd/dsdCheck.c b/src/bdd/dsd/dsdCheck.c index ce466a71..926237ca 100644 --- a/src/bdd/dsd/dsdCheck.c +++ b/src/bdd/dsd/dsdCheck.c @@ -61,7 +61,7 @@ void Dsd_CheckCacheAllocate( int nEntries ) { int nRequested; - pCache = ALLOC( Dds_Cache_t, 1 ); + pCache = ABC_ALLOC( Dds_Cache_t, 1 ); memset( pCache, 0, sizeof(Dds_Cache_t) ); // check what is the size of the current cache @@ -73,7 +73,7 @@ void Dsd_CheckCacheAllocate( int nEntries ) Dsd_CheckCacheDeallocate(); // allocate memory for the hash table pCache->nTableSize = nRequested; - pCache->pTable = ALLOC( Dsd_Entry_t, nRequested ); + pCache->pTable = ABC_ALLOC( Dsd_Entry_t, nRequested ); } // otherwise, there is no need to allocate, just clean Dsd_CheckCacheClear(); @@ -93,8 +93,8 @@ void Dsd_CheckCacheAllocate( int nEntries ) ******************************************************************************/ void Dsd_CheckCacheDeallocate() { - free( pCache->pTable ); - free( pCache ); + ABC_FREE( pCache->pTable ); + ABC_FREE( pCache ); } /**Function******************************************************************** @@ -183,7 +183,7 @@ int Dsd_CheckRootFunctionIdentity_rec( DdManager * dd, DdNode * bF1, DdNode * bF pCache->pTable[HKey].bX[3] == bC2 ) { pCache->nSuccess++; - return (int)(PORT_PTRUINT_T)pCache->pTable[HKey].bX[4]; // the last bit records the result (yes/no) + return (int)(ABC_PTRUINT_T)pCache->pTable[HKey].bX[4]; // the last bit records the result (yes/no) } else { @@ -302,7 +302,7 @@ int Dsd_CheckRootFunctionIdentity_rec( DdManager * dd, DdNode * bF1, DdNode * bF // set cache for ( i = 0; i < 4; i++ ) pCache->pTable[HKey].bX[i] = bA[i]; - pCache->pTable[HKey].bX[4] = (DdNode*)(PORT_PTRUINT_T)RetValue; + pCache->pTable[HKey].bX[4] = (DdNode*)(ABC_PTRUINT_T)RetValue; return RetValue; } diff --git a/src/bdd/dsd/dsdLocal.c b/src/bdd/dsd/dsdLocal.c index 6dd6e7d1..98b6d7d0 100644 --- a/src/bdd/dsd/dsdLocal.c +++ b/src/bdd/dsd/dsdLocal.c @@ -57,12 +57,12 @@ DdNode * Dsd_TreeGetPrimeFunction( DdManager * dd, Dsd_Node_t * pNode ) DdNode * bFunc, * bRes, * bTemp; st_table * pCache; - pPermute = ALLOC( int, dd->size ); - pVar2Form = ALLOC( int, dd->size ); - pForm2Var = ALLOC( int, dd->size ); + pPermute = ABC_ALLOC( int, dd->size ); + pVar2Form = ABC_ALLOC( int, dd->size ); + pForm2Var = ABC_ALLOC( int, dd->size ); - pbCube0 = ALLOC( DdNode *, dd->size ); - pbCube1 = ALLOC( DdNode *, dd->size ); + pbCube0 = ABC_ALLOC( DdNode *, dd->size ); + pbCube1 = ABC_ALLOC( DdNode *, dd->size ); // remap the global function in such a way that // the support variables of each formal input are adjacent @@ -119,11 +119,11 @@ DdNode * Dsd_TreeGetPrimeFunction( DdManager * dd, Dsd_Node_t * pNode ) Cudd_RecursiveDeref( dd, bTemp ); //////////// */ - FREE(pPermute); - FREE(pVar2Form); - FREE(pForm2Var); - FREE(pbCube0); - FREE(pbCube1); + ABC_FREE(pPermute); + ABC_FREE(pVar2Form); + ABC_FREE(pForm2Var); + ABC_FREE(pbCube0); + ABC_FREE(pbCube1); Cudd_Deref( bRes ); return bRes; diff --git a/src/bdd/dsd/dsdMan.c b/src/bdd/dsd/dsdMan.c index 6e43f0f4..6df6a15e 100644 --- a/src/bdd/dsd/dsdMan.c +++ b/src/bdd/dsd/dsdMan.c @@ -49,15 +49,15 @@ Dsd_Manager_t * Dsd_ManagerStart( DdManager * dd, int nSuppMax, int fVerbose ) assert( nSuppMax <= dd->size ); - dMan = ALLOC( Dsd_Manager_t, 1 ); + dMan = ABC_ALLOC( Dsd_Manager_t, 1 ); memset( dMan, 0, sizeof(Dsd_Manager_t) ); dMan->dd = dd; dMan->nInputs = nSuppMax; dMan->fVerbose = fVerbose; dMan->nRoots = 0; dMan->nRootsAlloc = 50; - dMan->pRoots = (Dsd_Node_t **) malloc( dMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); - dMan->pInputs = (Dsd_Node_t **) malloc( dMan->nInputs * sizeof(Dsd_Node_t *) ); + dMan->pRoots = (Dsd_Node_t **) ABC_ALLOC( char, dMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); + dMan->pInputs = (Dsd_Node_t **) ABC_ALLOC( char, dMan->nInputs * sizeof(Dsd_Node_t *) ); // create the primary inputs and insert them into the table dMan->Table = st_init_table(st_ptrcmp, st_ptrhash); @@ -103,9 +103,9 @@ void Dsd_ManagerStop( Dsd_Manager_t * dMan ) st_foreach_item( dMan->Table, gen, (char**)&bFunc, (char**)&pNode ) Dsd_TreeNodeDelete( dMan->dd, Dsd_Regular(pNode) ); st_free_table(dMan->Table); - free( dMan->pInputs ); - free( dMan->pRoots ); - free( dMan ); + ABC_FREE( dMan->pInputs ); + ABC_FREE( dMan->pRoots ); + ABC_FREE( dMan ); Dsd_CheckCacheDeallocate(); } diff --git a/src/bdd/dsd/dsdProc.c b/src/bdd/dsd/dsdProc.c index 45c0986f..0192346c 100644 --- a/src/bdd/dsd/dsdProc.c +++ b/src/bdd/dsd/dsdProc.c @@ -129,9 +129,9 @@ s_Loops2Useless = 0; if ( pDsdMan->nRootsAlloc < nFuncs ) { if ( pDsdMan->nRootsAlloc > 0 ) - free( pDsdMan->pRoots ); + ABC_FREE( pDsdMan->pRoots ); pDsdMan->nRootsAlloc = nFuncs; - pDsdMan->pRoots = (Dsd_Node_t **) malloc( pDsdMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); + pDsdMan->pRoots = (Dsd_Node_t **) ABC_ALLOC( char, pDsdMan->nRootsAlloc * sizeof(Dsd_Node_t *) ); } if ( pDsdMan->fVerbose ) diff --git a/src/bdd/dsd/dsdTree.c b/src/bdd/dsd/dsdTree.c index 5d69f2f4..a4641afc 100644 --- a/src/bdd/dsd/dsdTree.c +++ b/src/bdd/dsd/dsdTree.c @@ -56,13 +56,13 @@ static int s_GateSizeMax; Dsd_Node_t * Dsd_TreeNodeCreate( int Type, int nDecs, int BlockNum ) { // allocate memory for this node - Dsd_Node_t * p = (Dsd_Node_t *) malloc( sizeof(Dsd_Node_t) ); + 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 if ( p->nDecs ) { - p->pDecs = (Dsd_Node_t **) malloc( p->nDecs * sizeof(Dsd_Node_t *) ); + p->pDecs = (Dsd_Node_t **) ABC_ALLOC( char, p->nDecs * sizeof(Dsd_Node_t *) ); p->pDecs[0] = NULL; } return p; @@ -83,8 +83,8 @@ void Dsd_TreeNodeDelete( DdManager * dd, Dsd_Node_t * pNode ) { if ( pNode->G ) Cudd_RecursiveDeref( dd, pNode->G ); if ( pNode->S ) Cudd_RecursiveDeref( dd, pNode->S ); - FREE( pNode->pDecs ); - FREE( pNode ); + ABC_FREE( pNode->pDecs ); + ABC_FREE( pNode ); } /**Function************************************************************* @@ -555,7 +555,7 @@ Dsd_Node_t ** Dsd_TreeCollectNodesDfs( Dsd_Manager_t * pDsdMan, int * pnNodes ) nNodesAlloc = Dsd_TreeCountNonTerminalNodes(pDsdMan); nNodes = 0; - ppNodes = ALLOC( Dsd_Node_t *, nNodesAlloc ); + ppNodes = ABC_ALLOC( Dsd_Node_t *, nNodesAlloc ); for ( i = 0; i < pDsdMan->nRoots; i++ ) Dsd_TreeCollectNodesDfs_rec( Dsd_Regular(pDsdMan->pRoots[i]), ppNodes, &nNodes ); Dsd_TreeUnmark( pDsdMan ); @@ -583,7 +583,7 @@ Dsd_Node_t ** Dsd_TreeCollectNodesDfsOne( Dsd_Manager_t * pDsdMan, Dsd_Node_t * int nNodes, nNodesAlloc; nNodesAlloc = Dsd_TreeCountNonTerminalNodesOne(pNode); nNodes = 0; - ppNodes = ALLOC( Dsd_Node_t *, nNodesAlloc ); + ppNodes = ABC_ALLOC( Dsd_Node_t *, nNodesAlloc ); Dsd_TreeCollectNodesDfs_rec( Dsd_Regular(pNode), ppNodes, &nNodes ); Dsd_TreeUnmark_rec(Dsd_Regular(pNode)); assert( nNodesAlloc == nNodes ); @@ -682,7 +682,7 @@ void Dsd_TreePrint_rec( FILE * pFile, Dsd_Node_t * pNode, int fComp, char * pInp fprintf( pFile, "%s = ", pOutputName ); else fprintf( pFile, "NOT(%s) = ", pOutputName ); - pInputNums = ALLOC( int, pNode->nDecs ); + pInputNums = ABC_ALLOC( int, pNode->nDecs ); if ( pNode->Type == DSD_NODE_CONST1 ) { fprintf( pFile, " Constant 1.\n" ); @@ -815,7 +815,7 @@ void Dsd_TreePrint_rec( FILE * pFile, Dsd_Node_t * pNode, int fComp, char * pInp Dsd_TreePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, pInputNames, Buffer, nOffset + 6, pSigCounter, fShortNames ); } } - free( pInputNums ); + ABC_FREE( pInputNums ); } /**Function************************************************************* @@ -863,7 +863,7 @@ void Dsd_NodePrint_rec( FILE * pFile, Dsd_Node_t * pNode, int fComp, char * pOut fprintf( pFile, "%s = ", pOutputName ); else fprintf( pFile, "NOT(%s) = ", pOutputName ); - pInputNums = ALLOC( int, pNode->nDecs ); + pInputNums = ABC_ALLOC( int, pNode->nDecs ); if ( pNode->Type == DSD_NODE_CONST1 ) { fprintf( pFile, " Constant 1.\n" ); @@ -984,7 +984,7 @@ void Dsd_NodePrint_rec( FILE * pFile, Dsd_Node_t * pNode, int fComp, char * pOut Dsd_NodePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, Buffer, nOffset + 6, pSigCounter ); } } - free( pInputNums ); + ABC_FREE( pInputNums ); } diff --git a/src/bdd/epd/epd.c b/src/bdd/epd/epd.c index a80240bc..50da97c4 100644 --- a/src/bdd/epd/epd.c +++ b/src/bdd/epd/epd.c @@ -45,7 +45,7 @@ EpdAlloc() { EpDouble *epd; - epd = ALLOC(EpDouble, 1); + epd = ABC_ALLOC(EpDouble, 1); return(epd); } @@ -88,7 +88,7 @@ EpdCmp(const char *key1, const char *key2) void EpdFree(EpDouble *epd) { - FREE(epd); + ABC_FREE(epd); } diff --git a/src/bdd/mtr/mtrBasic.c b/src/bdd/mtr/mtrBasic.c index 94105282..428fa0b1 100644 --- a/src/bdd/mtr/mtrBasic.c +++ b/src/bdd/mtr/mtrBasic.c @@ -92,7 +92,7 @@ Mtr_AllocNode( { MtrNode *node; - node = ALLOC(MtrNode,1); + node = ABC_ALLOC(MtrNode,1); return node; } /* Mtr_AllocNode */ @@ -113,7 +113,7 @@ void Mtr_DeallocNode( MtrNode * node /* node to be deallocated */) { - FREE(node); + ABC_FREE(node); return; } /* end of Mtr_DeallocNode */ diff --git a/src/bdd/parse/parseCore.c b/src/bdd/parse/parseCore.c index 88888379..85200dd9 100644 --- a/src/bdd/parse/parseCore.c +++ b/src/bdd/parse/parseCore.c @@ -156,7 +156,7 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in } // copy the formula - pFormula = ALLOC( char, strlen(pFormulaInit) + 3 ); + pFormula = ABC_ALLOC( char, strlen(pFormulaInit) + 3 ); sprintf( pFormula, "(%s)", pFormulaInit ); // start the stacks @@ -335,7 +335,7 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in if ( Parse_ParserPerformTopOp( dd, pStackFn, Oper ) == NULL ) { fprintf( pOutput, "Parse_FormulaParser(): Unknown operation\n" ); - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } } @@ -382,7 +382,8 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in for ( i = 0; pTemp[i] && pTemp[i] != ' ' && pTemp[i] != '\t' && pTemp[i] != '\r' && pTemp[i] != '\n' && pTemp[i] != PARSE_SYM_AND1 && pTemp[i] != PARSE_SYM_AND2 && pTemp[i] != PARSE_SYM_XOR1 && pTemp[i] != PARSE_SYM_XOR2 && pTemp[i] != PARSE_SYM_XOR3 && pTemp[i] != PARSE_SYM_XOR && - pTemp[i] != PARSE_SYM_OR1 && pTemp[i] != PARSE_SYM_OR2 && pTemp[i] != PARSE_SYM_CLOSE; + pTemp[i] != PARSE_SYM_OR1 && pTemp[i] != PARSE_SYM_OR2 && pTemp[i] != PARSE_SYM_CLOSE && + pTemp[i] != PARSE_SYM_NEGAFT; i++ ) {} for ( v = 0; v < nVars; v++ ) @@ -446,7 +447,7 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in if ( Parse_ParserPerformTopOp( dd, pStackFn, Oper2 ) == NULL ) { fprintf( pOutput, "Parse_FormulaParser(): Unknown operation\n" ); - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } Parse_StackOpPush( pStackOp, Oper1 ); // push the last operation back @@ -471,7 +472,7 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in Parse_StackFnFree(pStackFn); Parse_StackOpFree(pStackOp); Cudd_Deref( bFunc ); - free( pFormula ); + ABC_FREE( pFormula ); return bFunc; } else @@ -482,7 +483,7 @@ DdNode * Parse_FormulaParser( FILE * pOutput, char * pFormulaInit, int nVars, in else fprintf( pOutput, "Parse_FormulaParser(): The input string is empty\n" ); } - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } diff --git a/src/bdd/parse/parseEqn.c b/src/bdd/parse/parseEqn.c index 02d83966..eceecc0c 100644 --- a/src/bdd/parse/parseEqn.c +++ b/src/bdd/parse/parseEqn.c @@ -91,7 +91,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t } // copy the formula - pFormula = ALLOC( char, strlen(pFormInit) + 3 ); + pFormula = ABC_ALLOC( char, strlen(pFormInit) + 3 ); sprintf( pFormula, "(%s)", pFormInit ); // start the stacks @@ -182,7 +182,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t if ( Parse_ParserPerformTopOp( pMan, pStackFn, Oper ) == NULL ) { fprintf( pOutput, "Parse_FormulaParserEqn(): Unknown operation\n" ); - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } } @@ -273,7 +273,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t if ( Parse_ParserPerformTopOp( pMan, pStackFn, Oper2 ) == NULL ) { fprintf( pOutput, "Parse_FormulaParserEqn(): Unknown operation\n" ); - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } Parse_StackOpPush( pStackOp, Oper1 ); // push the last operation back @@ -298,7 +298,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t Parse_StackFnFree(pStackFn); Parse_StackOpFree(pStackOp); // Cudd_Deref( gFunc ); - free( pFormula ); + ABC_FREE( pFormula ); return gFunc; } else @@ -309,7 +309,7 @@ Hop_Obj_t * Parse_FormulaParserEqn( FILE * pOutput, char * pFormInit, Vec_Ptr_t else fprintf( pOutput, "Parse_FormulaParserEqn(): The input string is empty\n" ); } - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } diff --git a/src/bdd/parse/parseStack.c b/src/bdd/parse/parseStack.c index cd7cd7e3..7ce488f1 100644 --- a/src/bdd/parse/parseStack.c +++ b/src/bdd/parse/parseStack.c @@ -54,9 +54,9 @@ struct ParseStackOpStruct Parse_StackFn_t * Parse_StackFnStart( int nDepth ) { Parse_StackFn_t * p; - p = ALLOC( Parse_StackFn_t, 1 ); + p = ABC_ALLOC( Parse_StackFn_t, 1 ); memset( p, 0, sizeof(Parse_StackFn_t) ); - p->pData = ALLOC( void *, nDepth ); + p->pData = ABC_ALLOC( void *, nDepth ); p->Size = nDepth; return p; } @@ -132,8 +132,8 @@ void * Parse_StackFnPop( Parse_StackFn_t * p ) ***********************************************************************/ void Parse_StackFnFree( Parse_StackFn_t * p ) { - FREE( p->pData ); - FREE( p ); + ABC_FREE( p->pData ); + ABC_FREE( p ); } @@ -153,9 +153,9 @@ void Parse_StackFnFree( Parse_StackFn_t * p ) Parse_StackOp_t * Parse_StackOpStart( int nDepth ) { Parse_StackOp_t * p; - p = ALLOC( Parse_StackOp_t, 1 ); + p = ABC_ALLOC( Parse_StackOp_t, 1 ); memset( p, 0, sizeof(Parse_StackOp_t) ); - p->pData = ALLOC( int, nDepth ); + p->pData = ABC_ALLOC( int, nDepth ); p->Size = nDepth; return p; } @@ -231,8 +231,8 @@ int Parse_StackOpPop( Parse_StackOp_t * p ) ***********************************************************************/ void Parse_StackOpFree( Parse_StackOp_t * p ) { - FREE( p->pData ); - FREE( p ); + ABC_FREE( p->pData ); + ABC_FREE( p ); } diff --git a/src/bdd/reo/reo.h b/src/bdd/reo/reo.h index 24e12c32..2f9c421e 100644 --- a/src/bdd/reo/reo.h +++ b/src/bdd/reo/reo.h @@ -19,20 +19,18 @@ #ifndef __REO_H__ #define __REO_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include "extra.h" -//#pragma warning( disable : 4514 ) - //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + // reordering parameters #define REO_REORDER_LIMIT 1.15 // determines the quality/runtime trade-off #define REO_QUAL_PAR 3 // the quality [1 = simple lower bound, 2 = strict, larger = heuristic] @@ -171,9 +169,9 @@ struct _reo_man }; // used to manipulate units -#define Unit_Regular(u) ((reo_unit *)((PORT_PTRUINT_T)(u) & ~01)) -#define Unit_Not(u) ((reo_unit *)((PORT_PTRUINT_T)(u) ^ 01)) -#define Unit_NotCond(u,c) ((reo_unit *)((PORT_PTRUINT_T)(u) ^ (c))) +#define Unit_Regular(u) ((reo_unit *)((ABC_PTRUINT_T)(u) & ~01)) +#define Unit_Not(u) ((reo_unit *)((ABC_PTRUINT_T)(u) ^ 01)) +#define Unit_NotCond(u,c) ((reo_unit *)((ABC_PTRUINT_T)(u) ^ (c))) #define Unit_IsConstant(u) ((int)((u)->lev == REO_CONST_LEVEL)) //////////////////////////////////////////////////////////////////////// diff --git a/src/bdd/reo/reoApi.c b/src/bdd/reo/reoApi.c index e833dabd..000489ed 100644 --- a/src/bdd/reo/reoApi.c +++ b/src/bdd/reo/reoApi.c @@ -48,7 +48,7 @@ reo_man * Extra_ReorderInit( int nDdVarsMax, int nNodesMax ) { reo_man * p; // allocate and clean the data structure - p = ALLOC( reo_man, 1 ); + p = ABC_ALLOC( reo_man, 1 ); memset( p, 0, sizeof(reo_man) ); // resize the manager to meet user's needs reoResizeStructures( p, nDdVarsMax, nNodesMax, 100 ); @@ -75,21 +75,21 @@ reo_man * Extra_ReorderInit( int nDdVarsMax, int nNodesMax ) ***********************************************************************/ void Extra_ReorderQuit( reo_man * p ) { - free( p->pTops ); - free( p->pSupp ); - free( p->pOrderInt ); - free( p->pWidthCofs ); - free( p->pMapToPlanes ); - free( p->pMapToDdVarsOrig ); - free( p->pMapToDdVarsFinal ); - free( p->pPlanes ); - free( p->pVarCosts ); - free( p->pLevelOrder ); - free( p->HTable ); - free( p->pRefNodes ); + ABC_FREE( p->pTops ); + ABC_FREE( p->pSupp ); + ABC_FREE( p->pOrderInt ); + ABC_FREE( p->pWidthCofs ); + ABC_FREE( p->pMapToPlanes ); + ABC_FREE( p->pMapToDdVarsOrig ); + ABC_FREE( p->pMapToDdVarsFinal ); + ABC_FREE( p->pPlanes ); + ABC_FREE( p->pVarCosts ); + ABC_FREE( p->pLevelOrder ); + ABC_FREE( p->HTable ); + ABC_FREE( p->pRefNodes ); reoUnitsStopDispenser( p ); - free( p->pMemChunks ); - free( p ); + ABC_FREE( p->pMemChunks ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/bdd/reo/reoCore.c b/src/bdd/reo/reoCore.c index 3782631c..a37bae13 100644 --- a/src/bdd/reo/reoCore.c +++ b/src/bdd/reo/reoCore.c @@ -22,8 +22,6 @@ /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -#define CALLOC(type, num) ((type *) calloc((long)(num), (long)sizeof(type))) - static int reoRecursiveDeref( reo_unit * pUnit ); static int reoCheckZeroRefs( reo_plane * pPlane ); static int reoCheckLevels( reo_man * p ); @@ -217,7 +215,7 @@ s_AplAfter = p->nAplEnd; if ( p->pOrder == NULL ) { - pOrder = ALLOC( int, p->nSupp ); + pOrder = ABC_ALLOC( int, p->nSupp ); for ( i = 0; i < p->nSupp; i++ ) pOrder[ p->pMapToDdVarsFinal[i] ] = p->pMapToDdVarsOrig[ p->pOrderInt[i] ]; } @@ -246,7 +244,7 @@ s_AplAfter = p->nAplEnd; printf( "REO: Internal verification is okay!\n" ); if ( p->pOrder == NULL ) - free( pOrder ); + ABC_FREE( pOrder ); } // recycle the data structure @@ -270,35 +268,35 @@ void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs // resize data structures depending on the number of variables in the DD manager if ( p->nSuppAlloc == 0 ) { - p->pSupp = ALLOC( int, nDdVarsMax + 1 ); - p->pOrderInt = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToPlanes = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsOrig = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsFinal = ALLOC( int, nDdVarsMax + 1 ); - p->pPlanes = CALLOC( reo_plane, nDdVarsMax + 1 ); - p->pVarCosts = ALLOC( double, nDdVarsMax + 1 ); - p->pLevelOrder = ALLOC( int, nDdVarsMax + 1 ); + p->pSupp = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pOrderInt = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToPlanes = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsOrig = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsFinal = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pPlanes = ABC_CALLOC( reo_plane, nDdVarsMax + 1 ); + p->pVarCosts = ABC_ALLOC( double, nDdVarsMax + 1 ); + p->pLevelOrder = ABC_ALLOC( int, nDdVarsMax + 1 ); p->nSuppAlloc = nDdVarsMax + 1; } else if ( p->nSuppAlloc < nDdVarsMax ) { - free( p->pSupp ); - free( p->pOrderInt ); - free( p->pMapToPlanes ); - free( p->pMapToDdVarsOrig ); - free( p->pMapToDdVarsFinal ); - free( p->pPlanes ); - free( p->pVarCosts ); - free( p->pLevelOrder ); - - p->pSupp = ALLOC( int, nDdVarsMax + 1 ); - p->pOrderInt = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToPlanes = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsOrig = ALLOC( int, nDdVarsMax + 1 ); - p->pMapToDdVarsFinal = ALLOC( int, nDdVarsMax + 1 ); - p->pPlanes = CALLOC( reo_plane, nDdVarsMax + 1 ); - p->pVarCosts = ALLOC( double, nDdVarsMax + 1 ); - p->pLevelOrder = ALLOC( int, nDdVarsMax + 1 ); + ABC_FREE( p->pSupp ); + ABC_FREE( p->pOrderInt ); + ABC_FREE( p->pMapToPlanes ); + ABC_FREE( p->pMapToDdVarsOrig ); + ABC_FREE( p->pMapToDdVarsFinal ); + ABC_FREE( p->pPlanes ); + ABC_FREE( p->pVarCosts ); + ABC_FREE( p->pLevelOrder ); + + p->pSupp = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pOrderInt = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToPlanes = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsOrig = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pMapToDdVarsFinal = ABC_ALLOC( int, nDdVarsMax + 1 ); + p->pPlanes = ABC_CALLOC( reo_plane, nDdVarsMax + 1 ); + p->pVarCosts = ABC_ALLOC( double, nDdVarsMax + 1 ); + p->pLevelOrder = ABC_ALLOC( int, nDdVarsMax + 1 ); p->nSuppAlloc = nDdVarsMax + 1; } @@ -310,10 +308,10 @@ void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs p->nRefNodesAlloc = 3*nNodesMax + 1; p->nMemChunksAlloc = (10*nNodesMax + 1)/REO_CHUNK_SIZE + 1; - p->HTable = CALLOC( reo_hash, p->nTableSize ); - p->pRefNodes = ALLOC( DdNode *, p->nRefNodesAlloc ); - p->pWidthCofs = ALLOC( reo_unit *, p->nRefNodesAlloc ); - p->pMemChunks = ALLOC( reo_unit *, p->nMemChunksAlloc ); + p->HTable = ABC_CALLOC( reo_hash, p->nTableSize ); + p->pRefNodes = ABC_ALLOC( DdNode *, p->nRefNodesAlloc ); + p->pWidthCofs = ABC_ALLOC( reo_unit *, p->nRefNodesAlloc ); + p->pMemChunks = ABC_ALLOC( reo_unit *, p->nMemChunksAlloc ); } else if ( p->nNodesMaxAlloc < nNodesMax ) { @@ -325,29 +323,29 @@ void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs p->nRefNodesAlloc = 3*nNodesMax + 1; p->nMemChunksAlloc = (10*nNodesMax + 1)/REO_CHUNK_SIZE + 1; - free( p->HTable ); - free( p->pRefNodes ); - free( p->pWidthCofs ); - p->HTable = CALLOC( reo_hash, p->nTableSize ); - p->pRefNodes = ALLOC( DdNode *, p->nRefNodesAlloc ); - p->pWidthCofs = ALLOC( reo_unit *, p->nRefNodesAlloc ); + ABC_FREE( p->HTable ); + ABC_FREE( p->pRefNodes ); + ABC_FREE( p->pWidthCofs ); + p->HTable = ABC_CALLOC( reo_hash, p->nTableSize ); + p->pRefNodes = ABC_ALLOC( DdNode *, p->nRefNodesAlloc ); + p->pWidthCofs = ABC_ALLOC( reo_unit *, p->nRefNodesAlloc ); // p->pMemChunks should be reallocated because it contains pointers currently in use - pTemp = ALLOC( reo_unit *, p->nMemChunksAlloc ); + pTemp = ABC_ALLOC( reo_unit *, p->nMemChunksAlloc ); memmove( pTemp, p->pMemChunks, sizeof(reo_unit *) * nMemChunksAllocPrev ); - free( p->pMemChunks ); + ABC_FREE( p->pMemChunks ); p->pMemChunks = pTemp; } // resize the data structures depending on the number of functions if ( p->nTopsAlloc == 0 ) { - p->pTops = ALLOC( reo_unit *, nFuncs ); + p->pTops = ABC_ALLOC( reo_unit *, nFuncs ); p->nTopsAlloc = nFuncs; } else if ( p->nTopsAlloc < nFuncs ) { - free( p->pTops ); - p->pTops = ALLOC( reo_unit *, nFuncs ); + ABC_FREE( p->pTops ); + p->pTops = ABC_ALLOC( reo_unit *, nFuncs ); p->nTopsAlloc = nFuncs; } } diff --git a/src/bdd/reo/reoProfile.c b/src/bdd/reo/reoProfile.c index 84a0bc19..8a48d809 100644 --- a/src/bdd/reo/reoProfile.c +++ b/src/bdd/reo/reoProfile.c @@ -132,8 +132,8 @@ void reoProfileWidthStart( reo_man * p ) int v; // allocate and clean the storage for starting and stopping levels - pWidthStart = ALLOC( int, p->nSupp + 1 ); - pWidthStop = ALLOC( int, p->nSupp + 1 ); + pWidthStart = ABC_ALLOC( int, p->nSupp + 1 ); + pWidthStop = ABC_ALLOC( int, p->nSupp + 1 ); memset( pWidthStart, 0, sizeof(int) * (p->nSupp + 1) ); memset( pWidthStop, 0, sizeof(int) * (p->nSupp + 1) ); @@ -200,8 +200,8 @@ void reoProfileWidthStart( reo_man * p ) // printf( "Level %2d: Width = %5d. Correct = %d.\n", v, Temp, p->pPlanes[v].statsWidth ); } p->nWidthBeg = p->nWidthCur; - free( pWidthStart ); - free( pWidthStop ); + ABC_FREE( pWidthStart ); + ABC_FREE( pWidthStop ); } /**Function******************************************************************** diff --git a/src/bdd/reo/reoSwap.c b/src/bdd/reo/reoSwap.c index d3a9c7a5..0e829407 100644 --- a/src/bdd/reo/reoSwap.c +++ b/src/bdd/reo/reoSwap.c @@ -233,7 +233,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, free other nodes + // and move them to the new uppoer level, ABC_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 +759,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, free other nodes + // and move them to the new uppoer level, ABC_FREE other nodes for ( pLoop = pListOld1; pLoop; ) { pUnit = pLoop; diff --git a/src/bdd/reo/reoTest.c b/src/bdd/reo/reoTest.c index 82f3d5f5..f0e70cf9 100644 --- a/src/bdd/reo/reoTest.c +++ b/src/bdd/reo/reoTest.c @@ -115,9 +115,9 @@ DdNode * Extra_ReorderCudd( DdManager * dd, DdNode * aFunc, int pPermuteReo[] ) // start the reordering manager if ( ddReorder == NULL ) { - Permute = ALLOC( int, dd->size ); - PermuteReo1 = ALLOC( int, dd->size ); - PermuteReo2 = ALLOC( int, dd->size ); + Permute = ABC_ALLOC( int, dd->size ); + PermuteReo1 = ABC_ALLOC( int, dd->size ); + PermuteReo2 = ABC_ALLOC( int, dd->size ); ddReorder = Cudd_Init( dd->size, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); Cudd_AutodynDisable(ddReorder); } diff --git a/src/bdd/reo/reoTransfer.c b/src/bdd/reo/reoTransfer.c index 26a6689e..ec02ac0c 100644 --- a/src/bdd/reo/reoTransfer.c +++ b/src/bdd/reo/reoTransfer.c @@ -69,7 +69,7 @@ reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F ) if ( cuddIsConstant(F) ) { pUnit->lev = REO_CONST_LEVEL; - pUnit->pE = (reo_unit*)((int)(PORT_PTRUINT_T)(cuddV(F))); + pUnit->pE = (reo_unit*)((int)(ABC_PTRUINT_T)(cuddV(F))); pUnit->pT = NULL; // check if the diagram that is being reordering has complement edges if ( F != dd->one ) @@ -89,7 +89,7 @@ reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F ) // add to the hash table if ( F->ref != 1 ) { - // the next free entry is already found - it is pointed to by HKey + // the next ABC_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 ); @@ -139,7 +139,7 @@ DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit ) // treat the case of constants if ( Unit_IsConstant(pUnit) ) { - bRes = cuddUniqueConst( dd, ((double)((int)(PORT_PTRUINT_T)(pUnit->pE))) ); + bRes = cuddUniqueConst( dd, ((double)((int)(ABC_PTRUINT_T)(pUnit->pE))) ); cuddRef( bRes ); } else diff --git a/src/bdd/reo/reoUnits.c b/src/bdd/reo/reoUnits.c index 52137027..f8bca7ad 100644 --- a/src/bdd/reo/reoUnits.c +++ b/src/bdd/reo/reoUnits.c @@ -30,7 +30,7 @@ static void reoUnitsAddToFreeUnitList( reo_man * p ); /**Function************************************************************* - Synopsis [Extract the next unit from the free unit list.] + Synopsis [Extract the next unit from the ABC_FREE unit list.] Description [] @@ -54,7 +54,7 @@ reo_unit * reoUnitsGetNextUnit(reo_man * p ) /**Function************************************************************* - Synopsis [Returns the unit to the free unit list.] + Synopsis [Returns the unit to the ABC_FREE unit list.] Description [] @@ -72,7 +72,7 @@ void reoUnitsRecycleUnit( reo_man * p, reo_unit * pUnit ) /**Function************************************************************* - Synopsis [Returns the list of units to the free unit list.] + Synopsis [Returns the list of units to the ABC_FREE unit list.] Description [] @@ -112,7 +112,7 @@ void reoUnitsStopDispenser( reo_man * p ) { int i; for ( i = 0; i < p->nMemChunks; i++ ) - free( p->pMemChunks[i] ); + ABC_FREE( p->pMemChunks[i] ); // printf("\nThe number of chunks used is %d, each of them %d units\n", p->nMemChunks, REO_CHUNK_SIZE ); p->nMemChunks = 0; } @@ -167,7 +167,7 @@ void reoUnitsAddToFreeUnitList( reo_man * p ) } // allocate the next chunk assert( p->pUnitFreeList == NULL ); - p->pUnitFreeList = ALLOC( reo_unit, REO_CHUNK_SIZE ); + p->pUnitFreeList = ABC_ALLOC( reo_unit, REO_CHUNK_SIZE ); // split chunks into list-connected units for ( c = 0; c < REO_CHUNK_SIZE-1; c++ ) (p->pUnitFreeList + c)->Next = p->pUnitFreeList + c + 1; diff --git a/src/demo.c b/src/demo.c new file mode 100644 index 00000000..de162409 --- /dev/null +++ b/src/demo.c @@ -0,0 +1,181 @@ +/**CFile**************************************************************** + + FileName [demo.c] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [ABC as a static library.] + + Synopsis [A demo program illustrating the use of ABC as a static library.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: demo.c,v 1.00 2005/11/14 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include +#include + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +// procedures to start and stop the ABC framework +// (should be called before and after the ABC procedures are called) +extern void Abc_Start(); +extern void Abc_Stop(); + +// procedures to get the ABC framework and execute commands in it +extern void * Abc_FrameGetGlobalFrame(); +extern int Cmd_CommandExecute( void * pAbc, char * sCommand ); + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [The main() procedure.] + + Description [This procedure compiles into a stand-alone program for + DAG-aware rewriting of the AIGs. A BLIF or PLA file to be considered + for rewriting should be given as a command-line argument. Implementation + of the rewriting is inspired by the paper: Per Bjesse, Arne Boralv, + "DAG-aware circuit compression for formal verification", Proc. ICCAD 2004.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int main( int argc, char * argv[] ) +{ + // parameters + int fUseResyn2 = 0; + int fPrintStats = 1; + int fVerify = 1; + // variables + void * pAbc; + char * pFileName; + char Command[1000]; + int clkRead, clkResyn, clkVer, clk; + + ////////////////////////////////////////////////////////////////////////// + // get the input file name + if ( argc != 2 ) + { + printf( "Wrong number of command-line arguments.\n" ); + return 1; + } + pFileName = argv[1]; + + ////////////////////////////////////////////////////////////////////////// + // start the ABC framework + Abc_Start(); + pAbc = Abc_FrameGetGlobalFrame(); + +clk = clock(); + ////////////////////////////////////////////////////////////////////////// + // read the file + sprintf( Command, "read %s", pFileName ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } + + ////////////////////////////////////////////////////////////////////////// + // balance + sprintf( Command, "balance" ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } +clkRead = clock() - clk; + + ////////////////////////////////////////////////////////////////////////// + // print stats + if ( fPrintStats ) + { + sprintf( Command, "print_stats" ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } + } + +clk = clock(); + ////////////////////////////////////////////////////////////////////////// + // synthesize + if ( fUseResyn2 ) + { + sprintf( Command, "balance; rewrite -l; refactor -l; balance; rewrite -l; rewrite -lz; balance; refactor -lz; rewrite -lz; balance" ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } + } + else + { + sprintf( Command, "balance; rewrite -l; rewrite -lz; balance; rewrite -lz; balance" ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } + } +clkResyn = clock() - clk; + + ////////////////////////////////////////////////////////////////////////// + // print stats + if ( fPrintStats ) + { + sprintf( Command, "print_stats" ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } + } + + ////////////////////////////////////////////////////////////////////////// + // write the result in blif + sprintf( Command, "write_blif result.blif" ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } + + ////////////////////////////////////////////////////////////////////////// + // perform verification +clk = clock(); + if ( fVerify ) + { + sprintf( Command, "cec %s result.blif", pFileName ); + if ( Cmd_CommandExecute( pAbc, Command ) ) + { + fprintf( stdout, "Cannot execute command \"%s\".\n", Command ); + return 1; + } + } +clkVer = clock() - clk; + + printf( "Reading = %6.2f sec ", (float)(clkRead)/(float)(CLOCKS_PER_SEC) ); + printf( "Rewriting = %6.2f sec ", (float)(clkResyn)/(float)(CLOCKS_PER_SEC) ); + printf( "Verification = %6.2f sec\n", (float)(clkVer)/(float)(CLOCKS_PER_SEC) ); + + ////////////////////////////////////////////////////////////////////////// + // stop the ABC framework + Abc_Stop(); + return 0; +} + diff --git a/src/generic.h b/src/generic.h index e17d2edf..fcc4cf26 100644 --- a/src/generic.h +++ b/src/generic.h @@ -21,10 +21,6 @@ #ifndef __zzz_H__ #define __zzz_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/map/amap/amap.h b/src/map/amap/amap.h index ee845e7f..284af309 100644 --- a/src/map/amap/amap.h +++ b/src/map/amap/amap.h @@ -21,10 +21,6 @@ #ifndef __AMAP_H__ #define __AMAP_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -45,7 +45,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 free (area = 0) + int fFreeInvs; // assume inverters are ABC_FREE (area = 0) float fEpsilon; // used to compare floating point numbers int fVerbose; // verbosity flag }; @@ -69,7 +69,10 @@ struct Amap_Out_t_ /*=== amapCore.c ==========================================================*/ extern void Amap_ManSetDefaultParams( Amap_Par_t * pPars ); -extern Vec_Ptr_t * Amap_ManTest( Aig_Man_t * pAig, Amap_Par_t * pPars ); +//extern Vec_Ptr_t * Amap_ManTest( Aig_Man_t * pAig, Amap_Par_t * pPars ); +/*=== amapLiberty.c ==========================================================*/ +extern int Amap_LibertyParse( char * pFileName, char * pFileGenlib, int fVerbose ); + #ifdef __cplusplus } diff --git a/src/map/amap/amapCore.c b/src/map/amap/amapCore.c index f1554862..7dedc067 100644 --- a/src/map/amap/amapCore.c +++ b/src/map/amap/amapCore.c @@ -46,7 +46,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 free (area = 0) + p->fFreeInvs = 0; // assume inverters are ABC_FREE (area = 0) p->fEpsilon = (float)0.001; // used to compare floating point numbers p->fVerbose = 0; // verbosity flag } @@ -81,8 +81,8 @@ Vec_Ptr_t * Amap_ManTest( Aig_Man_t * pAig, Amap_Par_t * pPars ) p->fAreaInv = pPars->fFreeInvs? 0.0 : pLib->pGateInv->dArea; p->fUseMux = pPars->fUseMuxes && pLib->fHasMux; p->fUseXor = pPars->fUseXors && pLib->fHasXor; - p->ppCutsTemp = CALLOC( Amap_Cut_t *, 2 * pLib->nNodes ); - p->pMatsTemp = CALLOC( int, 2 * pLib->nNodes ); + p->ppCutsTemp = ABC_CALLOC( Amap_Cut_t *, 2 * pLib->nNodes ); + p->pMatsTemp = ABC_CALLOC( int, 2 * pLib->nNodes ); Amap_ManCreate( p, pAig ); Amap_ManMap( p ); vRes = NULL; @@ -90,7 +90,7 @@ Vec_Ptr_t * Amap_ManTest( Aig_Man_t * pAig, Amap_Par_t * pPars ) Amap_ManStop( p ); if ( pPars->fVerbose ) { -PRT( "Total runtime", clock() - clkTotal ); +ABC_PRT( "Total runtime", clock() - clkTotal ); } return vRes; } diff --git a/src/map/amap/amapInt.h b/src/map/amap/amapInt.h index 954790c9..dec7e799 100644 --- a/src/map/amap/amapInt.h +++ b/src/map/amap/amapInt.h @@ -21,10 +21,6 @@ #ifndef __AMAP_INT_H__ #define __AMAP_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -36,6 +32,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + // the largest gate size in the library // (gates above this size will be ignored) #define AMAP_MAXINS 15 @@ -222,10 +222,10 @@ static inline int Amap_LitNot( int Lit ) { return Lit ^ 1 static inline int Amap_LitNotCond( int Lit, int c ) { return Lit ^ (int)(c > 0); } static inline int Amap_LitRegular( int Lit ) { return Lit & ~01; } -static inline Amap_Obj_t * Amap_Regular( Amap_Obj_t * p ) { return (Amap_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); } -static inline Amap_Obj_t * Amap_Not( Amap_Obj_t * p ) { return (Amap_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); } -static inline Amap_Obj_t * Amap_NotCond( Amap_Obj_t * p, int c ) { return (Amap_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); } -static inline int Amap_IsComplement( Amap_Obj_t * p ) { return (int )(((PORT_PTRUINT_T)p) & 01); } +static inline Amap_Obj_t * Amap_Regular( Amap_Obj_t * p ) { return (Amap_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); } +static inline Amap_Obj_t * Amap_Not( Amap_Obj_t * p ) { return (Amap_Obj_t *)((ABC_PTRUINT_T)(p) ^ 01); } +static inline Amap_Obj_t * Amap_NotCond( Amap_Obj_t * p, int c ) { return (Amap_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); } +static inline int Amap_IsComplement( Amap_Obj_t * p ) { return (int )(((ABC_PTRUINT_T)p) & 01); } static inline int Amap_ManPiNum( Amap_Man_t * p ) { return p->nObjs[AMAP_OBJ_PI]; } static inline int Amap_ManPoNum( Amap_Man_t * p ) { return p->nObjs[AMAP_OBJ_PO]; } diff --git a/src/map/amap/amapLib.c b/src/map/amap/amapLib.c index 816f0703..f2e5113f 100644 --- a/src/map/amap/amapLib.c +++ b/src/map/amap/amapLib.c @@ -42,7 +42,7 @@ Amap_Lib_t * Amap_LibAlloc() { Amap_Lib_t * p; - p = (Amap_Lib_t *)ALLOC( Amap_Lib_t, 1 ); + p = (Amap_Lib_t *)ABC_ALLOC( Amap_Lib_t, 1 ); memset( p, 0, sizeof(Amap_Lib_t) ); p->vGates = Vec_PtrAlloc( 100 ); p->pMemGates = Aig_MmFlexStart(); @@ -79,10 +79,10 @@ void Amap_LibFree( Amap_Lib_t * p ) Vec_IntFree( p->vRules3 ); Aig_MmFlexStop( p->pMemGates, 0 ); Aig_MmFlexStop( p->pMemSet, 0 ); - FREE( p->pRules ); - FREE( p->pRulesX ); - FREE( p->pNodes ); - free( p ); + ABC_FREE( p->pRules ); + ABC_FREE( p->pRulesX ); + ABC_FREE( p->pNodes ); + ABC_FREE( p ); } /**Function************************************************************* @@ -341,7 +341,7 @@ Amap_Lib_t * Amap_LibReadAndPrepare( char * pFileName, int fVerbose, int fVeryVe { printf( "Selected %d functionally unique gates. ", Vec_PtrSize(p->vSelect), Vec_PtrSize(p->vSorted) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } clk = clock(); Amap_LibCreateRules( p, fVeryVerbose ); @@ -349,7 +349,7 @@ Amap_Lib_t * Amap_LibReadAndPrepare( char * pFileName, int fVerbose, int fVeryVe { printf( "Created %d rules and %d matches. ", p->nNodes, p->nSets ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } return p; } diff --git a/src/map/amap/amapLiberty.c b/src/map/amap/amapLiberty.c new file mode 100644 index 00000000..7f46ffdf --- /dev/null +++ b/src/map/amap/amapLiberty.c @@ -0,0 +1,911 @@ +/**CFile**************************************************************** + + FileHead [amapLiberty.c] + + SystemHead [ABC: Logic synthesis and verification system.] + + PackageHead [Technology mapper for standard cells.] + + Synopsis [Liberty parser.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - June 20, 2005.] + + Revision [$Id: amapLiberty.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#include "amapInt.h" + +//////////////////////////////////////////////////////////////////////// +/// DECLARATIONS /// +//////////////////////////////////////////////////////////////////////// + +// entry types +typedef enum { + AMAP_LIBERTY_NONE = 0, // 0: unknown + AMAP_LIBERTY_PROC, // 1: procedure : key(head){body} + AMAP_LIBERTY_EQUA, // 2: equation : key:head; + AMAP_LIBERTY_LIST // 3: list : key(head) +} Amap_LibertyType_t; + +typedef struct Amap_Pair_t_ Amap_Pair_t; +struct Amap_Pair_t_ +{ + int Beg; // item beginning + int End; // item end +}; + +typedef struct Amap_Item_t_ Amap_Item_t; +struct Amap_Item_t_ +{ + int Type; // Amap_LibertyType_t + int iLine; // file line where the item's spec begins + Amap_Pair_t Key; // key part + Amap_Pair_t Head; // head part + Amap_Pair_t Body; // body part + int Next; // next item in the list + int Child; // first child item +}; + +typedef struct Amap_Tree_t_ Amap_Tree_t; +struct Amap_Tree_t_ +{ + char * pFileName; // input Liberty file name + char * pContents; // file contents + int nContents; // file size + int nLines; // line counter + int nItems; // number of items + int nItermAlloc; // number of items allocated + Amap_Item_t * pItems; // the items + char * pError; // the error string +}; + +static inline Amap_Item_t * Amap_LibertyRoot( Amap_Tree_t * p ) { return p->pItems; } +static inline Amap_Item_t * Amap_LibertyItem( Amap_Tree_t * p, int v ) { assert( v < p->nItems ); return v < 0 ? NULL : p->pItems + v; } +static inline int Amap_LibertyCompare( Amap_Tree_t * p, Amap_Pair_t Pair, char * pStr ) { return strncmp( p->pContents+Pair.Beg, pStr, Pair.End-Pair.Beg ); } +static inline void Amap_PrintWord( FILE * pFile, Amap_Tree_t * p, Amap_Pair_t Pair ) { char * pBeg = p->pContents+Pair.Beg, * pEnd = p->pContents+Pair.End; while ( pBeg < pEnd ) fputc( *pBeg++, pFile ); } +static inline void Amap_PrintSpace( FILE * pFile, int nOffset ) { int i; for ( i = 0; i < nOffset; i++ ) fputc(' ', pFile); } +static inline int Amap_LibertyItemId( Amap_Tree_t * p, Amap_Item_t * pItem ) { return pItem - p->pItems; } + +#define Amap_ItemForEachChild( p, pItem, pChild ) \ + for ( pChild = Amap_LibertyItem(p, pItem->Child); pChild; pChild = Amap_LibertyItem(p, pChild->Next) ) + +//////////////////////////////////////////////////////////////////////// +/// FUNCTION DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + +/**Function************************************************************* + + Synopsis [Prints parse tree in Liberty format.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Amap_LibertyPrintLibertyItem( FILE * pFile, Amap_Tree_t * p, Amap_Item_t * pItem, int nOffset ) +{ + if ( pItem->Type == AMAP_LIBERTY_PROC ) + { + Amap_PrintSpace( pFile, nOffset ); + Amap_PrintWord( pFile, p, pItem->Key ); + fprintf( pFile, "(" ); + Amap_PrintWord( pFile, p, pItem->Head ); + fprintf( pFile, ") {\n" ); + if ( Amap_LibertyItem(p, pItem->Child) ) + Amap_LibertyPrintLibertyItem( pFile, p, Amap_LibertyItem(p, pItem->Child), nOffset + 1 ); + Amap_PrintSpace( pFile, nOffset ); + fprintf( pFile, "}\n" ); + } + else if ( pItem->Type == AMAP_LIBERTY_EQUA ) + { + Amap_PrintSpace( pFile, nOffset ); + Amap_PrintWord( pFile, p, pItem->Key ); + fprintf( pFile, " : " ); + Amap_PrintWord( pFile, p, pItem->Head ); + fprintf( pFile, ";\n" ); + } + else if ( pItem->Type == AMAP_LIBERTY_LIST ) + { + Amap_PrintSpace( pFile, nOffset ); + Amap_PrintWord( pFile, p, pItem->Key ); + fprintf( pFile, "(" ); + Amap_PrintWord( pFile, p, pItem->Head ); + fprintf( pFile, ");\n" ); + } + else assert( 0 ); + if ( Amap_LibertyItem(p, pItem->Next) ) + Amap_LibertyPrintLibertyItem( pFile, p, Amap_LibertyItem(p, pItem->Next), nOffset ); +} + +/**Function************************************************************* + + Synopsis [Prints parse tree in Liberty format.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyPrintLiberty( Amap_Tree_t * p, char * pFileName ) +{ + FILE * pFile; + if ( pFileName == NULL ) + pFile = stdout; + else + { + pFile = fopen( pFileName, "w" ); + if ( pFile == NULL ) + { + printf( "Amap_LibertyPrintLiberty(): The output file is unavailable (absent or open).\n" ); + return 0; + } + } + Amap_LibertyPrintLibertyItem( pFile, p, Amap_LibertyRoot(p), 0 ); + if ( pFile != stdout ) + fclose( pFile ); + return 1; +} + + +/**Function************************************************************* + + Synopsis [Returns the time stamp.] + + Description [The file should be closed.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +char * Amap_LibertyTimeStamp() +{ + static char Buffer[100]; + char * TimeStamp; + time_t ltime; + // get the current time + time( <ime ); + TimeStamp = asctime( localtime( <ime ) ); + TimeStamp[ strlen(TimeStamp) - 1 ] = 0; + strcpy( Buffer, TimeStamp ); + return Buffer; +} + +/**Function************************************************************* + + Synopsis [Returns cell's function.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyCellIsFlop( Amap_Tree_t * p, Amap_Item_t * pCell ) +{ + Amap_Item_t * pAttr; + Amap_ItemForEachChild( p, pCell, pAttr ) + if ( !Amap_LibertyCompare(p, pAttr->Key, "ff") || + !Amap_LibertyCompare(p, pAttr->Key, "latch") ) + return 1; + return 0; +} + +/**Function************************************************************* + + Synopsis [Returns pin's function.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Amap_Item_t * Amap_LibertyPinFunction( Amap_Tree_t * p, Amap_Item_t * pPin ) +{ + Amap_Item_t * pFunc; + Amap_ItemForEachChild( p, pPin, pFunc ) + if ( !Amap_LibertyCompare(p, pFunc->Key, "function") ) + return pFunc; + return NULL; +} + +/**Function************************************************************* + + Synopsis [Returns cell's function.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Amap_Item_t * Amap_LibertyCellOutput( Amap_Tree_t * p, Amap_Item_t * pCell ) +{ + Amap_Item_t * pPin; + Amap_ItemForEachChild( p, pCell, pPin ) + { + if ( Amap_LibertyCompare(p, pPin->Key, "pin") ) + continue; + if ( Amap_LibertyPinFunction(p, pPin) ) + return pPin; + } + return NULL; +} + +/**Function************************************************************* + + Synopsis [Returns cell's area.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Amap_Item_t * Amap_LibertyCellArea( Amap_Tree_t * p, Amap_Item_t * pCell ) +{ + Amap_Item_t * pArea; + Amap_ItemForEachChild( p, pCell, pArea ) + { + if ( Amap_LibertyCompare(p, pArea->Key, "area") ) + continue; + return pArea; + } + return NULL; +} + +/**Function************************************************************* + + Synopsis [Count cell's output pins (pins with a logic function).] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyCellCountOutputs( Amap_Tree_t * p, Amap_Item_t * pCell ) +{ + Amap_Item_t * pPin; + int Counter = 0; + Amap_ItemForEachChild( p, pCell, pPin ) + { + if ( Amap_LibertyCompare(p, pPin->Key, "pin") ) + continue; + if ( Amap_LibertyPinFunction(p, pPin) ) + Counter++; + } + return Counter; +} + +/**Function************************************************************* + + Synopsis [Gets the name to write.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +char * Amap_LibertyGetString( Amap_Tree_t * p, Amap_Pair_t Pair ) +{ + static char Buffer[256]; + strncpy( Buffer, p->pContents+Pair.Beg, Pair.End-Pair.Beg ); + Buffer[Pair.End-Pair.Beg] = 0; + return Buffer; +} + +/**Function************************************************************* + + Synopsis [Gets the name to write.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +char * Amap_LibertyGetStringFormula( Amap_Tree_t * p, Amap_Pair_t Pair ) +{ + static char Buffer[256]; + strncpy( Buffer, p->pContents+Pair.Beg+1, Pair.End-Pair.Beg-2 ); + Buffer[Pair.End-Pair.Beg-2] = 0; + return Buffer; +} + +/**Function************************************************************* + + Synopsis [Prints parse tree in Genlib format.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName ) +{ + FILE * pFile; + Amap_Item_t * pCell, * pArea, * pFunc, * pPin, * pOutput; + int Counter; + if ( pFileName == NULL ) + pFile = stdout; + else + { + pFile = fopen( pFileName, "w" ); + if ( pFile == NULL ) + { + printf( "Amap_LibertyPrintGenlib(): The output file is unavailable (absent or open).\n" ); + return 0; + } + } + fprintf( pFile, "# This Genlib file was generated by ABC on %s\n", Amap_LibertyTimeStamp() ); + fprintf( pFile, "# The standard cell library \"%s\" is from Liberty file \"%s\"\n", Amap_LibertyGetString(p, Amap_LibertyRoot(p)->Head), p->pFileName ); + fprintf( pFile, "# (To find out more about Genlib format, google for \"sis_paper.ps\")\n" ); + + fprintf( pFile, "GATE " ); + fprintf( pFile, "%16s ", "_const0_" ); + fprintf( pFile, "%f ", 0.0 ); + fprintf( pFile, "%s=", "z" ); + fprintf( pFile, "%s;\n", "CONST0" ); + + fprintf( pFile, "GATE " ); + fprintf( pFile, "%16s ", "_const1_" ); + fprintf( pFile, "%f ", 0.0 ); + fprintf( pFile, "%s=", "z" ); + fprintf( pFile, "%s;\n", "CONST1" ); + + Amap_ItemForEachChild( p, Amap_LibertyRoot(p), pCell ) + { +/* + if ( strcmp(Amap_LibertyGetString(p, pCell->Head), "HA1SVTX1") == 0 ) + { + int s = 0; + } +*/ + if ( Amap_LibertyCompare(p, pCell->Key, "cell") ) + continue; + if ( Amap_LibertyCellIsFlop(p, pCell) ) + { + printf( "Amap_LibertyPrintGenlib() skipped sequential cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) ); + continue; + } + Counter = Amap_LibertyCellCountOutputs( p, pCell ); + if ( Counter == 0 ) + { + printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" without logic function.\n", Amap_LibertyGetString(p, pCell->Head) ); + continue; + } + if ( Counter > 1 ) + { + printf( "Amap_LibertyPrintGenlib() skipped multi-output cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) ); + continue; + } + pArea = Amap_LibertyCellArea( p, pCell ); + if ( pArea == NULL ) + { + printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with unspecified area.\n", Amap_LibertyGetString(p, pCell->Head) ); + continue; + } + pOutput = Amap_LibertyCellOutput( p, pCell ); + pFunc = Amap_LibertyPinFunction( p, pOutput ); + + fprintf( pFile, "GATE " ); + fprintf( pFile, "%16s ", Amap_LibertyGetString(p, pCell->Head) ); + fprintf( pFile, "%f ", atof(Amap_LibertyGetString(p, pArea->Head)) ); + fprintf( pFile, "%s=", Amap_LibertyGetString(p, pOutput->Head) ); + fprintf( pFile, "%s;\n", Amap_LibertyGetStringFormula(p, pFunc->Head) ); + + Amap_ItemForEachChild( p, pCell, pPin ) + if ( pPin != pOutput && !Amap_LibertyCompare(p, pPin->Key, "pin") ) + fprintf( pFile, " PIN %13s UNKNOWN 1 999 1.00 0.00 1.00 0.00\n", Amap_LibertyGetString(p, pPin->Head) ); + } + if ( pFile != stdout ) + fclose( pFile ); + return 1; +} + + +/**Function************************************************************* + + Synopsis [Returns the file size.] + + Description [The file should be closed.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyFileSize( char * pFileName ) +{ + FILE * pFile; + int nFileSize; + pFile = fopen( pFileName, "rb" ); + if ( pFile == NULL ) + { + printf( "Amap_LibertyFileSize(): The input 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 [] + +***********************************************************************/ +void Amap_LibertyFixFileHead( char * pFileName ) +{ + char * pHead; + for ( pHead = pFileName; *pHead; pHead++ ) + if ( *pHead == '>' ) + *pHead = '\\'; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyCountItems( char * pBeg, char * pEnd ) +{ + int Counter = 0; + for ( ; pBeg < pEnd; pBeg++ ) + Counter += (*pBeg == '(' || *pBeg == ':'); + return Counter; +} + +/**Function************************************************************* + + Synopsis [Removes C-style comments.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Amap_LibertyWipeOutComments( char * pBeg, char * pEnd ) +{ + char * pCur, * pStart; + for ( pCur = pBeg; pCur < pEnd; pCur++ ) + if ( pCur[0] == '/' && pCur[1] == '*' ) + for ( pStart = pCur; pCur < pEnd; pCur++ ) + if ( pCur[0] == '*' && pCur[1] == '/' ) + { + for ( ; pStart < pCur + 2; pStart++ ) + if ( *pStart != '\n' ) *pStart = ' '; + break; + } +} + +/**Function************************************************************* + + Synopsis [Returns 1 if the character is space.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Amap_LibertyCharIsSpace( char c ) +{ + return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\\'; +} + +/**Function************************************************************* + + Synopsis [Skips spaces.] + + Description [Returns 1 if reached the end.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Amap_LibertySkipSpaces( Amap_Tree_t * p, char ** ppPos, char * pEnd ) +{ + char * pPos = *ppPos; + for ( ; pPos < pEnd; pPos++ ) + { + if ( *pPos == '\n' ) + p->nLines++; + if ( !Amap_LibertyCharIsSpace(*pPos) ) + break; + } + *ppPos = pPos; + return pPos == pEnd; +} + +/**Function************************************************************* + + Synopsis [Skips entry delimited by " :;(){}" ] + + Description [Returns 1 if reached the end.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Amap_LibertySkipEntry( char ** ppPos, char * pEnd ) +{ + char * pPos = *ppPos; + if ( *pPos == '\"' ) + { + for ( pPos++; pPos < pEnd; pPos++ ) + if ( *pPos == '\"' ) + { + pPos++; + break; + } + } + else + { + for ( ; pPos < pEnd; pPos++ ) + if ( *pPos == ' ' || + *pPos == ':' || *pPos == ';' || + *pPos == '(' || *pPos == ')' || + *pPos == '{' || *pPos == '}' ) + break; + } + *ppPos = pPos; + return pPos == pEnd; +} + +/**Function************************************************************* + + Synopsis [Find the matching closing symbol.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline char * Amap_LibertyFindMatch( char * pPos, char * pEnd ) +{ + int Counter = 0; + assert( *pPos == '(' || *pPos == '{' ); + if ( *pPos == '(' ) + { + for ( ; pPos < pEnd; pPos++ ) + { + if ( *pPos == '(' ) + Counter++; + if ( *pPos == ')' ) + Counter--; + if ( Counter == 0 ) + break; + } + } + else + { + for ( ; pPos < pEnd; pPos++ ) + { + if ( *pPos == '{' ) + Counter++; + if ( *pPos == '}' ) + Counter--; + if ( Counter == 0 ) + break; + } + } + assert( *pPos == ')' || *pPos == '}' ); + return pPos; +} + +/**Function************************************************************* + + Synopsis [Find the matching closing symbol.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline Amap_Pair_t Amap_LibertyUpdateHead( Amap_Tree_t * p, Amap_Pair_t Head ) +{ + Amap_Pair_t Res; + char * pBeg = p->pContents + Head.Beg; + char * pEnd = p->pContents + Head.End; + char * pFirstNonSpace = NULL; + char * pLastNonSpace = NULL; + char * pChar; + for ( pChar = pBeg; pChar < pEnd; pChar++ ) + { + if ( *pChar == '\n' ) + p->nLines++; + if ( Amap_LibertyCharIsSpace(*pChar) ) + continue; + pLastNonSpace = pChar; + if ( pFirstNonSpace == NULL ) + pFirstNonSpace = pChar; + } + if ( pFirstNonSpace == NULL || pLastNonSpace == NULL ) + return Head; + assert( pFirstNonSpace && pLastNonSpace ); + Res.Beg = pFirstNonSpace - p->pContents; + Res.End = pLastNonSpace - p->pContents + 1; + return Res; +} + +/**Function************************************************************* + + Synopsis [Returns free item.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline Amap_Item_t * Amap_LibertyNewItem( Amap_Tree_t * p, int Type ) +{ + p->pItems[p->nItems].iLine = p->nLines; + p->pItems[p->nItems].Type = Type; + p->pItems[p->nItems].Child = -1; + p->pItems[p->nItems].Next = -1; + return p->pItems + p->nItems++; +} + +/**Function************************************************************* + + Synopsis [Returns free item.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyBuildItem( Amap_Tree_t * p, char ** ppPos, char * pEnd ) +{ + Amap_Item_t * pItem; + Amap_Pair_t Key, Head, Body; + char * pNext, * pStop; + if ( Amap_LibertySkipSpaces( p, ppPos, pEnd ) ) + return -2; + Key.Beg = *ppPos - p->pContents; + if ( Amap_LibertySkipEntry( ppPos, pEnd ) ) + goto exit; + Key.End = *ppPos - p->pContents; + if ( Amap_LibertySkipSpaces( p, ppPos, pEnd ) ) + goto exit; + pNext = *ppPos; + if ( *pNext == ':' ) + { + *ppPos = pNext + 1; + if ( Amap_LibertySkipSpaces( p, ppPos, pEnd ) ) + goto exit; + Head.Beg = *ppPos - p->pContents; + if ( Amap_LibertySkipEntry( ppPos, pEnd ) ) + goto exit; + Head.End = *ppPos - p->pContents; + if ( Amap_LibertySkipSpaces( p, ppPos, pEnd ) ) + goto exit; + pNext = *ppPos; + if ( *pNext != ';' ) + goto exit; + *ppPos = pNext + 1; + // end of equation + pItem = Amap_LibertyNewItem( p, AMAP_LIBERTY_EQUA ); + pItem->Key = Key; + pItem->Head = Amap_LibertyUpdateHead( p, Head ); + pItem->Next = Amap_LibertyBuildItem( p, ppPos, pEnd ); + if ( pItem->Next == -1 ) + goto exit; + return Amap_LibertyItemId( p, pItem ); + } + if ( *pNext == '(' ) + { + pStop = Amap_LibertyFindMatch( pNext, pEnd ); + Head.Beg = pNext - p->pContents + 1; + Head.End = pStop - p->pContents; + *ppPos = pStop + 1; + if ( Amap_LibertySkipSpaces( p, ppPos, pEnd ) ) + { + // end of list + pItem = Amap_LibertyNewItem( p, AMAP_LIBERTY_LIST ); + pItem->Key = Key; + pItem->Head = Amap_LibertyUpdateHead( p, Head ); + return Amap_LibertyItemId( p, pItem ); + } + pNext = *ppPos; + if ( *pNext == '{' ) // beginning of body + { + pStop = Amap_LibertyFindMatch( pNext, pEnd ); + Body.Beg = pNext - p->pContents + 1; + Body.End = pStop - p->pContents; + // end of body + pItem = Amap_LibertyNewItem( p, AMAP_LIBERTY_PROC ); + pItem->Key = Key; + pItem->Head = Amap_LibertyUpdateHead( p, Head ); + pItem->Body = Body; + *ppPos = pNext + 1; + pItem->Child = Amap_LibertyBuildItem( p, ppPos, pStop ); + if ( pItem->Child == -1 ) + goto exit; + *ppPos = pStop + 1; + pItem->Next = Amap_LibertyBuildItem( p, ppPos, pEnd ); + if ( pItem->Next == -1 ) + goto exit; + return Amap_LibertyItemId( p, pItem ); + } + // end of list + if ( *pNext == ';' ) + *ppPos = pNext + 1; + pItem = Amap_LibertyNewItem( p, AMAP_LIBERTY_LIST ); + pItem->Key = Key; + pItem->Head = Amap_LibertyUpdateHead( p, Head ); + pItem->Next = Amap_LibertyBuildItem( p, ppPos, pEnd ); + if ( pItem->Next == -1 ) + goto exit; + return Amap_LibertyItemId( p, pItem ); + } +exit: + if ( p->pError == NULL ) + { + p->pError = ABC_ALLOC( char, 1000 ); + sprintf( p->pError, "File \"%s\". Line %6d. Failed to parse entry \"%s\".\n", + p->pFileName, p->nLines, Amap_LibertyGetString(p, Key) ); + } + return -1; +} + +/**Function************************************************************* + + Synopsis [Starts the parsing manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Amap_Tree_t * Amap_LibertyStart( char * pFileName ) +{ + FILE * pFile; + Amap_Tree_t * p; + // start the manager + p = ABC_ALLOC( Amap_Tree_t, 1 ); + memset( p, 0, sizeof(Amap_Tree_t) ); + // read the file into the buffer + Amap_LibertyFixFileHead( pFileName ); + p->nContents = Amap_LibertyFileSize( pFileName ); + if ( p->nContents == 0 ) + { + ABC_FREE( p ); + return NULL; + } + pFile = fopen( pFileName, "rb" ); + p->pContents = ABC_ALLOC( char, p->nContents+1 ); + fread( p->pContents, p->nContents, 1, pFile ); + fclose( pFile ); + p->pContents[p->nContents] = 0; + // other + p->pFileName = Aig_UtilStrsav( pFileName ); + p->nItermAlloc = 10 + Amap_LibertyCountItems( p->pContents, p->pContents+p->nContents ); + p->pItems = ABC_CALLOC( Amap_Item_t, p->nItermAlloc ); + p->nItems = 0; + p->nLines = 1; + return p; +} + +/**Function************************************************************* + + Synopsis [Stops the parsing manager.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Amap_LibertyStop( Amap_Tree_t * p ) +{ + ABC_FREE( p->pFileName ); + ABC_FREE( p->pContents ); + ABC_FREE( p->pItems ); + ABC_FREE( p->pError ); + ABC_FREE( p ); +} + +/**Function************************************************************* + + Synopsis [Parses the standard cell library in Liberty format.] + + Description [Writes the resulting file in Genlib format.] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_LibertyParse( char * pFileName, char * pFileGenlib, int fVerbose ) +{ + Amap_Tree_t * p; + char * pPos; + int clk = clock(); + int RetValue; + p = Amap_LibertyStart( pFileName ); + if ( p == NULL ) + return 0; + pPos = p->pContents; + Amap_LibertyWipeOutComments( p->pContents, p->pContents+p->nContents ); + if ( Amap_LibertyBuildItem( p, &pPos, p->pContents + p->nContents ) == 0 ) + { + if ( fVerbose ) + printf( "Parsing finished successfully.\n" ); +// Amap_LibertyPrintLiberty( p, "temp.lib" ); + Amap_LibertyPrintGenlib( p, "temp.genlib" ); + RetValue = 1; + } + else + { + if ( p->pError ) + printf( "%s", p->pError ); + if ( fVerbose ) + printf( "Parsing failed.\n" ); + RetValue = 0; + } + if ( fVerbose ) + { + printf( "Memory = %7.2f Mb. ", 1.0*(p->nContents+p->nItermAlloc*sizeof(Amap_Item_t))/(1<<20) ); + ABC_PRT( "Time", clock() - clk ); + } + Amap_LibertyStop( p ); + return RetValue; +} + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + + diff --git a/src/map/amap/amapMan.c b/src/map/amap/amapMan.c index 521b4ffd..a1a66869 100644 --- a/src/map/amap/amapMan.c +++ b/src/map/amap/amapMan.c @@ -43,7 +43,7 @@ Amap_Man_t * Amap_ManStart( int nNodes ) { Amap_Man_t * p; // start the manager - p = ALLOC( Amap_Man_t, 1 ); + p = ABC_ALLOC( Amap_Man_t, 1 ); memset( p, 0, sizeof(Amap_Man_t) ); p->fEpsilonInternal = (float)0.01; // allocate arrays for nodes @@ -86,10 +86,10 @@ void Amap_ManStop( Amap_Man_t * p ) Aig_MmFlexStop( p->pMemCuts, 0 ); Aig_MmFlexStop( p->pMemCutBest, 0 ); Aig_MmFlexStop( p->pMemTemp, 0 ); - FREE( p->pMatsTemp ); - FREE( p->ppCutsTemp ); - FREE( p->pCutsPi ); - free( p ); + ABC_FREE( p->pMatsTemp ); + ABC_FREE( p->ppCutsTemp ); + ABC_FREE( p->pCutsPi ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/map/amap/amapMatch.c b/src/map/amap/amapMatch.c index 0b15a931..0ea65219 100644 --- a/src/map/amap/amapMatch.c +++ b/src/map/amap/amapMatch.c @@ -122,7 +122,7 @@ void Amap_ManCleanData( Amap_Man_t * p ) Amap_Obj_t * pObj; int i; // Amap_ManForEachNode( p, pObj, i ) -// FREE( pObj->pData ); +// ABC_FREE( pObj->pData ); Amap_ManForEachObj( p, pObj, i ) pObj->pData = NULL; } @@ -496,7 +496,7 @@ if ( p->pPars->fVerbose ) Area + nInvs * p->fAreaInv, Area, nInvs * p->fAreaInv, nInvs, Amap_ManMaxDelay(p) ); -PRT( "Time ", clock() - clk ); +ABC_PRT( "Time ", clock() - clk ); } // test procedures // Amap_ManForEachNode( p, pObj, i ) diff --git a/src/map/amap/amapMerge.c b/src/map/amap/amapMerge.c index b024616e..1a6e3804 100644 --- a/src/map/amap/amapMerge.c +++ b/src/map/amap/amapMerge.c @@ -44,7 +44,7 @@ Amap_Cut_t * Amap_ManSetupPis( Amap_Man_t * p ) Amap_Obj_t * pObj; Amap_Cut_t * pCut; int i, nBytes = sizeof(Amap_Cut_t) + sizeof(int); - char * pBuffer = ALLOC( char, Amap_ManPiNum(p) * nBytes ); + char * pBuffer = ABC_ALLOC( char, Amap_ManPiNum(p) * nBytes ); Amap_ManForEachPi( p, pObj, i ) { pCut = (Amap_Cut_t *)( pBuffer + i*nBytes ); @@ -509,7 +509,7 @@ void Amap_ManMerge( Amap_Man_t * p ) printf( "Node =%6d. Try =%9d. Try3 =%10d. Used =%7d. R =%6.2f. ", Amap_ManNodeNum(p), p->nCutsTried, p->nCutsTried3, p->nCutsUsed, 1.0*p->nCutsUsed/Amap_ManNodeNum(p) ); -PRT( "Time ", clock() - clk ); +ABC_PRT( "Time ", clock() - clk ); } } diff --git a/src/map/amap/amapParse.c b/src/map/amap/amapParse.c index 262fbd5a..48dabca2 100644 --- a/src/map/amap/amapParse.c +++ b/src/map/amap/amapParse.c @@ -122,7 +122,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa } // copy the formula - pFormula = ALLOC( char, strlen(pFormInit) + 3 ); + pFormula = ABC_ALLOC( char, strlen(pFormInit) + 3 ); sprintf( pFormula, "(%s)", pFormInit ); // start the stacks @@ -198,10 +198,10 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa case AMAP_EQN_SYM_OPEN: if ( Flag == AMAP_EQN_FLAG_VAR ) { -// Vec_IntPush( pStackOp, AMAP_EQN_OPER_AND ); - fprintf( pOutput, "Amap_ParseFormula(): An opening paranthesis follows a var without operation sign.\n" ); - Flag = AMAP_EQN_FLAG_ERROR; - break; + Vec_IntPush( pStackOp, AMAP_EQN_OPER_AND ); +// fprintf( pOutput, "Amap_ParseFormula(): An opening paranthesis follows a var without operation sign.\n" ); +// Flag = AMAP_EQN_FLAG_ERROR; +// break; } Vec_IntPush( pStackOp, AMAP_EQN_OPER_MARK ); // after an opening bracket, it feels like starting over again @@ -226,7 +226,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa if ( Amap_ParseFormulaOper( pMan, pStackFn, Oper ) == NULL ) { fprintf( pOutput, "Amap_ParseFormula(): Unknown operation\n" ); - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } } @@ -247,7 +247,8 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa for ( i = 0; pTemp[i] && pTemp[i] != ' ' && pTemp[i] != '\t' && pTemp[i] != '\r' && pTemp[i] != '\n' && pTemp[i] != AMAP_EQN_SYM_AND && pTemp[i] != AMAP_EQN_SYM_OR && - pTemp[i] != AMAP_EQN_SYM_XOR && pTemp[i] != AMAP_EQN_SYM_CLOSE; i++ ) + pTemp[i] != AMAP_EQN_SYM_XOR && pTemp[i] != AMAP_EQN_SYM_NEGAFT && + pTemp[i] != AMAP_EQN_SYM_CLOSE; i++ ) { if ( pTemp[i] == AMAP_EQN_SYM_NEG || pTemp[i] == AMAP_EQN_SYM_OPEN ) { @@ -271,12 +272,17 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa Flag = AMAP_EQN_FLAG_ERROR; break; } +/* if ( Flag == AMAP_EQN_FLAG_VAR ) { fprintf( pOutput, "Amap_ParseFormula(): The variable name \"%s\" follows another var without operation sign.\n", pTemp ); Flag = AMAP_EQN_FLAG_ERROR; break; } +*/ + if ( Flag == AMAP_EQN_FLAG_VAR ) + Vec_IntPush( pStackOp, AMAP_EQN_OPER_AND ); + Vec_PtrPush( pStackFn, Hop_IthVar( pMan, v ) ); // Cudd_Ref( pbVars[v] ); Flag = AMAP_EQN_FLAG_VAR; break; @@ -318,7 +324,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa if ( Amap_ParseFormulaOper( pMan, pStackFn, Oper2 ) == NULL ) { fprintf( pOutput, "Amap_ParseFormula(): Unknown operation\n" ); - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } Vec_IntPush( pStackOp, Oper1 ); // push the last operation back @@ -343,7 +349,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa Vec_PtrFree(pStackFn); Vec_IntFree(pStackOp); // Cudd_Deref( gFunc ); - free( pFormula ); + ABC_FREE( pFormula ); return gFunc; } else @@ -354,7 +360,7 @@ Hop_Obj_t * Amap_ParseFormula( FILE * pOutput, char * pFormInit, Vec_Ptr_t * vVa else fprintf( pOutput, "Amap_ParseFormula(): The input string is empty\n" ); } - free( pFormula ); + ABC_FREE( pFormula ); return NULL; } @@ -414,7 +420,7 @@ int Amap_LibParseEquations( Amap_Lib_t * p, int fVerbose ) pTruth = Hop_ManConvertAigToTruth( pMan, pObj, pGate->nPins, vTruth, 0 ); if ( Kit_TruthSupportSize(pTruth, pGate->nPins) < (int)pGate->nPins ) { - printf( "Skipping gate \"%s\" because its formula \"%s\" does not depend on some pin variables.\n", pGate->pName, pGate->pForm ); + printf( "Skipping gate \"%s\" because its output \"%s\" does not depend on all input variables.\n", pGate->pName, pGate->pForm ); continue; } pGate->pFunc = (unsigned *)Aig_MmFlexEntryFetch( p->pMemGates, sizeof(unsigned)*Aig_TruthWordNum(pGate->nPins) ); @@ -447,7 +453,7 @@ void Amap_LibParseTest( char * pFileName ) return; Amap_LibParseEquations( p, fVerbose ); Amap_LibFree( p ); - PRT( "Total time", clock() - clk ); + ABC_PRT( "Total time", clock() - clk ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/map/amap/amapRead.c b/src/map/amap/amapRead.c index 182de5d1..7ebc239b 100644 --- a/src/map/amap/amapRead.c +++ b/src/map/amap/amapRead.c @@ -89,7 +89,7 @@ char * Amap_LoadFile( char * pFileName ) // move the file current reading position to the beginning rewind( pFile ); // load the contents of the file into memory - pBuffer = ALLOC( char, nFileSize + 10 ); + pBuffer = ABC_ALLOC( char, nFileSize + 10 ); fread( pBuffer, nFileSize, 1, pFile ); // terminate the string with '\0' pBuffer[ nFileSize ] = '\0'; @@ -173,11 +173,11 @@ Vec_Ptr_t * Amap_DeriveTokens( char * pBuffer ) Vec_Ptr_t * vTokens; char * pToken; vTokens = Vec_PtrAlloc( 1000 ); - pToken = strtok( pBuffer, " ;=\t\r\n" ); + pToken = strtok( pBuffer, " =\t\r\n" ); while ( pToken ) { Vec_PtrPush( vTokens, pToken ); - pToken = strtok( NULL, " ;=\t\r\n" ); + pToken = strtok( NULL, " =\t\r\n" ); } return vTokens; } @@ -277,6 +277,32 @@ Amap_Gat_t * Amap_ParseGateWithSamePins( Amap_Gat_t * p ) return pGate; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Amap_CollectFormulaTokens( Vec_Ptr_t * vTokens, char * pToken, int iPos ) +{ + char * pNext, * pPrev; + pPrev = pToken + strlen(pToken); + while ( *(pPrev-1) != ';' ) + { + *pPrev++ = ' '; + pNext = Vec_PtrEntry(vTokens, iPos++); + while ( *pNext ) + *pPrev++ = *pNext++; + } + *(pPrev-1) = 0; + return iPos; +} + /**Function************************************************************* Synopsis [] @@ -320,6 +346,7 @@ Amap_Lib_t * Amap_ParseTokens( Vec_Ptr_t * vTokens, int fVerbose ) pToken = Vec_PtrEntry(vTokens, iPos++); pGate->pOutName = Amap_ParseStrsav( p->pMemGates, pToken ); pToken = Vec_PtrEntry(vTokens, iPos++); + iPos = Amap_CollectFormulaTokens( vTokens, pToken, iPos ); pGate->pForm = Amap_ParseStrsav( p->pMemGates, pToken ); // read pins Amap_GateForEachPin( pGate, pPin ) @@ -401,7 +428,7 @@ Amap_Lib_t * Amap_LibReadFile( char * pFileName, int fVerbose ) return NULL; pLib->pName = Amap_ParseStrsav( pLib->pMemGates, pFileName ); Vec_PtrFree( vTokens ); - free( pBuffer ); + ABC_FREE( pBuffer ); return pLib; } diff --git a/src/map/amap/amapUniq.c b/src/map/amap/amapUniq.c index 83fce6a2..e57161e4 100644 --- a/src/map/amap/amapUniq.c +++ b/src/map/amap/amapUniq.c @@ -134,7 +134,7 @@ Amap_Nod_t * Amap_LibCreateObj( Amap_Lib_t * p ) Amap_Nod_t * pNode; if ( p->nNodes == p->nNodesAlloc ) { - p->pNodes = REALLOC( Amap_Nod_t, p->pNodes, 2*p->nNodesAlloc ); + p->pNodes = ABC_REALLOC( Amap_Nod_t, p->pNodes, 2*p->nNodesAlloc ); p->nNodesAlloc *= 2; } pNode = Amap_LibNod( p, p->nNodes ); @@ -164,7 +164,7 @@ int Amap_LibCreateVar( Amap_Lib_t * p ) // start the manager assert( p->pNodes == NULL ); p->nNodesAlloc = 256; - p->pNodes = ALLOC( Amap_Nod_t, p->nNodesAlloc ); + p->pNodes = ABC_ALLOC( Amap_Nod_t, p->nNodesAlloc ); // create the first node pNode = Amap_LibCreateObj( p ); p->pNodes->Type = AMAP_OBJ_PI; @@ -281,7 +281,7 @@ int ** Amap_LibLookupTableAlloc( Vec_Ptr_t * vVec, int fVerbose ) nEntries = nSize = Vec_PtrSize( vVec ); Vec_PtrForEachEntry( vVec, vOne, i ) nEntries += Vec_IntSize(vOne); - pBuffer = ALLOC( int, nSize * sizeof(void *) + nEntries ); + pBuffer = ABC_ALLOC( int, nSize * sizeof(void *) + nEntries ); pRes = (int **)pBuffer; pRes[0] = pBuffer + nSize * sizeof(void *); nTotal = 0; diff --git a/src/map/amap/module.make b/src/map/amap/module.make index d5edadb9..2d534009 100644 --- a/src/map/amap/module.make +++ b/src/map/amap/module.make @@ -1,6 +1,7 @@ SRC += src/map/amap/amapCore.c \ src/map/amap/amapGraph.c \ src/map/amap/amapLib.c \ + src/map/amap/amapLiberty.c \ src/map/amap/amapMan.c \ src/map/amap/amapMatch.c \ src/map/amap/amapMerge.c \ diff --git a/src/map/fpga/fpga.h b/src/map/fpga/fpga.h index b2ca4882..0479847c 100644 --- a/src/map/fpga/fpga.h +++ b/src/map/fpga/fpga.h @@ -19,10 +19,6 @@ #ifndef __FPGA_H__ #define __FPGA_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -31,6 +27,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + // the maximum size of LUTs used for mapping #define FPGA_MAX_LUTSIZE 32 @@ -52,10 +52,10 @@ typedef struct Fpga_LutLibStruct_t_ Fpga_LutLib_t; /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#define Fpga_IsComplement(p) (((int)((PORT_PTRUINT_T) (p) & 01))) -#define Fpga_Regular(p) ((Fpga_Node_t *)((PORT_PTRUINT_T)(p) & ~01)) -#define Fpga_Not(p) ((Fpga_Node_t *)((PORT_PTRUINT_T)(p) ^ 01)) -#define Fpga_NotCond(p,c) ((Fpga_Node_t *)((PORT_PTRUINT_T)(p) ^ (c))) +#define Fpga_IsComplement(p) (((int)((ABC_PTRUINT_T) (p) & 01))) +#define Fpga_Regular(p) ((Fpga_Node_t *)((ABC_PTRUINT_T)(p) & ~01)) +#define Fpga_Not(p) ((Fpga_Node_t *)((ABC_PTRUINT_T)(p) ^ 01)) +#define Fpga_NotCond(p,c) ((Fpga_Node_t *)((ABC_PTRUINT_T)(p) ^ (c))) #define Fpga_Ref(p) #define Fpga_Deref(p) diff --git a/src/map/fpga/fpgaCore.c b/src/map/fpga/fpgaCore.c index 634a8eb1..17feac7c 100644 --- a/src/map/fpga/fpgaCore.c +++ b/src/map/fpga/fpgaCore.c @@ -72,7 +72,7 @@ int Fpga_Mapping( Fpga_Man_t * p ) if ( !Fpga_MappingPostProcess( p ) ) return 0; p->timeRecover = clock() - clk; -//PRT( "Total mapping time", clock() - clkTotal ); +//ABC_PRT( "Total mapping time", clock() - clkTotal ); s_MappingTime = clock() - clkTotal; s_MappingMem = Fpga_CutCountAll(p) * (sizeof(Fpga_Cut_t) - sizeof(int) * (FPGA_MAX_LEAVES - p->nVarsMax)); @@ -83,7 +83,7 @@ int Fpga_Mapping( Fpga_Man_t * p ) // Fpga_MappingPrintOutputArrivals( p ); if ( p->fVerbose ) { - PRT( "Total time", clock() - clkTotal ); + ABC_PRT( "Total time", clock() - clkTotal ); } return 1; } @@ -125,7 +125,7 @@ printf( "Switch = %8.1f ", Fpga_MappingGetSwitching(p,p->vMapping) ); else printf( "Delay = %5.2f ", Fpga_TimeComputeArrivalMax(p) ); -PRT( "Time", p->timeMatch ); +ABC_PRT( "Time", p->timeMatch ); } if ( !p->fAreaRecovery ) @@ -150,7 +150,7 @@ if ( fShowSwitching ) printf( "Switch = %8.1f ", Fpga_MappingGetSwitching(p,p->vMapping) ); else printf( "Delay = %5.2f ", Fpga_TimeComputeArrivalMax(p) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } @@ -177,7 +177,7 @@ if ( fShowSwitching ) printf( "Switch = %8.1f ", Fpga_MappingGetSwitching(p,p->vMapping) ); else printf( "Delay = %5.2f ", Fpga_TimeComputeArrivalMax(p) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } diff --git a/src/map/fpga/fpgaCreate.c b/src/map/fpga/fpgaCreate.c index c0bae1c7..5245f050 100644 --- a/src/map/fpga/fpgaCreate.c +++ b/src/map/fpga/fpgaCreate.c @@ -28,7 +28,7 @@ static void Fpga_TableResize( Fpga_Man_t * p ); static Fpga_Node_t * Fpga_TableLookup( Fpga_Man_t * p, Fpga_Node_t * p1, Fpga_Node_t * p2 ); // hash key for the structural hash table -static inline unsigned Fpga_HashKey2( Fpga_Node_t * p0, Fpga_Node_t * p1, int TableSize ) { return (unsigned)(((PORT_PTRUINT_T)(p0) + (PORT_PTRUINT_T)(p1) * 12582917) % TableSize); } +static inline unsigned Fpga_HashKey2( Fpga_Node_t * p0, Fpga_Node_t * p1, int TableSize ) { return (unsigned)(((ABC_PTRUINT_T)(p0) + (ABC_PTRUINT_T)(p1) * 12582917) % TableSize); } //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -167,7 +167,7 @@ Fpga_Man_t * Fpga_ManCreate( int nInputs, int nOutputs, int fVerbose ) int i; // start the manager - p = ALLOC( Fpga_Man_t, 1 ); + p = ABC_ALLOC( Fpga_Man_t, 1 ); memset( p, 0, sizeof(Fpga_Man_t) ); p->pLutLib = Abc_FrameReadLibLut(); p->nVarsMax = p->pLutLib->LutMax; @@ -193,13 +193,13 @@ Fpga_Man_t * Fpga_ManCreate( int nInputs, int nOutputs, int fVerbose ) // create the PI nodes p->nInputs = nInputs; - p->pInputs = ALLOC( Fpga_Node_t *, nInputs ); + p->pInputs = ABC_ALLOC( Fpga_Node_t *, nInputs ); for ( i = 0; i < nInputs; i++ ) p->pInputs[i] = Fpga_NodeCreate( p, NULL, NULL ); // create the place for the output nodes p->nOutputs = nOutputs; - p->pOutputs = ALLOC( Fpga_Node_t *, nOutputs ); + p->pOutputs = ABC_ALLOC( Fpga_Node_t *, nOutputs ); memset( p->pOutputs, 0, sizeof(Fpga_Node_t *) * nOutputs ); return p; } @@ -230,12 +230,12 @@ void Fpga_ManFree( Fpga_Man_t * p ) Fpga_NodeVecFree( p->vNodesAll ); Extra_MmFixedStop( p->mmNodes ); Extra_MmFixedStop( p->mmCuts ); - FREE( p->ppOutputNames ); - FREE( p->pInputArrivals ); - FREE( p->pInputs ); - FREE( p->pOutputs ); - FREE( p->pBins ); - FREE( p ); + ABC_FREE( p->ppOutputNames ); + ABC_FREE( p->pInputArrivals ); + ABC_FREE( p->pInputs ); + ABC_FREE( p->pOutputs ); + ABC_FREE( p->pBins ); + ABC_FREE( p ); } @@ -269,14 +269,14 @@ void Fpga_ManPrintTimeStats( Fpga_Man_t * p ) // printf( "N-canonical = %d. Matchings = %d. ", p->nCanons, p->nMatches ); // printf( "Choice nodes = %d. Choices = %d.\n", p->nChoiceNodes, p->nChoices ); - PRT( "ToMap", p->timeToMap ); - PRT( "Cuts ", p->timeCuts ); - PRT( "Match", p->timeMatch ); - PRT( "Area ", p->timeRecover ); - PRT( "ToNet", p->timeToNet ); - PRT( "TOTAL", p->timeTotal ); - if ( p->time1 ) { PRT( "time1", p->time1 ); } - if ( p->time2 ) { PRT( "time2", p->time2 ); } + ABC_PRT( "ToMap", p->timeToMap ); + ABC_PRT( "Cuts ", p->timeCuts ); + ABC_PRT( "Match", p->timeMatch ); + ABC_PRT( "Area ", p->timeRecover ); + ABC_PRT( "ToNet", p->timeToNet ); + ABC_PRT( "TOTAL", p->timeTotal ); + if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); } + if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); } } /**Function************************************************************* @@ -344,7 +344,7 @@ void Fpga_TableCreate( Fpga_Man_t * pMan ) { assert( pMan->pBins == NULL ); pMan->nBins = Cudd_Prime(50000); - pMan->pBins = ALLOC( Fpga_Node_t *, pMan->nBins ); + pMan->pBins = ABC_ALLOC( Fpga_Node_t *, pMan->nBins ); memset( pMan->pBins, 0, sizeof(Fpga_Node_t *) * pMan->nBins ); pMan->nNodes = 0; } @@ -429,7 +429,7 @@ clk = clock(); // get the new table size nBinsNew = Cudd_Prime(2 * pMan->nBins); // allocate a new array - pBinsNew = ALLOC( Fpga_Node_t *, nBinsNew ); + pBinsNew = ABC_ALLOC( Fpga_Node_t *, nBinsNew ); memset( pBinsNew, 0, sizeof(Fpga_Node_t *) * nBinsNew ); // rehash the entries from the old table Counter = 0; @@ -446,10 +446,10 @@ clk = clock(); if ( pMan->fVerbose ) { // printf( "Increasing the unique table size from %6d to %6d. ", pMan->nBins, nBinsNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); } // replace the table and the parameters - free( pMan->pBins ); + ABC_FREE( pMan->pBins ); pMan->pBins = pBinsNew; pMan->nBins = nBinsNew; } diff --git a/src/map/fpga/fpgaCut.c b/src/map/fpga/fpgaCut.c index de558456..a9108871 100644 --- a/src/map/fpga/fpgaCut.c +++ b/src/map/fpga/fpgaCut.c @@ -157,7 +157,7 @@ void Fpga_MappingCuts( Fpga_Man_t * p ) nCuts = Fpga_CutCountAll(p); printf( "Nodes = %6d. Total %d-cuts = %d. Cuts per node = %.1f. ", p->nNodes, p->nVarsMax, nCuts, ((float)nCuts)/p->nNodes ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // print the cuts for the first primary output @@ -913,15 +913,15 @@ Fpga_CutTable_t * Fpga_CutTableStart( Fpga_Man_t * pMan ) { Fpga_CutTable_t * p; // allocate the table - p = ALLOC( Fpga_CutTable_t, 1 ); + p = ABC_ALLOC( Fpga_CutTable_t, 1 ); memset( p, 0, sizeof(Fpga_CutTable_t) ); p->nBins = Cudd_Prime( 10 * FPGA_CUTS_MAX_COMPUTE ); - p->pBins = ALLOC( Fpga_Cut_t *, p->nBins ); + p->pBins = ABC_ALLOC( Fpga_Cut_t *, p->nBins ); memset( p->pBins, 0, sizeof(Fpga_Cut_t *) * p->nBins ); - p->pCuts = ALLOC( int, 2 * FPGA_CUTS_MAX_COMPUTE ); - p->pArray = ALLOC( Fpga_Cut_t *, 2 * FPGA_CUTS_MAX_COMPUTE ); - p->pCuts1 = ALLOC( Fpga_Cut_t *, 2 * FPGA_CUTS_MAX_COMPUTE ); - p->pCuts2 = ALLOC( Fpga_Cut_t *, 2 * FPGA_CUTS_MAX_COMPUTE ); + p->pCuts = ABC_ALLOC( int, 2 * FPGA_CUTS_MAX_COMPUTE ); + p->pArray = ABC_ALLOC( Fpga_Cut_t *, 2 * FPGA_CUTS_MAX_COMPUTE ); + p->pCuts1 = ABC_ALLOC( Fpga_Cut_t *, 2 * FPGA_CUTS_MAX_COMPUTE ); + p->pCuts2 = ABC_ALLOC( Fpga_Cut_t *, 2 * FPGA_CUTS_MAX_COMPUTE ); return p; } @@ -938,12 +938,12 @@ Fpga_CutTable_t * Fpga_CutTableStart( Fpga_Man_t * pMan ) ***********************************************************************/ void Fpga_CutTableStop( Fpga_CutTable_t * p ) { - free( p->pCuts1 ); - free( p->pCuts2 ); - free( p->pArray ); - free( p->pBins ); - free( p->pCuts ); - free( p ); + ABC_FREE( p->pCuts1 ); + ABC_FREE( p->pCuts2 ); + ABC_FREE( p->pArray ); + ABC_FREE( p->pBins ); + ABC_FREE( p->pCuts ); + ABC_FREE( p ); } /**Function************************************************************* @@ -1115,7 +1115,7 @@ Fpga_Cut_t * Fpga_CutSortCuts( Fpga_Man_t * pMan, Fpga_CutTable_t * p, Fpga_Cut_ if ( nCuts > FPGA_CUTS_MAX_USE - 1 ) { // printf( "*" ); - // free the remaining cuts + // ABC_FREE the remaining cuts for ( i = FPGA_CUTS_MAX_USE - 1; i < nCuts; i++ ) Extra_MmFixedEntryRecycle( pMan->mmCuts, (char *)p->pCuts1[i] ); // update the number of cuts diff --git a/src/map/fpga/fpgaInt.h b/src/map/fpga/fpgaInt.h index f4145e7f..ba9538c2 100644 --- a/src/map/fpga/fpgaInt.h +++ b/src/map/fpga/fpgaInt.h @@ -63,19 +63,19 @@ #define FPGA_INT_LARGE (10000000) // the macro to compute the signature -#define FPGA_SEQ_SIGN(p) (1 << (((PORT_PTRUINT_T)p)%31)); +#define FPGA_SEQ_SIGN(p) (1 << (((ABC_PTRUINT_T)p)%31)); // internal macros to work with cuts -#define Fpga_CutIsComplement(p) (((int)((PORT_PTRUINT_T)(p) & 01))) -#define Fpga_CutRegular(p) ((Fpga_Cut_t *)((PORT_PTRUINT_T)(p) & ~01)) -#define Fpga_CutNot(p) ((Fpga_Cut_t *)((PORT_PTRUINT_T)(p) ^ 01)) -#define Fpga_CutNotCond(p,c) ((Fpga_Cut_t *)((PORT_PTRUINT_T)(p) ^ (c))) +#define Fpga_CutIsComplement(p) (((int)((ABC_PTRUINT_T)(p) & 01))) +#define Fpga_CutRegular(p) ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) & ~01)) +#define Fpga_CutNot(p) ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) ^ 01)) +#define Fpga_CutNotCond(p,c) ((Fpga_Cut_t *)((ABC_PTRUINT_T)(p) ^ (c))) // the cut nodes -#define Fpga_SeqIsComplement( p ) (((int)((PORT_PTRUINT_T) (p) & 01))) -#define Fpga_SeqRegular( p ) ((Fpga_Node_t *)((PORT_PTRUINT_T)(p) & ~015)) -#define Fpga_SeqIndex( p ) ((((PORT_PTRUINT_T)(p)) >> 1) & 07) -#define Fpga_SeqIndexCreate( p, Ind ) (((PORT_PTRUINT_T)(p)) | (1 << (((PORT_PTRUINT_T)(Ind)) & 07))) +#define Fpga_SeqIsComplement( p ) (((int)((ABC_PTRUINT_T) (p) & 01))) +#define Fpga_SeqRegular( p ) ((Fpga_Node_t *)((ABC_PTRUINT_T)(p) & ~015)) +#define Fpga_SeqIndex( p ) ((((ABC_PTRUINT_T)(p)) >> 1) & 07) +#define Fpga_SeqIndexCreate( p, Ind ) (((ABC_PTRUINT_T)(p)) | (1 << (((ABC_PTRUINT_T)(Ind)) & 07))) // internal macros for referencing of nodes #define Fpga_NodeReadRef(p) ((Fpga_Regular(p))->nRefs) diff --git a/src/map/fpga/fpgaLib.c b/src/map/fpga/fpgaLib.c index b9615a8c..d5b12293 100644 --- a/src/map/fpga/fpgaLib.c +++ b/src/map/fpga/fpgaLib.c @@ -66,7 +66,7 @@ Fpga_LutLib_t * Fpga_LutLibRead( char * FileName, int fVerbose ) return NULL; } - p = ALLOC( Fpga_LutLib_t, 1 ); + p = ABC_ALLOC( Fpga_LutLib_t, 1 ); memset( p, 0, sizeof(Fpga_LutLib_t) ); p->pName = Extra_UtilStrsav( FileName ); @@ -81,7 +81,7 @@ Fpga_LutLib_t * Fpga_LutLibRead( char * FileName, int fVerbose ) if ( i != atoi(pToken) ) { printf( "Error in the LUT library file \"%s\".\n", FileName ); - free( p ); + ABC_FREE( p ); return NULL; } @@ -162,7 +162,7 @@ Fpga_LutLib_t * Fpga_LutLibRead( char * FileName, int fVerbose ) Fpga_LutLib_t * Fpga_LutLibDup( Fpga_LutLib_t * p ) { Fpga_LutLib_t * pNew; - pNew = ALLOC( Fpga_LutLib_t, 1 ); + pNew = ABC_ALLOC( Fpga_LutLib_t, 1 ); *pNew = *p; pNew->pName = Extra_UtilStrsav( pNew->pName ); return pNew; @@ -183,8 +183,8 @@ void Fpga_LutLibFree( Fpga_LutLib_t * pLutLib ) { if ( pLutLib == NULL ) return; - FREE( pLutLib->pName ); - FREE( pLutLib ); + ABC_FREE( pLutLib->pName ); + ABC_FREE( pLutLib ); } diff --git a/src/map/fpga/fpgaTruth.c b/src/map/fpga/fpgaTruth.c index 8ffb7819..7eca8e3e 100644 --- a/src/map/fpga/fpgaTruth.c +++ b/src/map/fpga/fpgaTruth.c @@ -44,7 +44,7 @@ DdNode * Fpga_TruthsCutBdd_rec( DdManager * dd, Fpga_Cut_t * pCut, Fpga_NodeVec_ assert( !Fpga_IsComplement(pCut) ); // if the cut is visited, return the result if ( pCut->uSign ) - return (DdNode *)(PORT_PTRUINT_T)pCut->uSign; + return (DdNode *)(ABC_PTRUINT_T)pCut->uSign; // compute the functions of the children bFunc0 = Fpga_TruthsCutBdd_rec( dd, Fpga_CutRegular(pCut->pOne), vVisited ); Cudd_Ref( bFunc0 ); bFunc0 = Cudd_NotCond( bFunc0, Fpga_CutIsComplement(pCut->pOne) ); @@ -56,7 +56,7 @@ DdNode * Fpga_TruthsCutBdd_rec( DdManager * dd, Fpga_Cut_t * pCut, Fpga_NodeVec_ Cudd_RecursiveDeref( dd, bFunc0 ); Cudd_RecursiveDeref( dd, bFunc1 ); assert( pCut->uSign == 0 ); - pCut->uSign = (unsigned)(PORT_PTRUINT_T)bFunc; + pCut->uSign = (unsigned)(ABC_PTRUINT_T)bFunc; // add this cut to the visited list Fpga_NodeVecPush( vVisited, (Fpga_Node_t *)pCut ); return bFunc; @@ -81,7 +81,7 @@ 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)(PORT_PTRUINT_T)Cudd_bddIthVar( dd, i ); + pCut->ppLeaves[i]->pCuts->uSign = (unsigned)(ABC_PTRUINT_T)Cudd_bddIthVar( dd, i ); // recursively compute the function vVisited = Fpga_NodeVecAlloc( 10 ); bFunc = Fpga_TruthsCutBdd_rec( dd, pCut, vVisited ); Cudd_Ref( bFunc ); @@ -91,7 +91,7 @@ void * Fpga_TruthsCutBdd( void * dd, Fpga_Cut_t * pCut ) for ( i = 0; i < vVisited->nSize; i++ ) { pCut = (Fpga_Cut_t *)vVisited->pArray[i]; - Cudd_RecursiveDeref( dd, (DdNode*)(PORT_PTRUINT_T)pCut->uSign ); + Cudd_RecursiveDeref( dd, (DdNode*)(ABC_PTRUINT_T)pCut->uSign ); pCut->uSign = 0; } // printf( "%d ", vVisited->nSize ); diff --git a/src/map/fpga/fpgaUtils.c b/src/map/fpga/fpgaUtils.c index 77c2e2b0..f360254b 100644 --- a/src/map/fpga/fpgaUtils.c +++ b/src/map/fpga/fpgaUtils.c @@ -305,7 +305,7 @@ float Fpga_MappingSetRefsAndArea( Fpga_Man_t * pMan ) // allocate place to store the nodes LevelMax = Fpga_MappingMaxLevel( pMan ); - ppStore = ALLOC( Fpga_Node_t *, LevelMax + 1 ); + ppStore = ABC_ALLOC( Fpga_Node_t *, LevelMax + 1 ); memset( ppStore, 0, sizeof(Fpga_Node_t *) * (LevelMax + 1) ); // collect nodes reachable from POs in the DFS order through the best cuts @@ -324,7 +324,7 @@ float Fpga_MappingSetRefsAndArea( Fpga_Man_t * pMan ) for ( i = LevelMax; i >= 0; i-- ) for ( pNode = ppStore[i]; pNode; pNode = (Fpga_Node_t *)pNode->pData0 ) Fpga_NodeVecPush( pMan->vMapping, pNode ); - free( ppStore ); + ABC_FREE( ppStore ); return aArea; } diff --git a/src/map/fpga/fpgaVec.c b/src/map/fpga/fpgaVec.c index 79b6b43d..b17697dd 100644 --- a/src/map/fpga/fpgaVec.c +++ b/src/map/fpga/fpgaVec.c @@ -42,12 +42,12 @@ static int Fpga_NodeVecCompareLevels( Fpga_Node_t ** pp1, Fpga_Node_t ** pp2 ); Fpga_NodeVec_t * Fpga_NodeVecAlloc( int nCap ) { Fpga_NodeVec_t * p; - p = ALLOC( Fpga_NodeVec_t, 1 ); + p = ABC_ALLOC( Fpga_NodeVec_t, 1 ); if ( nCap > 0 && nCap < 16 ) nCap = 16; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( Fpga_Node_t *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( Fpga_Node_t *, p->nCap ) : NULL; return p; } @@ -64,8 +64,8 @@ Fpga_NodeVec_t * Fpga_NodeVecAlloc( int nCap ) ***********************************************************************/ void Fpga_NodeVecFree( Fpga_NodeVec_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -115,7 +115,7 @@ void Fpga_NodeVecGrow( Fpga_NodeVec_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( Fpga_Node_t *, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( Fpga_Node_t *, p->pArray, nCapMin ); p->nCap = nCapMin; } diff --git a/src/map/if/if.h b/src/map/if/if.h index ce2cb483..91d6e037 100644 --- a/src/map/if/if.h +++ b/src/map/if/if.h @@ -21,10 +21,6 @@ #ifndef __IF_H__ #define __IF_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -38,6 +34,10 @@ extern "C" { #include "mem.h" #include "tim.h" +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// @@ -166,7 +166,7 @@ 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 free cutsets + If_Set_t * pFreeList; // the list of ABC_FREE cutsets int nSmallSupp; // the small support // timing manager Tim_Man_t * pManTim; @@ -198,7 +198,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 free list + If_Set_t * pNext; // next cutset in the ABC_FREE list If_Cut_t ** ppCuts; // the array of pointers to the cuts }; @@ -229,10 +229,10 @@ struct If_Obj_t_ If_Cut_t CutBest; // the best cut selected }; -static inline If_Obj_t * If_Regular( If_Obj_t * p ) { return (If_Obj_t *)((PORT_PTRUINT_T)(p) & ~01); } -static inline If_Obj_t * If_Not( If_Obj_t * p ) { return (If_Obj_t *)((PORT_PTRUINT_T)(p) ^ 01); } -static inline If_Obj_t * If_NotCond( If_Obj_t * p, int c ) { return (If_Obj_t *)((PORT_PTRUINT_T)(p) ^ (c)); } -static inline int If_IsComplement( If_Obj_t * p ) { return (int )(((PORT_PTRUINT_T)p) & 01); } +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)); } +static inline int If_IsComplement( If_Obj_t * p ) { return (int )(((ABC_PTRUINT_T)p) & 01); } static inline int If_ManCiNum( If_Man_t * p ) { return p->nObjs[IF_CI]; } static inline int If_ManCoNum( If_Man_t * p ) { return p->nObjs[IF_CO]; } diff --git a/src/map/if/ifCore.c b/src/map/if/ifCore.c index 99b99af7..0f0ca002 100644 --- a/src/map/if/ifCore.c +++ b/src/map/if/ifCore.c @@ -134,7 +134,7 @@ int If_ManPerformMappingComb( If_Man_t * p ) // printf( "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) ); - PRT( "Total time", clock() - clkTotal ); + ABC_PRT( "Total time", clock() - clkTotal ); } // printf( "Cross cut memory = %d.\n", Mem_FixedReadMaxEntriesUsed(p->pMemSet) ); s_MappingTime = clock() - clkTotal; diff --git a/src/map/if/ifCut.c b/src/map/if/ifCut.c index af1f5213..d3ce5397 100644 --- a/src/map/if/ifCut.c +++ b/src/map/if/ifCut.c @@ -1349,7 +1349,7 @@ int If_CutGetCones( If_Man_t * p ) } } printf( "Cound not find boundary for %d nodes.\n", Counter ); - PRT( "Cones", clock() - clk ); + ABC_PRT( "Cones", clock() - clk ); return 1; } @@ -1406,7 +1406,7 @@ int If_CutCountTotalFanins( If_Man_t * p ) } } printf( "Total cut inputs = %d. Total fanins incremental = %d.\n", nFaninsTotal, Counter ); - PRT( "Fanins", clock() - clk ); + ABC_PRT( "Fanins", clock() - clk ); Vec_IntFree( vLeaves ); return 1; } diff --git a/src/map/if/ifLib.c b/src/map/if/ifLib.c index 51630164..176edb24 100644 --- a/src/map/if/ifLib.c +++ b/src/map/if/ifLib.c @@ -24,7 +24,7 @@ /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// -static inline char * If_UtilStrsav( char *s ) { return !s ? s : strcpy(ALLOC(char, strlen(s)+1), s); } +static inline char * If_UtilStrsav( char *s ) { return !s ? s : strcpy(ABC_ALLOC(char, strlen(s)+1), s); } //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -55,7 +55,7 @@ If_Lib_t * If_LutLibRead( char * FileName ) return NULL; } - p = ALLOC( If_Lib_t, 1 ); + p = ABC_ALLOC( If_Lib_t, 1 ); memset( p, 0, sizeof(If_Lib_t) ); p->pName = If_UtilStrsav( FileName ); @@ -70,7 +70,7 @@ If_Lib_t * If_LutLibRead( char * FileName ) if ( i != atoi(pToken) ) { printf( "Error in the LUT library file \"%s\".\n", FileName ); - free( p ); + ABC_FREE( p ); return NULL; } @@ -145,7 +145,7 @@ If_Lib_t * If_LutLibRead( char * FileName ) If_Lib_t * If_LutLibDup( If_Lib_t * p ) { If_Lib_t * pNew; - pNew = ALLOC( If_Lib_t, 1 ); + pNew = ABC_ALLOC( If_Lib_t, 1 ); *pNew = *p; pNew->pName = If_UtilStrsav( pNew->pName ); return pNew; @@ -166,8 +166,8 @@ void If_LutLibFree( If_Lib_t * pLutLib ) { if ( pLutLib == NULL ) return; - FREE( pLutLib->pName ); - FREE( pLutLib ); + ABC_FREE( pLutLib->pName ); + ABC_FREE( pLutLib ); } diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c index 82ee6728..97f2a06a 100644 --- a/src/map/if/ifMan.c +++ b/src/map/if/ifMan.c @@ -48,7 +48,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) { If_Man_t * p; // start the manager - p = ALLOC( If_Man_t, 1 ); + p = ABC_ALLOC( If_Man_t, 1 ); memset( p, 0, sizeof(If_Man_t) ); p->pPars = pPars; p->fEpsilon = pPars->Epsilon; @@ -71,7 +71,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) printf( "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? ALLOC( unsigned, 4 * p->nTruthWords ) : NULL; + p->puTemp[0] = p->pPars->fTruth? ABC_ALLOC( unsigned, 4 * p->nTruthWords ) : NULL; p->puTemp[1] = p->puTemp[0] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords; @@ -96,7 +96,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) ***********************************************************************/ void If_ManRestart( If_Man_t * p ) { - FREE( p->pMemCi ); + ABC_FREE( p->pMemCi ); Vec_PtrClear( p->vCis ); Vec_PtrClear( p->vCos ); Vec_PtrClear( p->vObjs ); @@ -124,7 +124,7 @@ void If_ManRestart( If_Man_t * p ) ***********************************************************************/ void If_ManStop( If_Man_t * p ) { -// PRT( "Truth", p->timeTruth ); +// ABC_PRT( "Truth", p->timeTruth ); // printf( "Small support = %d.\n", p->nSmallSupp ); Vec_PtrFree( p->vCis ); Vec_PtrFree( p->vCos ); @@ -135,19 +135,19 @@ void If_ManStop( If_Man_t * p ) if ( p->vLatchOrder ) Vec_PtrFree( p->vLatchOrder ); if ( p->vLags ) Vec_IntFree( p->vLags ); Mem_FixedStop( p->pMemObj, 0 ); - FREE( p->pMemCi ); - FREE( p->pMemAnd ); - FREE( p->puTemp[0] ); - // free pars memory + ABC_FREE( p->pMemCi ); + ABC_FREE( p->pMemAnd ); + ABC_FREE( p->puTemp[0] ); + // ABC_FREE pars memory if ( p->pPars->pTimesArr ) - FREE( p->pPars->pTimesArr ); + ABC_FREE( p->pPars->pTimesArr ); if ( p->pPars->pTimesReq ) - FREE( p->pPars->pTimesReq ); + ABC_FREE( p->pPars->pTimesReq ); if ( p->pManTim ) Tim_ManStop( p->pManTim ); if ( p->vSwitching ) Vec_IntFree( p->vSwitching ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -427,7 +427,7 @@ void If_ManSetupCiCutSets( If_Man_t * p ) If_ManForEachCi( p, pObj, i ) If_ManSetupCutTriv( p, &pObj->CutBest, pObj->Id ); // create elementary cutsets for the CIs - p->pMemCi = (If_Set_t *)malloc( If_ManCiNum(p) * (sizeof(If_Set_t) + sizeof(void *)) ); + p->pMemCi = (If_Set_t *)ABC_ALLOC( char, If_ManCiNum(p) * (sizeof(If_Set_t) + sizeof(void *)) ); If_ManForEachCi( p, pObj, i ) { pObj->pCutSet = (If_Set_t *)((char *)p->pMemCi + i * (sizeof(If_Set_t) + sizeof(void *))); @@ -552,7 +552,7 @@ void If_ManSetupSetAll( If_Man_t * p, int nCrossCut ) If_Set_t * pCutSet; int i, nCutSets; nCutSets = 128 + nCrossCut; - p->pFreeList = p->pMemAnd = pCutSet = (If_Set_t *)malloc( nCutSets * p->nSetBytes ); + p->pFreeList = p->pMemAnd = pCutSet = (If_Set_t *)ABC_ALLOC( char, nCutSets * p->nSetBytes ); for ( i = 0; i < nCutSets; i++ ) { If_ManSetupSet( p, pCutSet ); diff --git a/src/map/if/ifMap.c b/src/map/if/ifMap.c index fc3d7cd3..2879081c 100644 --- a/src/map/if/ifMap.c +++ b/src/map/if/ifMap.c @@ -106,7 +106,7 @@ 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 free cut + // get the next ABC_FREE cut assert( pCutSet->nCuts <= pCutSet->nCutsMax ); pCut = pCutSet->ppCuts[pCutSet->nCuts]; // make sure K-feasible cut exists @@ -169,7 +169,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep If_ObjForEachCut( pObj, pCut, i ) p->pPars->pFuncUser( p, pObj, pCut ); - // free the cuts + // ABC_FREE the cuts If_ManDerefNodeCutSet( p, pObj ); } @@ -212,7 +212,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 free cut + // get the next ABC_FREE cut assert( pCutSet->nCuts <= pCutSet->nCutsMax ); pCut = pCutSet->ppCuts[pCutSet->nCuts]; // copy the cut into storage @@ -253,7 +253,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP if ( Mode && pObj->nRefs > 0 ) If_CutAreaRef( p, If_ObjCutBest(pObj) ); - // free the cuts + // ABC_FREE the cuts If_ManDerefChoiceCutSet( p, pObj ); } @@ -342,7 +342,7 @@ int If_ManPerformMappingRound( If_Man_t * p, int nCutsUsed, int Mode, int fPrepr 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. ", Symb, p->RequiredGlo, p->AreaGlo, p->nNets, p->dPower, p->nCutsMerged ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); // printf( "Max number of cuts = %d. Average number of cuts = %5.2f.\n", // p->nCutsMax, 1.0 * p->nCutsMerged / If_ManAndNum(p) ); } diff --git a/src/map/if/ifReduce.c b/src/map/if/ifReduce.c index a5fa7d86..b3130600 100644 --- a/src/map/if/ifReduce.c +++ b/src/map/if/ifReduce.c @@ -57,7 +57,7 @@ void If_ManImproveMapping( If_Man_t * p ) { printf( "E: Del = %7.2f. Ar = %9.1f. Edge = %8d. Switch = %7.2f. Cut = %8d. ", p->RequiredGlo, p->AreaGlo, p->nNets, p->dPower, p->nCutsMerged ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); } /* @@ -68,7 +68,7 @@ void If_ManImproveMapping( If_Man_t * p ) { printf( "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) ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); } */ /* @@ -79,7 +79,7 @@ void If_ManImproveMapping( If_Man_t * p ) { printf( "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) ); - PRT( "T", clock() - clk ); + ABC_PRT( "T", clock() - clk ); } */ } diff --git a/src/map/if/ifUtil.c b/src/map/if/ifUtil.c index 06015b06..1e6d7704 100644 --- a/src/map/if/ifUtil.c +++ b/src/map/if/ifUtil.c @@ -333,7 +333,7 @@ float If_ManScanMapping( If_Man_t * p ) pObj->nRefs = 0; } // allocate place to store the nodes - ppStore = ALLOC( If_Obj_t *, p->nLevelMax + 1 ); + ppStore = ABC_ALLOC( If_Obj_t *, p->nLevelMax + 1 ); memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) ); // collect nodes reachable from POs in the DFS order through the best cuts aArea = 0; @@ -344,7 +344,7 @@ float If_ManScanMapping( If_Man_t * p ) for ( i = p->nLevelMax; i >= 0; i-- ) for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy ) Vec_PtrPush( p->vMapped, pObj ); - free( ppStore ); + ABC_FREE( ppStore ); return aArea; } @@ -374,7 +374,7 @@ float If_ManScanMappingDirect( If_Man_t * p ) pObj->nRefs = 0; } // allocate place to store the nodes - ppStore = ALLOC( If_Obj_t *, p->nLevelMax + 1 ); + ppStore = ABC_ALLOC( If_Obj_t *, p->nLevelMax + 1 ); memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) ); // collect nodes reachable from POs in the DFS order through the best cuts aArea = 0; @@ -386,7 +386,7 @@ float If_ManScanMappingDirect( If_Man_t * p ) for ( i = 0; i <= p->nLevelMax; i++ ) for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy ) Vec_PtrPush( p->vMapped, pObj ); - free( ppStore ); + ABC_FREE( ppStore ); return aArea; } @@ -550,7 +550,7 @@ Vec_Ptr_t * If_ManReverseOrder( If_Man_t * p ) If_Obj_t * pObj, ** ppStore; int i; // allocate place to store the nodes - ppStore = ALLOC( If_Obj_t *, p->nLevelMax + 1 ); + ppStore = ABC_ALLOC( If_Obj_t *, p->nLevelMax + 1 ); memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) ); // add the nodes If_ManForEachObj( p, pObj, i ) @@ -563,7 +563,7 @@ Vec_Ptr_t * If_ManReverseOrder( If_Man_t * p ) for ( i = p->nLevelMax; i >= 0; i-- ) for ( pObj = ppStore[i]; pObj; pObj = pObj->pCopy ) Vec_PtrPush( vOrder, pObj ); - free( ppStore ); + 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 ); diff --git a/src/map/mapper/mapper.h b/src/map/mapper/mapper.h index 673f7538..ac31feac 100644 --- a/src/map/mapper/mapper.h +++ b/src/map/mapper/mapper.h @@ -19,19 +19,18 @@ #ifndef __MAPPER_H__ #define __MAPPER_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -63,10 +62,10 @@ struct Map_TimeStruct_t_ /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#define Map_IsComplement(p) (((int)((PORT_PTRUINT_T) (p) & 01))) -#define Map_Regular(p) ((Map_Node_t *)((PORT_PTRUINT_T)(p) & ~01)) -#define Map_Not(p) ((Map_Node_t *)((PORT_PTRUINT_T)(p) ^ 01)) -#define Map_NotCond(p,c) ((Map_Node_t *)((PORT_PTRUINT_T)(p) ^ (c))) +#define Map_IsComplement(p) (((int)((ABC_PTRUINT_T) (p) & 01))) +#define Map_Regular(p) ((Map_Node_t *)((ABC_PTRUINT_T)(p) & ~01)) +#define Map_Not(p) ((Map_Node_t *)((ABC_PTRUINT_T)(p) ^ 01)) +#define Map_NotCond(p,c) ((Map_Node_t *)((ABC_PTRUINT_T)(p) ^ (c))) //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// diff --git a/src/map/mapper/mapperCore.c b/src/map/mapper/mapperCore.c index 5d4854e6..fc0d9609 100644 --- a/src/map/mapper/mapperCore.c +++ b/src/map/mapper/mapperCore.c @@ -70,7 +70,7 @@ int Map_Mapping( Map_Man_t * p ) Map_MappingTruths( p ); p->timeTruth = clock() - clk; ////////////////////////////////////////////////////////////////////// -//PRT( "Truths", clock() - clk ); +//ABC_PRT( "Truths", clock() - clk ); ////////////////////////////////////////////////////////////////////// // compute the minimum-delay mapping @@ -88,7 +88,7 @@ printf( "Delay : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", fShowSwitching? "Switch" : "Delay", fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, Map_MappingGetAreaFlow(p), p->AreaBase, 0.0 ); -PRT( "Time", p->timeMatch ); +ABC_PRT( "Time", p->timeMatch ); } ////////////////////////////////////////////////////////////////////// @@ -119,7 +119,7 @@ printf( "AreaFlow : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, Map_MappingGetAreaFlow(p), p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } p->timeArea += clock() - clk; @@ -145,7 +145,7 @@ printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 0.0, p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } p->timeArea += clock() - clk; @@ -171,7 +171,7 @@ printf( "Area : %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 0.0, p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } p->timeArea += clock() - clk; @@ -197,7 +197,7 @@ printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 0.0, p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } // compute the required times @@ -215,7 +215,7 @@ printf( "Switching: %s = %8.2f Flow = %11.1f Area = %11.1f %4.1f %% ", fShowSwitching? Map_MappingGetSwitching(p,p->vMapping) : p->fRequiredGlo, 0.0, p->AreaFinal, 100.0*(p->AreaBase-p->AreaFinal)/p->AreaBase ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } } p->timeArea += clock() - clk; diff --git a/src/map/mapper/mapperCreate.c b/src/map/mapper/mapperCreate.c index 0a971542..ee2b089c 100644 --- a/src/map/mapper/mapperCreate.c +++ b/src/map/mapper/mapperCreate.c @@ -27,7 +27,7 @@ static void Map_TableResize( Map_Man_t * p ); static Map_Node_t * Map_TableLookup( Map_Man_t * p, Map_Node_t * p1, Map_Node_t * p2 ); // hash key for the structural hash table -static inline unsigned Map_HashKey2( Map_Node_t * p0, Map_Node_t * p1, int TableSize ) { return (unsigned)(((PORT_PTRUINT_T)(p0) + (PORT_PTRUINT_T)(p1) * 12582917) % TableSize); } +static inline unsigned Map_HashKey2( Map_Node_t * p0, Map_Node_t * p1, int TableSize ) { return (unsigned)(((ABC_PTRUINT_T)(p0) + (ABC_PTRUINT_T)(p1) * 12582917) % TableSize); } //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// @@ -190,7 +190,7 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose ) } // start the manager - p = ALLOC( Map_Man_t, 1 ); + p = ABC_ALLOC( Map_Man_t, 1 ); memset( p, 0, sizeof(Map_Man_t) ); p->pSuperLib = Abc_FrameReadLibSuper(); p->nVarsMax = p->pSuperLib->nVarsMax; @@ -220,13 +220,13 @@ Map_Man_t * Map_ManCreate( int nInputs, int nOutputs, int fVerbose ) // create the PI nodes p->nInputs = nInputs; - p->pInputs = ALLOC( Map_Node_t *, nInputs ); + p->pInputs = ABC_ALLOC( Map_Node_t *, nInputs ); for ( i = 0; i < nInputs; i++ ) p->pInputs[i] = Map_NodeCreate( p, NULL, NULL ); // create the place for the output nodes p->nOutputs = nOutputs; - p->pOutputs = ALLOC( Map_Node_t *, nOutputs ); + p->pOutputs = ABC_ALLOC( Map_Node_t *, nOutputs ); memset( p->pOutputs, 0, sizeof(Map_Node_t *) * nOutputs ); return p; } @@ -258,17 +258,17 @@ void Map_ManFree( Map_Man_t * p ) Map_NodeVecFree( p->vMapping ); if ( p->vVisited ) Map_NodeVecFree( p->vVisited ); - if ( p->uCanons ) free( p->uCanons ); - if ( p->uPhases ) free( p->uPhases ); - if ( p->pCounters ) free( p->pCounters ); + if ( p->uCanons ) ABC_FREE( p->uCanons ); + if ( p->uPhases ) ABC_FREE( p->uPhases ); + if ( p->pCounters ) ABC_FREE( p->pCounters ); Extra_MmFixedStop( p->mmNodes ); Extra_MmFixedStop( p->mmCuts ); - FREE( p->pInputArrivals ); - FREE( p->pInputs ); - FREE( p->pOutputs ); - FREE( p->pBins ); - FREE( p->ppOutputNames ); - FREE( p ); + ABC_FREE( p->pInputArrivals ); + ABC_FREE( p->pInputs ); + ABC_FREE( p->pOutputs ); + ABC_FREE( p->pBins ); + ABC_FREE( p->ppOutputNames ); + ABC_FREE( p ); } @@ -287,17 +287,17 @@ void Map_ManPrintTimeStats( Map_Man_t * p ) { printf( "N-canonical = %d. Matchings = %d. Phases = %d. ", p->nCanons, p->nMatches, p->nPhases ); printf( "Choice nodes = %d. Choices = %d.\n", p->nChoiceNodes, p->nChoices ); - PRT( "ToMap", p->timeToMap ); - PRT( "Cuts ", p->timeCuts ); - PRT( "Truth", p->timeTruth ); - PRT( "Match", p->timeMatch ); - PRT( "Area ", p->timeArea ); - PRT( "Sweep", p->timeSweep ); - PRT( "ToNet", p->timeToNet ); - PRT( "TOTAL", p->timeTotal ); - if ( p->time1 ) { PRT( "time1", p->time1 ); } - if ( p->time2 ) { PRT( "time2", p->time2 ); } - if ( p->time3 ) { PRT( "time3", p->time3 ); } + ABC_PRT( "ToMap", p->timeToMap ); + ABC_PRT( "Cuts ", p->timeCuts ); + ABC_PRT( "Truth", p->timeTruth ); + ABC_PRT( "Match", p->timeMatch ); + ABC_PRT( "Area ", p->timeArea ); + ABC_PRT( "Sweep", p->timeSweep ); + ABC_PRT( "ToNet", p->timeToNet ); + ABC_PRT( "TOTAL", p->timeTotal ); + if ( p->time1 ) { ABC_PRT( "time1", p->time1 ); } + if ( p->time2 ) { ABC_PRT( "time2", p->time2 ); } + if ( p->time3 ) { ABC_PRT( "time3", p->time3 ); } } /**Function************************************************************* @@ -388,7 +388,7 @@ void Map_TableCreate( Map_Man_t * pMan ) { assert( pMan->pBins == NULL ); pMan->nBins = Cudd_Prime(5000); - pMan->pBins = ALLOC( Map_Node_t *, pMan->nBins ); + pMan->pBins = ABC_ALLOC( Map_Node_t *, pMan->nBins ); memset( pMan->pBins, 0, sizeof(Map_Node_t *) * pMan->nBins ); pMan->nNodes = 0; } @@ -473,7 +473,7 @@ clk = clock(); // get the new table size nBinsNew = Cudd_Prime(2 * pMan->nBins); // allocate a new array - pBinsNew = ALLOC( Map_Node_t *, nBinsNew ); + pBinsNew = ABC_ALLOC( Map_Node_t *, nBinsNew ); memset( pBinsNew, 0, sizeof(Map_Node_t *) * nBinsNew ); // rehash the entries from the old table Counter = 0; @@ -490,10 +490,10 @@ clk = clock(); if ( pMan->fVerbose ) { // printf( "Increasing the unique table size from %6d to %6d. ", pMan->nBins, nBinsNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); } // replace the table and the parameters - free( pMan->pBins ); + ABC_FREE( pMan->pBins ); pMan->pBins = pBinsNew; pMan->nBins = nBinsNew; } diff --git a/src/map/mapper/mapperCut.c b/src/map/mapper/mapperCut.c index 46405547..00ec9fe5 100644 --- a/src/map/mapper/mapperCut.c +++ b/src/map/mapper/mapperCut.c @@ -151,7 +151,7 @@ void Map_MappingCuts( Map_Man_t * p ) nCuts = Map_MappingCountAllCuts(p); printf( "Nodes = %6d. Total %d-feasible cuts = %10d. Per node = %.1f. ", p->nNodes, p->nVarsMax, nCuts, ((float)nCuts)/p->nNodes ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // print the cuts for the first primary output @@ -809,15 +809,15 @@ Map_CutTable_t * Map_CutTableStart( Map_Man_t * pMan ) { Map_CutTable_t * p; // allocate the table - p = ALLOC( Map_CutTable_t, 1 ); + p = ABC_ALLOC( Map_CutTable_t, 1 ); memset( p, 0, sizeof(Map_CutTable_t) ); p->nBins = Cudd_Prime( 10 * MAP_CUTS_MAX_COMPUTE ); - p->pBins = ALLOC( Map_Cut_t *, p->nBins ); + p->pBins = ABC_ALLOC( Map_Cut_t *, p->nBins ); memset( p->pBins, 0, sizeof(Map_Cut_t *) * p->nBins ); - p->pCuts = ALLOC( int, 2 * MAP_CUTS_MAX_COMPUTE ); - p->pArray = ALLOC( Map_Cut_t *, 2 * MAP_CUTS_MAX_COMPUTE ); - p->pCuts1 = ALLOC( Map_Cut_t *, 2 * MAP_CUTS_MAX_COMPUTE ); - p->pCuts2 = ALLOC( Map_Cut_t *, 2 * MAP_CUTS_MAX_COMPUTE ); + p->pCuts = ABC_ALLOC( int, 2 * MAP_CUTS_MAX_COMPUTE ); + p->pArray = ABC_ALLOC( Map_Cut_t *, 2 * MAP_CUTS_MAX_COMPUTE ); + p->pCuts1 = ABC_ALLOC( Map_Cut_t *, 2 * MAP_CUTS_MAX_COMPUTE ); + p->pCuts2 = ABC_ALLOC( Map_Cut_t *, 2 * MAP_CUTS_MAX_COMPUTE ); return p; } @@ -834,12 +834,12 @@ Map_CutTable_t * Map_CutTableStart( Map_Man_t * pMan ) ***********************************************************************/ void Map_CutTableStop( Map_CutTable_t * p ) { - free( p->pCuts1 ); - free( p->pCuts2 ); - free( p->pArray ); - free( p->pBins ); - free( p->pCuts ); - free( p ); + ABC_FREE( p->pCuts1 ); + ABC_FREE( p->pCuts2 ); + ABC_FREE( p->pArray ); + ABC_FREE( p->pBins ); + ABC_FREE( p->pCuts ); + ABC_FREE( p ); } /**Function************************************************************* @@ -1005,7 +1005,7 @@ Map_Cut_t * Map_CutSortCuts( Map_Man_t * pMan, Map_CutTable_t * p, Map_Cut_t * p // move them back into the list if ( nCuts > MAP_CUTS_MAX_USE - 1 ) { - // free the remaining cuts + // ABC_FREE the remaining cuts for ( i = MAP_CUTS_MAX_USE - 1; i < nCuts; i++ ) Extra_MmFixedEntryRecycle( pMan->mmCuts, (char *)p->pCuts1[i] ); // update the number of cuts diff --git a/src/map/mapper/mapperInt.h b/src/map/mapper/mapperInt.h index 00550deb..7f4c93dc 100644 --- a/src/map/mapper/mapperInt.h +++ b/src/map/mapper/mapperInt.h @@ -60,10 +60,10 @@ #define MAP_RANDOM_UNSIGNED ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand())) // internal macros to work with cuts -#define Map_CutIsComplement(p) (((int)((PORT_PTRUINT_T) (p) & 01))) -#define Map_CutRegular(p) ((Map_Cut_t *)((PORT_PTRUINT_T)(p) & ~01)) -#define Map_CutNot(p) ((Map_Cut_t *)((PORT_PTRUINT_T)(p) ^ 01)) -#define Map_CutNotCond(p,c) ((Map_Cut_t *)((PORT_PTRUINT_T)(p) ^ (c))) +#define Map_CutIsComplement(p) (((int)((ABC_PTRUINT_T) (p) & 01))) +#define Map_CutRegular(p) ((Map_Cut_t *)((ABC_PTRUINT_T)(p) & ~01)) +#define Map_CutNot(p) ((Map_Cut_t *)((ABC_PTRUINT_T)(p) ^ 01)) +#define Map_CutNotCond(p,c) ((Map_Cut_t *)((ABC_PTRUINT_T)(p) ^ (c))) // internal macros for referencing of nodes #define Map_NodeReadRef(p) ((Map_Regular(p))->nRefs) diff --git a/src/map/mapper/mapperLib.c b/src/map/mapper/mapperLib.c index 9c47ed03..942caa8e 100644 --- a/src/map/mapper/mapperLib.c +++ b/src/map/mapper/mapperLib.c @@ -56,7 +56,7 @@ Map_SuperLib_t * Map_SuperLibCreate( char * pFileName, char * pExcludeFile, bool int clk; // start the supergate library - p = ALLOC( Map_SuperLib_t, 1 ); + p = ABC_ALLOC( Map_SuperLib_t, 1 ); memset( p, 0, sizeof(Map_SuperLib_t) ); p->pName = pFileName; p->fVerbose = fVerbose; @@ -98,7 +98,7 @@ clk = clock(); if ( fVerbose ) { printf( "Loaded %d unique %d-input supergates from \"%s\". ", p->nSupersReal, p->nVarsMax, pFileName ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } // assign the interver parameters @@ -155,8 +155,8 @@ void Map_SuperLibFree( Map_SuperLib_t * p ) Extra_MmFixedStop( p->mmSupers ); Extra_MmFixedStop( p->mmEntries ); Extra_MmFlexStop( p->mmForms ); - FREE( p->ppSupers ); - FREE( p ); + ABC_FREE( p->ppSupers ); + ABC_FREE( p ); } /**Function************************************************************* @@ -192,7 +192,7 @@ int Map_SuperLibDeriveFromGenlib( Mio_Library_t * pLib ) // get the file name with the library pNameGeneric = Extra_FileNameGeneric( Mio_LibraryReadName(pLib) ); sprintf( FileNameSuper, "%s.super", pNameGeneric ); - free( pNameGeneric ); + ABC_FREE( pNameGeneric ); sprintf( CommandSuper, "super -l 1 -i 5 -d 10000000 -a 10000000 -t 100 %s", FileNameGenlib ); if ( Cmd_CommandExecute( pAbc, CommandSuper ) ) diff --git a/src/map/mapper/mapperRefs.c b/src/map/mapper/mapperRefs.c index a50b134a..852e759f 100644 --- a/src/map/mapper/mapperRefs.c +++ b/src/map/mapper/mapperRefs.c @@ -430,7 +430,7 @@ void Map_MappingSetRefs( Map_Man_t * pMan ) LevelMax = Map_Regular(pMan->pOutputs[i])->Level; // allocate place to store the nodes - ppStore = ALLOC( Map_Node_t *, LevelMax + 1 ); + ppStore = ABC_ALLOC( Map_Node_t *, LevelMax + 1 ); memset( ppStore, 0, sizeof(Map_Node_t *) * (LevelMax + 1) ); // visit nodes reachable from POs in the DFS order through the best cuts @@ -447,7 +447,7 @@ void Map_MappingSetRefs( Map_Man_t * pMan ) for ( i = LevelMax; i >= 0; i-- ) for ( pNode = ppStore[i]; pNode; pNode = (Map_Node_t *)pNode->pData0 ) Map_NodeVecPush( pMan->vMapping, pNode ); - free( ppStore ); + ABC_FREE( ppStore ); } /**Function************************************************************* diff --git a/src/map/mapper/mapperTable.c b/src/map/mapper/mapperTable.c index 3feba352..a0805991 100644 --- a/src/map/mapper/mapperTable.c +++ b/src/map/mapper/mapperTable.c @@ -46,12 +46,12 @@ Map_HashTable_t * Map_SuperTableCreate( Map_SuperLib_t * pLib ) { Map_HashTable_t * p; // allocate the table - p = ALLOC( Map_HashTable_t, 1 ); + p = ABC_ALLOC( Map_HashTable_t, 1 ); memset( p, 0, sizeof(Map_HashTable_t) ); p->mmMan = pLib->mmEntries; // allocate and clean the bins p->nBins = Cudd_Prime(20000); - p->pBins = ALLOC( Map_HashEntry_t *, p->nBins ); + p->pBins = ABC_ALLOC( Map_HashEntry_t *, p->nBins ); memset( p->pBins, 0, sizeof(Map_HashEntry_t *) * p->nBins ); return p; } @@ -70,8 +70,8 @@ Map_HashTable_t * Map_SuperTableCreate( Map_SuperLib_t * pLib ) ***********************************************************************/ void Map_SuperTableFree( Map_HashTable_t * p ) { - FREE( p->pBins ); - FREE( p ); + ABC_FREE( p->pBins ); + ABC_FREE( p ); } /**Function************************************************************* @@ -236,7 +236,7 @@ void Map_SuperTableResize( Map_HashTable_t * p ) // get the new table size nBinsNew = Cudd_Prime(2 * p->nBins); // allocate a new array - pBinsNew = ALLOC( Map_HashEntry_t *, nBinsNew ); + pBinsNew = ABC_ALLOC( Map_HashEntry_t *, nBinsNew ); memset( pBinsNew, 0, sizeof(Map_HashEntry_t *) * nBinsNew ); // rehash the entries from the old table Counter = 0; @@ -251,7 +251,7 @@ void Map_SuperTableResize( Map_HashTable_t * p ) } assert( Counter == p->nEntries ); // replace the table and the parameters - free( p->pBins ); + ABC_FREE( p->pBins ); p->pBins = pBinsNew; p->nBins = nBinsNew; } @@ -317,7 +317,7 @@ void Map_SuperTableSortSupergates( Map_HashTable_t * p, int nSupersMax ) int nSupers, i; // copy all the supergates into one array - ppSupers = ALLOC( Map_Super_t *, nSupersMax ); + ppSupers = ABC_ALLOC( Map_Super_t *, nSupersMax ); nSupers = 0; for ( i = 0; i < p->nBins; i++ ) for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext ) @@ -342,7 +342,7 @@ void Map_SuperTableSortSupergates( Map_HashTable_t * p, int nSupersMax ) printf( "%s", ppSupers[i]->pFormula ); printf( "\n" ); } - free( ppSupers ); + ABC_FREE( ppSupers ); } /**Function************************************************************* @@ -363,7 +363,7 @@ void Map_SuperTableSortSupergatesByDelay( Map_HashTable_t * p, int nSupersMax ) Map_Super_t * pSuper; int nSupers, i, k; - ppSupers = ALLOC( Map_Super_t *, nSupersMax ); + ppSupers = ABC_ALLOC( Map_Super_t *, nSupersMax ); for ( i = 0; i < p->nBins; i++ ) for ( pEnt = p->pBins[i]; pEnt; pEnt = pEnt->pNext ) { @@ -392,7 +392,7 @@ void Map_SuperTableSortSupergatesByDelay( Map_HashTable_t * p, int nSupersMax ) // save the number of supergates in the list pEnt->pGates->nSupers = nSupers; } - FREE( ppSupers ); + ABC_FREE( ppSupers ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/map/mapper/mapperTree.c b/src/map/mapper/mapperTree.c index 6e69bc69..4cabf86c 100644 --- a/src/map/mapper/mapperTree.c +++ b/src/map/mapper/mapperTree.c @@ -198,7 +198,7 @@ int Map_LibraryReadFileTree( Map_SuperLib_t * pLib, FILE * pFile, char *pFileNam } // allocate room for supergate pointers - pLib->ppSupers = ALLOC( Map_Super_t *, pLib->nLines + 10000 ); + pLib->ppSupers = ABC_ALLOC( Map_Super_t *, pLib->nLines + 10000 ); // create the elementary supergates for ( i = 0; i < pLib->nVarsMax; i++ ) diff --git a/src/map/mapper/mapperVec.c b/src/map/mapper/mapperVec.c index f75138fb..f675e0c5 100644 --- a/src/map/mapper/mapperVec.c +++ b/src/map/mapper/mapperVec.c @@ -42,12 +42,12 @@ static int Map_NodeVecCompareLevels( Map_Node_t ** pp1, Map_Node_t ** pp2 ); Map_NodeVec_t * Map_NodeVecAlloc( int nCap ) { Map_NodeVec_t * p; - p = ALLOC( Map_NodeVec_t, 1 ); + p = ABC_ALLOC( Map_NodeVec_t, 1 ); if ( nCap > 0 && nCap < 16 ) nCap = 16; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( Map_Node_t *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( Map_Node_t *, p->nCap ) : NULL; return p; } @@ -64,8 +64,8 @@ Map_NodeVec_t * Map_NodeVecAlloc( int nCap ) ***********************************************************************/ void Map_NodeVecFree( Map_NodeVec_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -115,7 +115,7 @@ void Map_NodeVecGrow( Map_NodeVec_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( Map_Node_t *, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( Map_Node_t *, p->pArray, nCapMin ); p->nCap = nCapMin; } diff --git a/src/map/mio/mio.c b/src/map/mio/mio.c index 1326dbbf..b7dd2895 100644 --- a/src/map/mio/mio.c +++ b/src/map/mio/mio.c @@ -27,6 +27,7 @@ #include "mainInt.h" #include "mioInt.h" #include "mapper.h" +#include "amap.h" extern void Amap_LibFree( void * p ); extern void Amap_LibPrintSelectedGates( void * p, int fAllGates ); @@ -36,6 +37,8 @@ extern void * Amap_LibReadAndPrepare( char * pFileName, int fVerbose, int fVeryV /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// +static int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ); + static int Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ); static int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ); @@ -106,6 +109,8 @@ void Mio_Init( Abc_Frame_t * pAbc ) unlink( pFileTemp ); #endif + Cmd_CommandAdd( pAbc, "SC mapping", "read_liberty", Mio_CommandReadLiberty, 0 ); + Cmd_CommandAdd( pAbc, "SC mapping", "read_library", Mio_CommandReadLibrary, 0 ); Cmd_CommandAdd( pAbc, "SC mapping", "print_library", Mio_CommandPrintLibrary, 0 ); @@ -132,6 +137,82 @@ void Mio_End() } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ) +{ + FILE * pFile; + FILE * pOut, * pErr; + Abc_Ntk_t * pNet; + char * FileName; + int fVerbose; + int c; + + pNet = Abc_FrameReadNtk(pAbc); + pOut = Abc_FrameReadOut(pAbc); + pErr = Abc_FrameReadErr(pAbc); + + // set the defaults + fVerbose = 1; + Extra_UtilGetoptReset(); + while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) + { + switch (c) + { + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + break; + default: + goto usage; + } + } + + + if ( argc != globalUtilOptind + 1 ) + { + goto usage; + } + + // get the input file name + FileName = argv[globalUtilOptind]; + if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL ) + { + fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); + if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) + fprintf( pErr, "Did you mean \"%s\"?", FileName ); + fprintf( pErr, "\n" ); + return 1; + } + fclose( pFile ); + + if ( !Amap_LibertyParse( FileName, "temp.genlib", fVerbose ) ) + return 0; + Cmd_CommandExecute( pAbc, "read_library temp.genlib" ); + return 0; + +usage: + fprintf( pErr, "usage: read_liberty [-vh]\n"); + fprintf( pErr, "\t read standard cell library in Liberty format\n" ); + fprintf( pErr, "\t (if the library contains more than one gate\n" ); + fprintf( pErr, "\t with the same Boolean function, only the gate\n" ); + fprintf( pErr, "\t with the smallest area will be used)\n" ); + fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); + fprintf( pErr, "\t-h : enable verbose output\n"); + return 1; /* error exit */ +} + /**Function************************************************************* Synopsis [] diff --git a/src/map/mio/mio.h b/src/map/mio/mio.h index 0e5a39d3..66fea292 100644 --- a/src/map/mio/mio.h +++ b/src/map/mio/mio.h @@ -19,10 +19,6 @@ #ifndef __MIO_H__ #define __MIO_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -31,6 +27,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/map/mio/mioFunc.c b/src/map/mio/mioFunc.c index 1fca5764..a06151f0 100644 --- a/src/map/mio/mioFunc.c +++ b/src/map/mio/mioFunc.c @@ -144,7 +144,7 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate ) { // get the topmost (generic) pin pPin = pGate->pPins; - FREE( pPin->pName ); + ABC_FREE( pPin->pName ); // create individual pins from the generic pin ppPin = &pPin->pNext; @@ -173,10 +173,10 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate ) { if ( pPinNames[i] && strcmp( pPinNames[i], pPin->pName ) == 0 ) { - // free pPinNames[i] because it is already available as pPin->pName + // ABC_FREE pPinNames[i] because it is already available as pPin->pName // setting pPinNames[i] to NULL is useful to make sure that // this name is not assigned to two pins in the list - FREE( pPinNames[i] ); + ABC_FREE( pPinNames[i] ); pPinNamesCopy[iPin++] = pPin->pName; break; } @@ -212,6 +212,8 @@ int Mio_GateParseFormula( Mio_Gate_t * pGate ) // derive the formula as the BDD pGate->bFunc = Parse_FormulaParser( stdout, pGate->pForm, nPins, 0, pPinNames, dd, dd->vars ); + if ( pGate->bFunc == NULL ) + return 1; Cudd_Ref( pGate->bFunc ); // derive the cover (SOP) diff --git a/src/map/mio/mioRead.c b/src/map/mio/mioRead.c index ae33c942..fdb340aa 100644 --- a/src/map/mio/mioRead.c +++ b/src/map/mio/mioRead.c @@ -94,7 +94,7 @@ Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, bool fE char * pBuffer = 0; // allocate the genlib structure - pLib = ALLOC( Mio_Library_t, 1 ); + pLib = ABC_ALLOC( Mio_Library_t, 1 ); memset( pLib, 0, sizeof(Mio_Library_t) ); pLib->pName = Extra_UtilStrsav( FileName ); pLib->tName2Gate = st_init_table(strcmp, st_strhash); @@ -122,7 +122,7 @@ Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, bool fE // move the file current reading position to the beginning rewind( pFile ); // load the contents of the file into memory - pBuffer = ALLOC( char, nFileSize + 10 ); + pBuffer = ABC_ALLOC( char, nFileSize + 10 ); fread( pBuffer, nFileSize, 1, pFile ); // terminate the string with '\0' pBuffer[ nFileSize ] = '\0'; @@ -137,10 +137,10 @@ Mio_Library_t * Mio_LibraryReadOne( Abc_Frame_t * pAbc, char * FileName, bool fE if ( Mio_LibraryReadInternal( pLib, pBuffer, fExtendedFormat, tExcludeGate, fVerbose ) ) { Mio_LibraryDelete( pLib ); - free( pBuffer ); + ABC_FREE( pBuffer ); return NULL; } - free( pBuffer ); + ABC_FREE( pBuffer ); // derive the functinality of gates if ( Mio_LibraryParseFormulas( pLib ) ) @@ -243,7 +243,7 @@ Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, bool fExtendedFormat ) char * pToken = *ppToken; // allocate the gate structure - pGate = ALLOC( Mio_Gate_t, 1 ); + pGate = ABC_ALLOC( Mio_Gate_t, 1 ); memset( pGate, 0, sizeof(Mio_Gate_t) ); // read the name @@ -311,7 +311,7 @@ Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, bool fExtendedFormat ) char * pToken = *ppToken; // allocate the gate structure - pPin = ALLOC( Mio_Pin_t, 1 ); + pPin = ABC_ALLOC( Mio_Pin_t, 1 ); memset( pPin, 0, sizeof(Mio_Pin_t) ); // read the name @@ -397,7 +397,7 @@ char * chomp( char *s ) if ( !isspace(*b) ) break; // strsav the string - a = strcpy( ALLOC(char, strlen(b)+1), b ); + a = strcpy( ABC_ALLOC(char, strlen(b)+1), b ); // remove trailing spaces for ( c = a+strlen(a); c > a; c-- ) if ( *c == 0 || isspace(*c) ) @@ -464,12 +464,12 @@ void Mio_LibrarySortGates( Mio_Library_t * pLib ) { Mio_Gate_t ** ppGates, * pGate; int i = 0; - ppGates = ALLOC( Mio_Gate_t *, pLib->nGates ); + ppGates = ABC_ALLOC( Mio_Gate_t *, pLib->nGates ); Mio_LibraryForEachGate( pLib, pGate ) ppGates[i++] = pGate; assert( i == pLib->nGates ); // sort gates by area - pLib->ppGates0 = ALLOC( Mio_Gate_t *, pLib->nGates ); + pLib->ppGates0 = ABC_ALLOC( Mio_Gate_t *, pLib->nGates ); for ( i = 0; i < pLib->nGates; i++ ) pLib->ppGates0[i] = ppGates[i]; qsort( (void *)ppGates, pLib->nGates, sizeof(void *), @@ -477,9 +477,9 @@ void Mio_LibrarySortGates( Mio_Library_t * pLib ) for ( i = 0; i < pLib->nGates; i++ ) ppGates[i]->pNext = (i < pLib->nGates-1)? ppGates[i+1] : NULL; pLib->pGates = ppGates[0]; - free( ppGates ); + ABC_FREE( ppGates ); // sort gates by name - pLib->ppGatesName = ALLOC( Mio_Gate_t *, pLib->nGates ); + pLib->ppGatesName = ABC_ALLOC( Mio_Gate_t *, pLib->nGates ); for ( i = 0; i < pLib->nGates; i++ ) pLib->ppGatesName[i] = pLib->ppGates0[i]; qsort( (void *)pLib->ppGatesName, pLib->nGates, sizeof(void *), diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c index 2a1d1f30..3f42d2bb 100644 --- a/src/map/mio/mioUtils.c +++ b/src/map/mio/mioUtils.c @@ -47,10 +47,10 @@ void Mio_LibraryDelete( Mio_Library_t * pLib ) Mio_Gate_t * pGate, * pGate2; if ( pLib == NULL ) return; - // free the bindings of nodes to gates from this library for all networks + // ABC_FREE the bindings of nodes to gates from this library for all networks Abc_FrameUnmapAllNetworks( Abc_FrameGetGlobalFrame() ); - // free the library - FREE( pLib->pName ); + // ABC_FREE the library + ABC_FREE( pLib->pName ); Mio_LibraryForEachGateSafe( pLib, pGate, pGate2 ) Mio_GateDelete( pGate ); Extra_MmFlexStop( pLib->pMmFlex ); @@ -59,9 +59,9 @@ void Mio_LibraryDelete( Mio_Library_t * pLib ) st_free_table( pLib->tName2Gate ); if ( pLib->dd ) Cudd_Quit( pLib->dd ); - FREE( pLib->ppGates0 ); - FREE( pLib->ppGatesName ); - free( pLib ); + ABC_FREE( pLib->ppGates0 ); + ABC_FREE( pLib->ppGatesName ); + ABC_FREE( pLib ); } /**Function************************************************************* @@ -78,14 +78,14 @@ void Mio_LibraryDelete( Mio_Library_t * pLib ) void Mio_GateDelete( Mio_Gate_t * pGate ) { Mio_Pin_t * pPin, * pPin2; - FREE( pGate->pOutName ); - FREE( pGate->pName ); - FREE( pGate->pForm ); + ABC_FREE( pGate->pOutName ); + ABC_FREE( pGate->pName ); + ABC_FREE( pGate->pForm ); if ( pGate->bFunc ) Cudd_RecursiveDeref( pGate->pLib->dd, pGate->bFunc ); Mio_GateForEachPinSafe( pGate, pPin, pPin2 ) Mio_PinDelete( pPin ); - free( pGate ); + ABC_FREE( pGate ); } /**Function************************************************************* @@ -101,8 +101,8 @@ void Mio_GateDelete( Mio_Gate_t * pGate ) ***********************************************************************/ void Mio_PinDelete( Mio_Pin_t * pPin ) { - FREE( pPin->pName ); - free( pPin ); + ABC_FREE( pPin->pName ); + ABC_FREE( pPin ); } /**Function************************************************************* @@ -120,7 +120,7 @@ Mio_Pin_t * Mio_PinDup( Mio_Pin_t * pPin ) { Mio_Pin_t * pPinNew; - pPinNew = ALLOC( Mio_Pin_t, 1 ); + pPinNew = ABC_ALLOC( Mio_Pin_t, 1 ); *pPinNew = *pPin; pPinNew->pName = (pPinNew->pName ? Extra_UtilStrsav(pPinNew->pName) : NULL); pPinNew->pNext = NULL; @@ -256,7 +256,7 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, } // collect the gates into the array - ppGates = ALLOC( Mio_Gate_t *, nGates ); + ppGates = ABC_ALLOC( Mio_Gate_t *, nGates ); iGate = 0; st_foreach_item( tFuncs, gen, (char **)&bFunc, (char **)&pGate ) ppGates[ iGate++ ] = pGate; @@ -265,7 +265,7 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, */ - ppGates = ALLOC( Mio_Gate_t *, nGates ); + ppGates = ABC_ALLOC( Mio_Gate_t *, nGates ); iGate = 0; Mio_LibraryForEachGate( pLib, pGate ) { @@ -515,13 +515,13 @@ Mio_Gate_t * Mio_GateCreatePseudo( int nInputs ) Mio_Pin_t * pPin; int i; // allocate the gate structure - pGate = ALLOC( Mio_Gate_t, 1 ); + pGate = ABC_ALLOC( Mio_Gate_t, 1 ); memset( pGate, 0, sizeof(Mio_Gate_t) ); pGate->nInputs = nInputs; // create pins for ( i = 0; i < nInputs; i++ ) { - pPin = ALLOC( Mio_Pin_t, 1 ); + pPin = ABC_ALLOC( Mio_Pin_t, 1 ); memset( pPin, 0, sizeof(Mio_Pin_t) ); pPin->pNext = pGate->pPins; pGate->pPins = pPin; diff --git a/src/map/super/super.h b/src/map/super/super.h index a7169924..9f5e83ae 100644 --- a/src/map/super/super.h +++ b/src/map/super/super.h @@ -19,10 +19,6 @@ #ifndef __SUPER_H__ #define __SUPER_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -31,6 +27,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/map/super/superAnd.c b/src/map/super/superAnd.c index 8e831952..3014d505 100644 --- a/src/map/super/superAnd.c +++ b/src/map/super/superAnd.c @@ -61,10 +61,10 @@ struct Super2_GateStruct_t_ // manipulation of complemented attributes -#define Super2_IsComplement(p) (((int)((PORT_PTRUINT_T) (p) & 01))) -#define Super2_Regular(p) ((Super2_Gate_t *)((PORT_PTRUINT_T)(p) & ~01)) -#define Super2_Not(p) ((Super2_Gate_t *)((PORT_PTRUINT_T)(p) ^ 01)) -#define Super2_NotCond(p,c) ((Super2_Gate_t *)((PORT_PTRUINT_T)(p) ^ (c))) +#define Super2_IsComplement(p) (((int)((ABC_PTRUINT_T) (p) & 01))) +#define Super2_Regular(p) ((Super2_Gate_t *)((ABC_PTRUINT_T)(p) & ~01)) +#define Super2_Not(p) ((Super2_Gate_t *)((ABC_PTRUINT_T)(p) ^ 01)) +#define Super2_NotCond(p,c) ((Super2_Gate_t *)((ABC_PTRUINT_T)(p) ^ (c))) // iterating through the gates in the library #define Super2_LibForEachGate( Lib, Gate ) \ @@ -132,7 +132,7 @@ clk = clock(); Super2_LibStop( pLibCur ); pLibCur = pLibNext; printf( "Level %d: Tried = %7d. Computed = %7d. ", Level, pMan->nTried, pLibCur->nGates ); -PRT( "Runtime", clock() - clk ); +ABC_PRT( "Runtime", clock() - clk ); fflush( stdout ); } @@ -163,7 +163,7 @@ fflush( stdout ); Super2_Man_t * Super2_ManStart() { Super2_Man_t * pMan; - pMan = ALLOC( Super2_Man_t, 1 ); + pMan = ABC_ALLOC( Super2_Man_t, 1 ); memset( pMan, 0, sizeof(Super2_Man_t) ); pMan->pMem = Extra_MmFixedStart( sizeof(Super2_Gate_t) ); pMan->tTable = stmm_init_table( st_ptrcmp, st_ptrhash ); @@ -185,7 +185,7 @@ void Super2_ManStop( Super2_Man_t * pMan ) { Extra_MmFixedStop( pMan->pMem ); stmm_free_table( pMan->tTable ); - free( pMan ); + ABC_FREE( pMan ); } /**Function************************************************************* @@ -202,7 +202,7 @@ void Super2_ManStop( Super2_Man_t * pMan ) Super2_Lib_t * Super2_LibStart() { Super2_Lib_t * pLib; - pLib = ALLOC( Super2_Lib_t, 1 ); + pLib = ABC_ALLOC( Super2_Lib_t, 1 ); memset( pLib, 0, sizeof(Super2_Lib_t) ); return pLib; } @@ -228,7 +228,7 @@ Super2_Lib_t * Super2_LibDup( Super2_Lib_t * pLib ) pLibNew->nGates = pLib->nGates; pLibNew->uMaskBit = pLib->uMaskBit; pLibNew->nGatesAlloc = 1000 + pLib->nGatesAlloc; - pLibNew->pGates = ALLOC( Super2_Gate_t *, pLibNew->nGatesAlloc ); + pLibNew->pGates = ABC_ALLOC( Super2_Gate_t *, pLibNew->nGatesAlloc ); memcpy( pLibNew->pGates, pLib->pGates, pLibNew->nGates * sizeof(Super2_Gate_t *) ); return pLibNew; } @@ -248,7 +248,7 @@ void Super2_LibAddGate( Super2_Lib_t * pLib, Super2_Gate_t * pGate ) { if ( pLib->nGates == pLib->nGatesAlloc ) { - pLib->pGates = REALLOC( Super2_Gate_t *, pLib->pGates, 3 * pLib->nGatesAlloc ); + pLib->pGates = ABC_REALLOC( Super2_Gate_t *, pLib->pGates, 3 * pLib->nGatesAlloc ); pLib->nGatesAlloc *= 3; } pLib->pGates[ pLib->nGates++ ] = pGate; @@ -267,8 +267,8 @@ void Super2_LibAddGate( Super2_Lib_t * pLib, Super2_Gate_t * pGate ) ***********************************************************************/ void Super2_LibStop( Super2_Lib_t * pLib ) { - free( pLib->pGates ); - free( pLib ); + ABC_FREE( pLib->pGates ); + ABC_FREE( pLib ); } /**Function************************************************************* @@ -297,7 +297,7 @@ Super2_Lib_t * Super2_LibFirst( Super2_Man_t * pMan, int nInputs ) pLib->nGates = nInputs + 1; pLib->nGatesAlloc = nInputs + 1; pLib->uMaskBit = (1 << (pLib->nMints-1)); - pLib->pGates = ALLOC( Super2_Gate_t *, nInputs + 1 ); + pLib->pGates = ABC_ALLOC( Super2_Gate_t *, nInputs + 1 ); // add the constant 0 pLib->pGates[0] = (Super2_Gate_t *)Extra_MmFixedEntryFetch( pMan->pMem ); memset( pLib->pGates[0], 0, sizeof(Super2_Gate_t) ); @@ -306,7 +306,7 @@ Super2_Lib_t * Super2_LibFirst( Super2_Man_t * pMan, int nInputs ) { pLib->pGates[v+1] = (Super2_Gate_t *)Extra_MmFixedEntryFetch( pMan->pMem ); memset( pLib->pGates[v+1], 0, sizeof(Super2_Gate_t) ); - pLib->pGates[v+1]->pTwo = (Super2_Gate_t *)(PORT_PTRUINT_T)v; + pLib->pGates[v+1]->pTwo = (Super2_Gate_t *)(ABC_PTRUINT_T)v; } // set up their truth tables @@ -347,7 +347,7 @@ Super2_Lib_t * Super2_LibCompute( Super2_Man_t * pMan, Super2_Lib_t * pLib ) { uTruthR = ((pGate1->uTruth & pLibNew->uMaskBit)? Mask & ~pGate1->uTruth : pGate1->uTruth); - if ( stmm_lookup( pMan->tTable, (char *)(PORT_PTRUINT_T)uTruthR, (char **)&pGate2 ) ) + if ( stmm_lookup( pMan->tTable, (char *)(ABC_PTRUINT_T)uTruthR, (char **)&pGate2 ) ) { printf( "New gate:\n" ); Super2_LibWriteGate( stdout, pLibNew, pGate1 ); @@ -355,7 +355,7 @@ Super2_Lib_t * Super2_LibCompute( Super2_Man_t * pMan, Super2_Lib_t * pLib ) Super2_LibWriteGate( stdout, pLibNew, pGate2 ); assert( 0 ); } - stmm_insert( pMan->tTable, (char *)(PORT_PTRUINT_T)uTruthR, (char *)(PORT_PTRUINT_T)pGate1 ); + stmm_insert( pMan->tTable, (char *)(ABC_PTRUINT_T)uTruthR, (char *)(ABC_PTRUINT_T)pGate1 ); } @@ -382,7 +382,7 @@ Super2_Lib_t * Super2_LibCompute( Super2_Man_t * pMan, Super2_Lib_t * pLib ) uTruth = uTruth1 & uTruth2; uTruthR = ((uTruth & pLibNew->uMaskBit)? Mask & ~uTruth : uTruth); - if ( !stmm_find_or_add( pMan->tTable, (char *)(PORT_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) + if ( !stmm_find_or_add( pMan->tTable, (char *)(ABC_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) { pGateNew = (Super2_Gate_t *)Extra_MmFixedEntryFetch( pMan->pMem ); pGateNew->pOne = pGate1; @@ -396,7 +396,7 @@ Super2_Lib_t * Super2_LibCompute( Super2_Man_t * pMan, Super2_Lib_t * pLib ) uTruth = uTruth1c & uTruth2; uTruthR = ((uTruth & pLibNew->uMaskBit)? Mask & ~uTruth : uTruth); - if ( !stmm_find_or_add( pMan->tTable, (char *)(PORT_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) + if ( !stmm_find_or_add( pMan->tTable, (char *)(ABC_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) { pGateNew = (Super2_Gate_t *)Extra_MmFixedEntryFetch( pMan->pMem ); pGateNew->pOne = Super2_Not(pGate1); @@ -410,7 +410,7 @@ Super2_Lib_t * Super2_LibCompute( Super2_Man_t * pMan, Super2_Lib_t * pLib ) uTruth = uTruth1 & uTruth2c; uTruthR = ((uTruth & pLibNew->uMaskBit)? Mask & ~uTruth : uTruth); - if ( !stmm_find_or_add( pMan->tTable, (char *)(PORT_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) + if ( !stmm_find_or_add( pMan->tTable, (char *)(ABC_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) { pGateNew = (Super2_Gate_t *)Extra_MmFixedEntryFetch( pMan->pMem ); pGateNew->pOne = pGate1; @@ -424,7 +424,7 @@ Super2_Lib_t * Super2_LibCompute( Super2_Man_t * pMan, Super2_Lib_t * pLib ) uTruth = uTruth1c & uTruth2c; uTruthR = ((uTruth & pLibNew->uMaskBit)? Mask & ~uTruth : uTruth); - if ( !stmm_find_or_add( pMan->tTable, (char *)(PORT_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) + if ( !stmm_find_or_add( pMan->tTable, (char *)(ABC_PTRUINT_T)uTruthR, (char ***)&ppGate ) ) { pGateNew = (Super2_Gate_t *)Extra_MmFixedEntryFetch( pMan->pMem ); pGateNew->pOne = Super2_Not(pGate1); @@ -475,7 +475,7 @@ clk = clock(); qsort( (void *)pLib->pGates, pLib->nGates, sizeof(Super2_Gate_t *), (int (*)(const void *, const void *)) Super2_LibCompareGates ); assert( Super2_LibCompareGates( pLib->pGates, pLib->pGates + pLib->nGates - 1 ) < 0 ); -PRT( "Sorting", clock() - clk ); +ABC_PRT( "Sorting", clock() - clk ); // start the file @@ -600,7 +600,7 @@ char * Super2_LibWriteGate_rec( Super2_Gate_t * pGate, int fInv, int Level ) } else { - pBuffer1[0] = (fInv? 'A' + ((int)(PORT_PTRUINT_T)pGate->pTwo): 'a' + ((int)(PORT_PTRUINT_T)pGate->pTwo)); + pBuffer1[0] = (fInv? 'A' + ((int)(ABC_PTRUINT_T)pGate->pTwo): 'a' + ((int)(ABC_PTRUINT_T)pGate->pTwo)); pBuffer1[1] = 0; } return pBuffer1; diff --git a/src/map/super/superGate.c b/src/map/super/superGate.c index c8aa02ba..7bc5e703 100644 --- a/src/map/super/superGate.c +++ b/src/map/super/superGate.c @@ -164,7 +164,7 @@ void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, float // stop the manager Super_ManStop( pMan ); - free( ppGates ); + ABC_FREE( ppGates ); return; } @@ -193,7 +193,7 @@ if ( fVerbose ) { printf( "Lev %d: Try =%12d. Add =%6d. Rem =%5d. Save =%6d. Lookups =%12d. Aliases =%12d. ", Level, pMan->nTried, pMan->nAdded, pMan->nRemoved, pMan->nAdded - pMan->nRemoved, pMan->nLookups, pMan->nAliases ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); fflush( stdout ); } } @@ -209,7 +209,7 @@ fflush( stdout ); // stop the manager Super_ManStop( pMan ); - free( ppGates ); + ABC_FREE( ppGates ); } @@ -235,7 +235,7 @@ void Super_First( Super_Man_t * pMan, int nVarsMax ) pMan->nLevels = 0; // allocate room for the gates pMan->nGates = nVarsMax; - pMan->pGates = ALLOC( Super_Gate_t *, nVarsMax + 2 ); + pMan->pGates = ABC_ALLOC( Super_Gate_t *, nVarsMax + 2 ); // create the gates corresponding to the elementary variables for ( v = 0; v < nVarsMax; v++ ) { @@ -329,7 +329,7 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat pProgress = Extra_ProgressBarStart( stdout, pMan->TimeLimit ); pMan->TimePrint = clock() + CLOCKS_PER_SEC; - ppGatesLimit = ALLOC( Super_Gate_t *, pMan->nGates ); + ppGatesLimit = ABC_ALLOC( Super_Gate_t *, pMan->nGates ); // go through the root gates // the root gates are sorted in the increasing gelay fTimeOut = 0; @@ -658,7 +658,7 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat } done: Extra_ProgressBarStop( pProgress ); - free( ppGatesLimit ); + ABC_FREE( ppGatesLimit ); return pMan; } @@ -709,8 +709,8 @@ void Super_TranferGatesToArray( Super_Man_t * pMan ) unsigned Key; // put the gates fron the table into the array - free( pMan->pGates ); - pMan->pGates = ALLOC( Super_Gate_t *, pMan->nAdded ); + ABC_FREE( pMan->pGates ); + pMan->pGates = ABC_ALLOC( Super_Gate_t *, pMan->nAdded ); pMan->nGates = 0; stmm_foreach_item( pMan->tTable, gen, (char **)&Key, (char **)&pList ) { @@ -737,7 +737,7 @@ void Super_AddGateToTable( Super_Man_t * pMan, Super_Gate_t * pGate ) unsigned Key; // Key = pGate->uTruth[0] + 2003 * pGate->uTruth[1]; Key = pGate->uTruth[0] ^ pGate->uTruth[1]; - if ( !stmm_find_or_add( pMan->tTable, (char *)(PORT_PTRUINT_T)Key, (char ***)&ppList ) ) + if ( !stmm_find_or_add( pMan->tTable, (char *)(ABC_PTRUINT_T)Key, (char ***)&ppList ) ) *ppList = NULL; pGate->pNext = *ppList; *ppList = pGate; @@ -778,7 +778,7 @@ bool Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, floa // get hold of the place where the entry is stored // Key = uTruth[0] + 2003 * uTruth[1]; Key = uTruth[0] ^ uTruth[1]; - if ( !stmm_find( pMan->tTable, (char *)(PORT_PTRUINT_T)Key, (char ***)&ppList ) ) + if ( !stmm_find( pMan->tTable, (char *)(ABC_PTRUINT_T)Key, (char ***)&ppList ) ) return 1; // the entry with this truth table is found pPrev = NULL; @@ -872,7 +872,7 @@ Super_Gate_t * Super_CreateGateNew( Super_Man_t * pMan, Mio_Gate_t * pRoot, Supe Super_Man_t * Super_ManStart() { Super_Man_t * pMan; - pMan = ALLOC( Super_Man_t, 1 ); + pMan = ABC_ALLOC( Super_Man_t, 1 ); memset( pMan, 0, sizeof(Super_Man_t) ); pMan->pMem = Extra_MmFixedStart( sizeof(Super_Gate_t) ); pMan->tTable = stmm_init_table( st_ptrcmp, st_ptrhash ); @@ -894,8 +894,8 @@ void Super_ManStop( Super_Man_t * pMan ) { Extra_MmFixedStop( pMan->pMem ); if ( pMan->tTable ) stmm_free_table( pMan->tTable ); - FREE( pMan->pGates ); - free( pMan ); + ABC_FREE( pMan->pGates ); + ABC_FREE( pMan ); } @@ -930,8 +930,8 @@ void Super_Write( Super_Man_t * pMan ) // the given limit, provided that the inputs are not consequtive. // For example, NAND2(a,c) is removed, but NAND2(a,b) is left, // because a and b are consequtive. - FREE( pMan->pGates ); - pMan->pGates = ALLOC( Super_Gate_t *, pMan->nAdded ); + ABC_FREE( pMan->pGates ); + pMan->pGates = ABC_ALLOC( Super_Gate_t *, pMan->nAdded ); pMan->nGates = 0; stmm_foreach_item( pMan->tTable, gen, (char **)&Key, (char **)&pGateRoot ) { @@ -961,7 +961,7 @@ clk = clock(); assert( Super_WriteCompare( pMan->pGates, pMan->pGates + pMan->nGates - 1 ) <= 0 ); if ( pMan->fVerbose ) { -PRT( "Sorting", clock() - clk ); +ABC_PRT( "Sorting", clock() - clk ); } @@ -971,7 +971,7 @@ clk = clock(); Super_WriteLibrary( pMan ); if ( pMan->fVerbose ) { -PRT( "Writing old format", clock() - clk ); +ABC_PRT( "Writing old format", clock() - clk ); } // write the tree-like structure of supergates @@ -979,7 +979,7 @@ clk = clock(); Super_WriteLibraryTree( pMan ); if ( pMan->fVerbose ) { -PRT( "Writing new format", clock() - clk ); +ABC_PRT( "Writing new format", clock() - clk ); } } @@ -1114,7 +1114,7 @@ void Super_WriteLibrary( Super_Man_t * pMan ) // get the file name pNameGeneric = Extra_FileNameGeneric( pMan->pName ); sprintf( FileName, "%s.super_old", pNameGeneric ); - free( pNameGeneric ); + ABC_FREE( pNameGeneric ); // count the number of unique functions pMan->nUnique = 1; @@ -1259,7 +1259,7 @@ void Super_WriteLibraryTree( Super_Man_t * pMan ) // get the file name pNameGeneric = Extra_FileNameGeneric( pMan->pName ); sprintf( FileName, "%s.super", pNameGeneric ); - free( pNameGeneric ); + ABC_FREE( pNameGeneric ); // write the elementary variables pFile = fopen( FileName, "w" ); diff --git a/src/misc/extra/extra.h b/src/misc/extra/extra.h index d7a3e98c..f81479b3 100644 --- a/src/misc/extra/extra.h +++ b/src/misc/extra/extra.h @@ -29,10 +29,6 @@ #ifndef __EXTRA_H__ #define __EXTRA_H__ -#ifdef __cplusplus -extern "C" { -#endif - #ifdef _WIN32 #define inline __inline // compatible with MS VS 6.0 #endif @@ -46,14 +42,12 @@ extern "C" { #include #include #include +#include "abc_global.h" #include "st.h" #include "cuddInt.h" -#include "port_type.h" -// catch memory leaks in Visual Studio -#ifdef _DEBUG -#define _CRTDBG_MAP_ALLOC -#include +#ifdef __cplusplus +extern "C" { #endif /*---------------------------------------------------------------------------*/ @@ -76,25 +70,9 @@ extern "C" { /* Macro declarations */ /*---------------------------------------------------------------------------*/ -#ifdef WIN32 -#define ABC_DLLEXPORT __declspec(dllexport) -#define ABC_DLLIMPORT __declspec(dllimport) -#else /* defined(WIN32) */ -#define ABC_DLLIMPORT -#endif /* defined(WIN32) */ - -#ifndef ABC_DLL -#define ABC_DLL ABC_DLLIMPORT -#endif - typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; -#ifdef WIN32 -typedef unsigned __int64 uint64; -#else -typedef unsigned long long uint64; -#endif /* constants of the manager */ #define b0 Cudd_Not((dd)->one) @@ -106,34 +84,21 @@ typedef unsigned long long uint64; // hash key macros #define hashKey1(a,TSIZE) \ -((PORT_PTRUINT_T)(a) % TSIZE) +((ABC_PTRUINT_T)(a) % TSIZE) #define hashKey2(a,b,TSIZE) \ -(((PORT_PTRUINT_T)(a) + (PORT_PTRUINT_T)(b) * DD_P1) % TSIZE) +(((ABC_PTRUINT_T)(a) + (ABC_PTRUINT_T)(b) * DD_P1) % TSIZE) #define hashKey3(a,b,c,TSIZE) \ -(((((PORT_PTRUINT_T)(a) + (PORT_PTRUINT_T)(b)) * DD_P1 + (PORT_PTRUINT_T)(c)) * DD_P2 ) % TSIZE) +(((((ABC_PTRUINT_T)(a) + (ABC_PTRUINT_T)(b)) * DD_P1 + (ABC_PTRUINT_T)(c)) * DD_P2 ) % TSIZE) #define hashKey4(a,b,c,d,TSIZE) \ -((((((PORT_PTRUINT_T)(a) + (PORT_PTRUINT_T)(b)) * DD_P1 + (PORT_PTRUINT_T)(c)) * DD_P2 + \ - (PORT_PTRUINT_T)(d)) * DD_P3) % TSIZE) +((((((ABC_PTRUINT_T)(a) + (ABC_PTRUINT_T)(b)) * DD_P1 + (ABC_PTRUINT_T)(c)) * DD_P2 + \ + (ABC_PTRUINT_T)(d)) * DD_P3) % TSIZE) #define hashKey5(a,b,c,d,e,TSIZE) \ -(((((((PORT_PTRUINT_T)(a) + (PORT_PTRUINT_T)(b)) * DD_P1 + (PORT_PTRUINT_T)(c)) * DD_P2 + \ - (PORT_PTRUINT_T)(d)) * DD_P3 + (PORT_PTRUINT_T)(e)) * DD_P1) % TSIZE) - -#ifndef PRT -#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)) -#define PRTn(a,t) printf("%s = ", (a)); printf("%6.2f sec ", (float)(t)/(float)(CLOCKS_PER_SEC)) -#endif - -#ifndef PRTP -#define PRTP(a,t,T) printf("%s = ", (a)); printf("%6.2f sec (%6.2f %%)\n", (float)(t)/(float)(CLOCKS_PER_SEC), (T)? 100.0*(t)/(T) : 0.0) -#endif - -#ifndef PRB -#define PRB(dd,f) printf("%s = ", #f); Extra_bddPrint(dd,f); printf("\n") -#endif +(((((((ABC_PTRUINT_T)(a) + (ABC_PTRUINT_T)(b)) * DD_P1 + (ABC_PTRUINT_T)(c)) * DD_P2 + \ + (ABC_PTRUINT_T)(d)) * DD_P3 + (ABC_PTRUINT_T)(e)) * DD_P1) % TSIZE) /*===========================================================================*/ /* Various Utilities */ @@ -229,6 +194,10 @@ extern DdNode * Extra_zddPrimes( DdManager * dd, DdNode * F ); extern void Extra_bddPermuteArray( DdManager * dd, DdNode ** bNodesIn, DdNode ** bNodesOut, int nNodes, int *permut ); extern DdNode * Extra_bddComputeCube( DdManager * dd, DdNode ** bXVars, int nVars ); +#ifndef ABC_PRB +#define ABC_PRB(dd,f) printf("%s = ", #f); Extra_bddPrint(dd,f); printf("\n") +#endif + /*=== extraBddKmap.c ================================================================*/ /* displays the Karnaugh Map of a function */ @@ -617,33 +586,6 @@ extern unsigned Extra_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux /*=== extraUtilUtil.c ================================================================*/ -#ifndef ABS -#define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef ALLOC -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#endif - -#ifndef FREE -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#endif - -#ifndef REALLOC -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) -#endif - - extern long Extra_CpuTime(); extern double Extra_CpuTimeDouble(); extern int Extra_GetSoftDataLimit(); diff --git a/src/misc/extra/extraBddAuto.c b/src/misc/extra/extraBddAuto.c index 11612ef4..ebafb3a8 100644 --- a/src/misc/extra/extraBddAuto.c +++ b/src/misc/extra/extraBddAuto.c @@ -159,7 +159,7 @@ DdNode * Extra_bddSpaceFromFunctionFast( DdManager * dd, DdNode * bFunc ) int i, lev; // get the support - pSupport = ALLOC( int, ddMax(dd->size,dd->sizeZ) ); + pSupport = ABC_ALLOC( int, ddMax(dd->size,dd->sizeZ) ); Extra_SupportArray( dd, bFunc, pSupport ); nSupp = 0; for ( i = 0; i < dd->size; i++ ) @@ -171,14 +171,14 @@ DdNode * Extra_bddSpaceFromFunctionFast( DdManager * dd, DdNode * bFunc ) { printf( "Cannot derive linear space, because DD manager does not have enough variables.\n" ); fflush( stdout ); - free( pSupport ); + ABC_FREE( pSupport ); return NULL; } // create the permutation arrays - pPermute = ALLOC( int, dd->size ); - pPermuteBack = ALLOC( int, dd->size ); - pCompose = ALLOC( DdNode *, dd->size ); + pPermute = ABC_ALLOC( int, dd->size ); + pPermuteBack = ABC_ALLOC( int, dd->size ); + pCompose = ABC_ALLOC( DdNode *, dd->size ); for ( i = 0; i < dd->size; i++ ) { pPermute[i] = i; @@ -225,10 +225,10 @@ DdNode * Extra_bddSpaceFromFunctionFast( DdManager * dd, DdNode * bFunc ) for ( i = 0; i < dd->size; i++ ) Cudd_RecursiveDeref( dd, pCompose[i] ); - free( pPermute ); - free( pPermuteBack ); - free( pCompose ); - free( pSupport ); + ABC_FREE( pPermute ); + ABC_FREE( pPermuteBack ); + ABC_FREE( pCompose ); + ABC_FREE( pSupport ); Cudd_Deref( bSpace ); return bSpace; @@ -500,11 +500,11 @@ DdNode ** Extra_bddSpaceExorGates( DdManager * dd, DdNode * bFuncRed, DdNode * z DdNode * zExor, * zTemp; // get the set of non-canonical variables - pVarsNonCan = ALLOC( int, ddMax(dd->size,dd->sizeZ) ); + pVarsNonCan = ABC_ALLOC( int, ddMax(dd->size,dd->sizeZ) ); Extra_SupportArray( dd, bFuncRed, pVarsNonCan ); // allocate storage for the EXOR sets - pzRes = ALLOC( DdNode *, dd->size ); + pzRes = ABC_ALLOC( DdNode *, dd->size ); memset( pzRes, 0, sizeof(DdNode *) * dd->size ); // go through all the equations @@ -536,7 +536,7 @@ DdNode ** Extra_bddSpaceExorGates( DdManager * dd, DdNode * bFuncRed, DdNode * z } Cudd_RecursiveDerefZdd( dd, zEquRem ); - free( pVarsNonCan ); + ABC_FREE( pVarsNonCan ); return pzRes; } @@ -575,7 +575,7 @@ DdNode * extraBddSpaceFromFunction( DdManager * dd, DdNode * bF, DdNode * bG ) // both bFunc and bCore are not constants // the operation is commutative - normalize the problem - if ( (unsigned)(PORT_PTRUINT_T)bF > (unsigned)(PORT_PTRUINT_T)bG ) + if ( (unsigned)(ABC_PTRUINT_T)bF > (unsigned)(ABC_PTRUINT_T)bG ) return extraBddSpaceFromFunction(dd, bG, bF); diff --git a/src/misc/extra/extraBddCas.c b/src/misc/extra/extraBddCas.c index 29382bfb..ccf7397d 100644 --- a/src/misc/extra/extraBddCas.c +++ b/src/misc/extra/extraBddCas.c @@ -226,7 +226,7 @@ Extra_bddEncodingNonStrict( // s_EncSearchTime += clock() - clk; // allocate the temporary storage for the columns - s_pbTemp = (DdNode **) malloc( nColumns * sizeof(DdNode *) ); + s_pbTemp = (DdNode **)ABC_ALLOC( char, nColumns * sizeof(DdNode *) ); // clk = clock(); bResult = CreateTheCodes_rec( dd, bEncoded, 0, pCVars ); Cudd_Ref( bResult ); @@ -236,7 +236,7 @@ Extra_bddEncodingNonStrict( Cudd_RecursiveDeref( dd, bEncoded ); // Cudd_RecursiveDeref( dd, aEncoded ); - free( s_pbTemp ); + ABC_FREE( s_pbTemp ); *pSimple = s_nVarsBest; Cudd_Deref( bResult ); @@ -306,7 +306,7 @@ st_table * Extra_bddNodePathsUnderCut( DdManager * dd, DdNode * bFunc, int CutLe st_foreach_item( Visited, gen, (char**)&aNode, (char**)&p ) { Cudd_RecursiveDeref( dd, p->bSum ); - free( p ); + ABC_FREE( p ); } st_free_table( Visited ); } @@ -394,7 +394,7 @@ int Extra_bddNodePathsUnderCutArray( DdManager * dd, DdNode ** paNodes, DdNode * st_foreach_item( Visited, gen, (char**)&aNode, (char**)&p ) { Cudd_RecursiveDeref( dd, p->bSum ); - free( p ); + ABC_FREE( p ); } st_free_table( Visited ); } @@ -1123,7 +1123,7 @@ void CountNodeVisits_rec( DdManager * dd, DdNode * aFunc, st_table * Visited ) assert( !Cudd_IsComplement(aFunc) ); // create the new traversal entry - p = (traventry *) malloc( sizeof(traventry) ); + p = (traventry *) ABC_ALLOC( char, sizeof(traventry) ); // set the initial sum of edges to zero BDD p->bSum = b0; Cudd_Ref( b0 ); // set the starting number of incoming edges diff --git a/src/misc/extra/extraBddImage.c b/src/misc/extra/extraBddImage.c index 23c1c682..11d60a40 100644 --- a/src/misc/extra/extraBddImage.c +++ b/src/misc/extra/extraBddImage.c @@ -170,7 +170,7 @@ Extra_ImageTree_t * Extra_bddImageStart( pNodes = Extra_CreateNodes( dd, nParts + 1, pParts, dd->size, pVars ); // create the tree - pTree = ALLOC( Extra_ImageTree_t, 1 ); + pTree = ABC_ALLOC( Extra_ImageTree_t, 1 ); memset( pTree, 0, sizeof(Extra_ImageTree_t) ); pTree->pCare = pNodes[nParts]; pTree->fVerbose = fVerbose; @@ -181,7 +181,7 @@ Extra_ImageTree_t * Extra_bddImageStart( // make sure the variables are gone for ( v = 0; v < dd->size; v++ ) assert( pVars[v] == NULL ); - FREE( pVars ); + ABC_FREE( pVars ); // merge the topmost nodes while ( (pTree->pRoot = Extra_MergeTopNodes( dd, nParts + 1, pNodes )) == NULL ); @@ -189,7 +189,7 @@ Extra_ImageTree_t * Extra_bddImageStart( // make sure the nodes are gone for ( v = 0; v < nParts + 1; v++ ) assert( pNodes[v] == NULL ); - FREE( pNodes ); + ABC_FREE( pNodes ); // if ( fVerbose ) // Extra_bddImagePrintTree( pTree ); @@ -199,7 +199,7 @@ Extra_ImageTree_t * Extra_bddImageStart( // clean the partitions Extra_DeleteParts_rec( pTree->pRoot ); - FREE( pParts ); + ABC_FREE( pParts ); return pTree; } @@ -229,9 +229,9 @@ DdNode * Extra_bddImageCompute( Extra_ImageTree_t * pTree, DdNode * bCare ) if ( bRem != b1 ) { printf( "Original care set support: " ); -PRB( dd, pTree->bCareSupp ); +ABC_PRB( dd, pTree->bCareSupp ); printf( "Current care set support: " ); -PRB( dd, bSupp ); +ABC_PRB( dd, bSupp ); Cudd_RecursiveDeref( dd, bSupp ); Cudd_RecursiveDeref( dd, bRem ); printf( "The care set depends on some vars that were not in the care set during scheduling.\n" ); @@ -272,7 +272,7 @@ void Extra_bddImageTreeDelete( Extra_ImageTree_t * pTree ) if ( pTree->bCareSupp ) Cudd_RecursiveDeref( pTree->pRoot->dd, pTree->bCareSupp ); Extra_bddImageTreeDelete_rec( pTree->pRoot ); - FREE( pTree ); + ABC_FREE( pTree ); } /**Function************************************************************* @@ -317,11 +317,11 @@ Extra_ImagePart_t ** Extra_CreateParts( DdManager * dd, int i; // start the partitions - pParts = ALLOC( Extra_ImagePart_t *, nParts + 1 ); + pParts = ABC_ALLOC( Extra_ImagePart_t *, nParts + 1 ); // create structures for each variable for ( i = 0; i < nParts; i++ ) { - pParts[i] = ALLOC( Extra_ImagePart_t, 1 ); + pParts[i] = ABC_ALLOC( Extra_ImagePart_t, 1 ); pParts[i]->bFunc = pbParts[i]; Cudd_Ref( pParts[i]->bFunc ); pParts[i]->bSupp = Cudd_Support( dd, pParts[i]->bFunc ); Cudd_Ref( pParts[i]->bSupp ); pParts[i]->nSupp = Extra_bddSuppSize( dd, pParts[i]->bSupp ); @@ -329,7 +329,7 @@ Extra_ImagePart_t ** Extra_CreateParts( DdManager * dd, pParts[i]->iPart = i; } // add the care set as the last partition - pParts[nParts] = ALLOC( Extra_ImagePart_t, 1 ); + pParts[nParts] = ABC_ALLOC( Extra_ImagePart_t, 1 ); pParts[nParts]->bFunc = bCare; Cudd_Ref( pParts[nParts]->bFunc ); pParts[nParts]->bSupp = Cudd_Support( dd, pParts[nParts]->bFunc ); Cudd_Ref( pParts[nParts]->bSupp ); pParts[nParts]->nSupp = Extra_bddSuppSize( dd, pParts[nParts]->bSupp ); @@ -359,11 +359,11 @@ Extra_ImageVar_t ** Extra_CreateVars( DdManager * dd, int nVarsTotal, iVar, p, Counter; // put all the functions into one array - pbFuncs = ALLOC( DdNode *, nParts ); + pbFuncs = ABC_ALLOC( DdNode *, nParts ); for ( p = 0; p < nParts; p++ ) pbFuncs[p] = pParts[p]->bSupp; bSupp = Cudd_VectorSupport( dd, pbFuncs, nParts ); Cudd_Ref( bSupp ); - FREE( pbFuncs ); + ABC_FREE( pbFuncs ); // remove the NS vars bCubeNs = Cudd_bddComputeCube( dd, pbVars, NULL, nVars ); Cudd_Ref( bCubeNs ); @@ -375,13 +375,13 @@ Extra_ImageVar_t ** Extra_CreateVars( DdManager * dd, nVarsTotal = Extra_bddSuppSize( dd, bSupp ); // start the variables - pVars = ALLOC( Extra_ImageVar_t *, dd->size ); + pVars = ABC_ALLOC( Extra_ImageVar_t *, dd->size ); memset( pVars, 0, sizeof(Extra_ImageVar_t *) * dd->size ); // create structures for each variable for ( bSuppTemp = bSupp; bSuppTemp != b1; bSuppTemp = cuddT(bSuppTemp) ) { iVar = bSuppTemp->index; - pVars[iVar] = ALLOC( Extra_ImageVar_t, 1 ); + pVars[iVar] = ABC_ALLOC( Extra_ImageVar_t, 1 ); pVars[iVar]->iNum = iVar; // collect all the parts this var belongs to Counter = 0; @@ -428,11 +428,11 @@ Extra_ImageNode_t ** Extra_CreateNodes( DdManager * dd, Extra_ImagePart_t * pPart; // the partition (temporary) */ // start the partitions - pNodes = ALLOC( Extra_ImageNode_t *, nParts ); + pNodes = ABC_ALLOC( Extra_ImageNode_t *, nParts ); // create structures for each leaf nodes for ( i = 0; i < nParts; i++ ) { - pNodes[i] = ALLOC( Extra_ImageNode_t, 1 ); + pNodes[i] = ABC_ALLOC( Extra_ImageNode_t, 1 ); memset( pNodes[i], 0, sizeof(Extra_ImageNode_t) ); pNodes[i]->dd = dd; pNodes[i]->pPart = pParts[i]; @@ -459,7 +459,7 @@ Extra_ImageNode_t ** Extra_CreateNodes( DdManager * dd, } // remove these variables Cudd_RecursiveDeref( dd, pVars[v]->bParts ); - FREE( pVars[v] ); + ABC_FREE( pVars[v] ); } // assign the leaf node images @@ -494,9 +494,9 @@ Extra_ImageNode_t ** Extra_CreateNodes( DdManager * dd, for ( i = 0; i < nParts; i++ ) { pNode = pNodes[i]; -PRB( dd, pNode->bCube ); -PRB( dd, pNode->pPart->bFunc ); -PRB( dd, pNode->pPart->bSupp ); +ABC_PRB( dd, pNode->bCube ); +ABC_PRB( dd, pNode->pPart->bFunc ); +ABC_PRB( dd, pNode->pPart->bSupp ); printf( "\n" ); } */ @@ -525,7 +525,7 @@ void Extra_DeleteParts_rec( Extra_ImageNode_t * pNode ) pPart = pNode->pPart; Cudd_RecursiveDeref( pNode->dd, pPart->bFunc ); Cudd_RecursiveDeref( pNode->dd, pPart->bSupp ); - FREE( pNode->pPart ); + ABC_FREE( pNode->pPart ); } /**Function************************************************************* @@ -550,7 +550,7 @@ void Extra_bddImageTreeDelete_rec( Extra_ImageNode_t * pNode ) if ( pNode->bImage ) Cudd_RecursiveDeref( pNode->dd, pNode->bImage ); assert( pNode->pPart == NULL ); - FREE( pNode ); + ABC_FREE( pNode ); } /**Function************************************************************* @@ -663,11 +663,11 @@ int Extra_BuildTreeNode( DdManager * dd, Cudd_RecursiveDeref( dd, bTemp ); // clean this var Cudd_RecursiveDeref( dd, pVars[v]->bParts ); - FREE( pVars[v] ); + ABC_FREE( pVars[v] ); } // clean the best var Cudd_RecursiveDeref( dd, pVars[iVarBest]->bParts ); - FREE( pVars[iVarBest] ); + ABC_FREE( pVars[iVarBest] ); // combines two nodes pNode = Extra_CombineTwoNodes( dd, bCube, pNode1, pNode2 ); @@ -783,7 +783,7 @@ Extra_ImageNode_t * Extra_CombineTwoNodes( DdManager * dd, DdNode * bCube, Extra_ImagePart_t * pPart; // create a new partition - pPart = ALLOC( Extra_ImagePart_t, 1 ); + pPart = ABC_ALLOC( Extra_ImagePart_t, 1 ); memset( pPart, 0, sizeof(Extra_ImagePart_t) ); // create the function pPart->bFunc = Cudd_bddAndAbstract( dd, pNode1->pPart->bFunc, pNode2->pPart->bFunc, bCube ); @@ -796,12 +796,12 @@ Extra_ImageNode_t * Extra_CombineTwoNodes( DdManager * dd, DdNode * bCube, pPart->nNodes = Cudd_DagSize( pPart->bFunc ); pPart->iPart = -1; /* -PRB( dd, pNode1->pPart->bSupp ); -PRB( dd, pNode2->pPart->bSupp ); -PRB( dd, pPart->bSupp ); +ABC_PRB( dd, pNode1->pPart->bSupp ); +ABC_PRB( dd, pNode2->pPart->bSupp ); +ABC_PRB( dd, pPart->bSupp ); */ // create a new node - pNode = ALLOC( Extra_ImageNode_t, 1 ); + pNode = ABC_ALLOC( Extra_ImageNode_t, 1 ); memset( pNode, 0, sizeof(Extra_ImageNode_t) ); pNode->dd = dd; pNode->pPart = pPart; @@ -1013,7 +1013,7 @@ void Extra_bddImagePrintTree_rec( Extra_ImageNode_t * pNode, int Offset ) printf( "<%d> ", pNode->pPart->iPart ); if ( Cube != NULL ) { - PRB( pNode->dd, Cube ); + ABC_PRB( pNode->dd, Cube ); } else printf( "\n" ); @@ -1023,7 +1023,7 @@ void Extra_bddImagePrintTree_rec( Extra_ImageNode_t * pNode, int Offset ) printf( "<*> " ); if ( Cube != NULL ) { - PRB( pNode->dd, Cube ); + ABC_PRB( pNode->dd, Cube ); } else printf( "\n" ); @@ -1069,7 +1069,7 @@ Extra_ImageTree2_t * Extra_bddImageStart2( DdNode * bCubeAll, * bCubeNot, * bTemp; int i; - pTree = ALLOC( Extra_ImageTree2_t, 1 ); + pTree = ABC_ALLOC( Extra_ImageTree2_t, 1 ); pTree->dd = dd; pTree->bImage = NULL; @@ -1130,7 +1130,7 @@ void Extra_bddImageTreeDelete2( Extra_ImageTree2_t * pTree ) Cudd_RecursiveDeref( pTree->dd, pTree->bCube ); if ( pTree->bImage ) Cudd_RecursiveDeref( pTree->dd, pTree->bImage ); - FREE( pTree ); + ABC_FREE( pTree ); } /**Function************************************************************* diff --git a/src/misc/extra/extraBddMisc.c b/src/misc/extra/extraBddMisc.c index 8b8bdd81..e17d1744 100644 --- a/src/misc/extra/extraBddMisc.c +++ b/src/misc/extra/extraBddMisc.c @@ -112,7 +112,7 @@ DdNode * Extra_TransferLevelByLevel( DdManager * ddSource, DdManager * ddDestina nMin = ddMin(ddSource->size, ddDestination->size); nMax = ddMax(ddSource->size, ddDestination->size); - pPermute = ALLOC( int, nMax ); + pPermute = ABC_ALLOC( int, nMax ); // set up the variable permutation for ( i = 0; i < nMin; i++ ) pPermute[ ddSource->invperm[i] ] = ddDestination->invperm[i]; @@ -122,7 +122,7 @@ DdNode * Extra_TransferLevelByLevel( DdManager * ddSource, DdManager * ddDestina pPermute[ ddSource->invperm[i] ] = -1; } bRes = Extra_TransferPermute( ddSource, ddDestination, f, pPermute ); - FREE( pPermute ); + ABC_FREE( pPermute ); return bRes; } @@ -145,7 +145,7 @@ DdNode * Extra_bddRemapUp( DdNode * bSupp, * bTemp, * bRes; int Counter; - pPermute = ALLOC( int, dd->size ); + pPermute = ABC_ALLOC( int, dd->size ); // get support bSupp = Cudd_Support( dd, bF ); Cudd_Ref( bSupp ); @@ -164,7 +164,7 @@ DdNode * Extra_bddRemapUp( // return Cudd_Deref( bRes ); - free( pPermute ); + ABC_FREE( pPermute ); return bRes; } @@ -584,7 +584,7 @@ DdNode * Extra_bddFindOneCube( DdManager * dd, DdNode * bF ) int v; // get the vector of variables in the cube - s_Temp = ALLOC( char, dd->size ); + s_Temp = ABC_ALLOC( char, dd->size ); Cudd_bddPickOneCube( dd, bF, s_Temp ); // start the cube @@ -603,7 +603,7 @@ DdNode * Extra_bddFindOneCube( DdManager * dd, DdNode * bF ) Cudd_RecursiveDeref( dd, bTemp ); } Cudd_Deref(bCube); - free( s_Temp ); + ABC_FREE( s_Temp ); return bCube; } @@ -745,7 +745,7 @@ DdNode * Extra_bddSupportNegativeCube( DdManager * dd, DdNode * f ) /* Allocate and initialize support array for ddSupportStep. */ size = ddMax( dd->size, dd->sizeZ ); - support = ALLOC( int, size ); + support = ABC_ALLOC( int, size ); if ( support == NULL ) { dd->errorCode = CUDD_MEMORY_OUT; @@ -793,7 +793,7 @@ DdNode * Extra_bddSupportNegativeCube( DdManager * dd, DdNode * f ) } while ( dd->reordered == 1 ); - FREE( support ); + ABC_FREE( support ); if ( res != NULL ) cuddDeref( res ); return ( res ); diff --git a/src/misc/extra/extraBddSymm.c b/src/misc/extra/extraBddSymm.c index 666814f6..e42130d4 100644 --- a/src/misc/extra/extraBddSymm.c +++ b/src/misc/extra/extraBddSymm.c @@ -207,12 +207,12 @@ Extra_SymmInfo_t * Extra_SymmPairsAllocate( int nVars ) Extra_SymmInfo_t * p; // allocate and clean the storage for symmetry info - p = ALLOC( Extra_SymmInfo_t, 1 ); + p = ABC_ALLOC( Extra_SymmInfo_t, 1 ); memset( p, 0, sizeof(Extra_SymmInfo_t) ); p->nVars = nVars; - p->pVars = ALLOC( int, nVars ); - p->pSymms = ALLOC( char *, nVars ); - p->pSymms[0] = ALLOC( char , nVars * nVars ); + p->pVars = ABC_ALLOC( int, nVars ); + p->pSymms = ABC_ALLOC( char *, nVars ); + p->pSymms[0] = ABC_ALLOC( char , nVars * nVars ); memset( p->pSymms[0], 0, nVars * nVars * sizeof(char) ); for ( i = 1; i < nVars; i++ ) @@ -234,10 +234,10 @@ Extra_SymmInfo_t * Extra_SymmPairsAllocate( int nVars ) ******************************************************************************/ void Extra_SymmPairsDissolve( Extra_SymmInfo_t * p ) { - free( p->pVars ); - free( p->pSymms[0] ); - free( p->pSymms ); - free( p ); + ABC_FREE( p->pVars ); + ABC_FREE( p->pSymms[0] ); + ABC_FREE( p->pSymms ); + ABC_FREE( p ); } /* end of Extra_SymmPairsDissolve */ /**Function******************************************************************** @@ -298,7 +298,7 @@ Extra_SymmInfo_t * Extra_SymmPairsCreateFromZdd( DdManager * dd, DdNode * zPairs p = Extra_SymmPairsAllocate( nSuppSize ); // allocate the storage for the temporary map - pMapVars2Nums = ALLOC( int, dd->size ); + pMapVars2Nums = ABC_ALLOC( int, dd->size ); memset( pMapVars2Nums, 0, dd->size * sizeof(int) ); // assign the variables @@ -337,7 +337,7 @@ Extra_SymmInfo_t * Extra_SymmPairsCreateFromZdd( DdManager * dd, DdNode * zPairs } // for each cube Cudd_RecursiveDerefZdd( dd, zSet ); - FREE( pMapVars2Nums ); + ABC_FREE( pMapVars2Nums ); return p; } /* end of Extra_SymmPairsCreateFromZdd */ diff --git a/src/misc/extra/extraBddUnate.c b/src/misc/extra/extraBddUnate.c index 92396c38..715731bd 100644 --- a/src/misc/extra/extraBddUnate.c +++ b/src/misc/extra/extraBddUnate.c @@ -153,10 +153,10 @@ Extra_UnateInfo_t * Extra_UnateInfoAllocate( int nVars ) { Extra_UnateInfo_t * p; // allocate and clean the storage for unateness info - p = ALLOC( Extra_UnateInfo_t, 1 ); + p = ABC_ALLOC( Extra_UnateInfo_t, 1 ); memset( p, 0, sizeof(Extra_UnateInfo_t) ); p->nVars = nVars; - p->pVars = ALLOC( Extra_UnateVar_t, nVars ); + p->pVars = ABC_ALLOC( Extra_UnateVar_t, nVars ); memset( p->pVars, 0, nVars * sizeof(Extra_UnateVar_t) ); return p; } /* end of Extra_UnateInfoAllocate */ @@ -174,8 +174,8 @@ Extra_UnateInfo_t * Extra_UnateInfoAllocate( int nVars ) ******************************************************************************/ void Extra_UnateInfoDissolve( Extra_UnateInfo_t * p ) { - free( p->pVars ); - free( p ); + ABC_FREE( p->pVars ); + ABC_FREE( p ); } /* end of Extra_UnateInfoDissolve */ /**Function******************************************************************** @@ -193,7 +193,7 @@ void Extra_UnateInfoPrint( Extra_UnateInfo_t * p ) { char * pBuffer; int i; - pBuffer = ALLOC( char, p->nVarsMax+1 ); + pBuffer = ABC_ALLOC( char, p->nVarsMax+1 ); memset( pBuffer, ' ', p->nVarsMax ); pBuffer[p->nVarsMax] = 0; for ( i = 0; i < p->nVars; i++ ) @@ -204,7 +204,7 @@ void Extra_UnateInfoPrint( Extra_UnateInfo_t * p ) else pBuffer[ p->pVars[i].iVar ] = '.'; printf( "%s\n", pBuffer ); - free( pBuffer ); + ABC_FREE( pBuffer ); } /* end of Extra_UnateInfoPrint */ @@ -234,7 +234,7 @@ Extra_UnateInfo_t * Extra_UnateInfoCreateFromZdd( DdManager * dd, DdNode * zPair p = Extra_UnateInfoAllocate( nSuppSize ); // allocate the storage for the temporary map - pMapVars2Nums = ALLOC( int, dd->size ); + pMapVars2Nums = ABC_ALLOC( int, dd->size ); memset( pMapVars2Nums, 0, dd->size * sizeof(int) ); // assign the variables @@ -269,7 +269,7 @@ Extra_UnateInfo_t * Extra_UnateInfoCreateFromZdd( DdManager * dd, DdNode * zPair } // for each cube Cudd_RecursiveDerefZdd( dd, zSet ); - FREE( pMapVars2Nums ); + ABC_FREE( pMapVars2Nums ); return p; } /* end of Extra_UnateInfoCreateFromZdd */ diff --git a/src/misc/extra/extraUtilBitMatrix.c b/src/misc/extra/extraUtilBitMatrix.c index b860a538..dd63e05c 100644 --- a/src/misc/extra/extraUtilBitMatrix.c +++ b/src/misc/extra/extraUtilBitMatrix.c @@ -79,14 +79,14 @@ Extra_BitMat_t * Extra_BitMatrixStart( int nSize ) { Extra_BitMat_t * p; int i; - p = ALLOC( Extra_BitMat_t, 1 ); + p = ABC_ALLOC( Extra_BitMat_t, 1 ); memset( p, 0, sizeof(Extra_BitMat_t) ); p->nSize = nSize; p->nBitShift = (sizeof(unsigned) == 4) ? 5: 6; p->uMask = (sizeof(unsigned) == 4) ? 31: 63; p->nWords = nSize / (8 * sizeof(unsigned)) + ((nSize % (8 * sizeof(unsigned))) > 0); - p->ppData = ALLOC( unsigned *, nSize ); - p->ppData[0] = ALLOC( unsigned, nSize * p->nWords ); + p->ppData = ABC_ALLOC( unsigned *, nSize ); + p->ppData[0] = ABC_ALLOC( unsigned, nSize * p->nWords ); memset( p->ppData[0], 0, sizeof(unsigned) * nSize * p->nWords ); for ( i = 1; i < nSize; i++ ) p->ppData[i] = p->ppData[i-1] + p->nWords; @@ -122,9 +122,9 @@ void Extra_BitMatrixClean( Extra_BitMat_t * p ) ***********************************************************************/ void Extra_BitMatrixStop( Extra_BitMat_t * p ) { - FREE( p->ppData[0] ); - FREE( p->ppData ); - FREE( p ); + ABC_FREE( p->ppData[0] ); + ABC_FREE( p->ppData ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/misc/extra/extraUtilFile.c b/src/misc/extra/extraUtilFile.c index 44dff1e0..96cf8601 100644 --- a/src/misc/extra/extraUtilFile.c +++ b/src/misc/extra/extraUtilFile.c @@ -98,7 +98,7 @@ char * Extra_FileGetSimilarName( char * pFileNameWrong, char * pS1, char * pS2, } } } - FREE( pFileGen ); + ABC_FREE( pFileGen ); if ( pFile ) { fclose( pFile ); @@ -238,7 +238,7 @@ char * Extra_FileRead( FILE * pFile ) // move the file current reading position to the beginning rewind( pFile ); // load the contents of the file into memory - pBuffer = ALLOC( char, nFileSize + 3 ); + pBuffer = ABC_ALLOC( char, nFileSize + 3 ); fread( pBuffer, nFileSize, 1, pFile ); // terminate the string with '\0' pBuffer[ nFileSize + 0] = '\n'; @@ -482,9 +482,9 @@ char * Extra_StringAppend( char * pStrGiven, char * pStrAdd ) char * pTemp; if ( pStrGiven ) { - pTemp = ALLOC( char, strlen(pStrGiven) + strlen(pStrAdd) + 2 ); + pTemp = ABC_ALLOC( char, strlen(pStrGiven) + strlen(pStrAdd) + 2 ); sprintf( pTemp, "%s%s", pStrGiven, pStrAdd ); - free( pStrGiven ); + ABC_FREE( pStrGiven ); } else pTemp = Extra_UtilStrsav( pStrAdd ); diff --git a/src/misc/extra/extraUtilMemory.c b/src/misc/extra/extraUtilMemory.c index e672afbb..626d58b5 100644 --- a/src/misc/extra/extraUtilMemory.c +++ b/src/misc/extra/extraUtilMemory.c @@ -35,7 +35,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 free entries + char * pEntriesFree; // the linked list of ABC_FREE entries // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -52,8 +52,8 @@ struct Extra_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 + char * pCurrent; // the current pointer to ABC_FREE memory + char * pEnd; // the first entry outside the ABC_FREE memory // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -120,7 +120,7 @@ Extra_MmFixed_t * Extra_MmFixedStart( int nEntrySize ) { Extra_MmFixed_t * p; - p = ALLOC( Extra_MmFixed_t, 1 ); + p = ABC_ALLOC( Extra_MmFixed_t, 1 ); memset( p, 0, sizeof(Extra_MmFixed_t) ); p->nEntrySize = nEntrySize; @@ -137,7 +137,7 @@ Extra_MmFixed_t * Extra_MmFixedStart( int nEntrySize ) p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -180,9 +180,9 @@ void Extra_MmFixedStop( Extra_MmFixed_t * p ) if ( p == NULL ) return; for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -201,16 +201,16 @@ char * Extra_MmFixedEntryFetch( Extra_MmFixed_t * p ) char * pTemp; int i; - // check if there are still free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize ); + 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; @@ -230,7 +230,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 free entry list + // return the first entry in the ABC_FREE entry list pTemp = p->pEntriesFree; p->pEntriesFree = *((char **)pTemp); return pTemp; @@ -251,7 +251,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 free entries + // add the entry to the linked list of ABC_FREE entries *((char **)pEntry) = p->pEntriesFree; p->pEntriesFree = pEntry; } @@ -274,7 +274,7 @@ void Extra_MmFixedRestart( Extra_MmFixed_t * p ) // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; // transform these entries into a linked list pTemp = p->pChunks[0]; @@ -285,7 +285,7 @@ void Extra_MmFixedRestart( Extra_MmFixed_t * p ) } // set the last link *((char **)pTemp) = NULL; - // set the free entry list + // set the ABC_FREE entry list p->pEntriesFree = p->pChunks[0]; // set the correct statistics p->nMemoryAlloc = p->nEntrySize * p->nChunkSize; @@ -342,7 +342,7 @@ Extra_MmFlex_t * Extra_MmFlexStart() { Extra_MmFlex_t * p; //printf( "allocing flex\n" ); - p = ALLOC( Extra_MmFlex_t, 1 ); + p = ABC_ALLOC( Extra_MmFlex_t, 1 ); memset( p, 0, sizeof(Extra_MmFlex_t) ); p->nEntriesUsed = 0; @@ -352,7 +352,7 @@ Extra_MmFlex_t * Extra_MmFlexStart() p->nChunkSize = (1 << 12); p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -396,9 +396,9 @@ void Extra_MmFlexStop( Extra_MmFlex_t * p ) return; //printf( "deleting flex\n" ); for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -415,13 +415,13 @@ void Extra_MmFlexStop( Extra_MmFlex_t * p ) char * Extra_MmFlexEntryFetch( Extra_MmFlex_t * p, int nBytes ) { char * pTemp; - // check if there are still free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } if ( nBytes > p->nChunkSize ) { @@ -429,7 +429,7 @@ char * Extra_MmFlexEntryFetch( Extra_MmFlex_t * p, int nBytes ) // (ideally, this should never happen) p->nChunkSize = 2 * nBytes; } - p->pCurrent = ALLOC( char, p->nChunkSize ); + p->pCurrent = ABC_ALLOC( char, p->nChunkSize ); p->pEnd = p->pCurrent + p->nChunkSize; p->nMemoryAlloc += p->nChunkSize; // add the chunk to the chunk storage @@ -479,7 +479,7 @@ int Extra_MmFlexReadMemUsage( Extra_MmFlex_t * p ) 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 free()ed.] + entries are handed over to malloc() and then ABC_FREE()ed.] SideEffects [] @@ -490,16 +490,16 @@ Extra_MmStep_t * Extra_MmStepStart( int nSteps ) { Extra_MmStep_t * p; int i, k; - p = ALLOC( Extra_MmStep_t, 1 ); + p = ABC_ALLOC( Extra_MmStep_t, 1 ); memset( p, 0, sizeof(Extra_MmStep_t) ); p->nMems = nSteps; // start the fixed memory managers - p->pMems = ALLOC( Extra_MmFixed_t *, p->nMems ); + p->pMems = ABC_ALLOC( Extra_MmFixed_t *, p->nMems ); for ( i = 0; i < p->nMems; i++ ) p->pMems[i] = Extra_MmFixedStart( (8<nMapSize = (4<nMems); - p->pMap = ALLOC( Extra_MmFixed_t *, p->nMapSize+1 ); + p->pMap = ABC_ALLOC( Extra_MmFixed_t *, p->nMapSize+1 ); p->pMap[0] = NULL; for ( k = 1; k <= 4; k++ ) p->pMap[k] = p->pMems[0]; @@ -530,12 +530,12 @@ void Extra_MmStepStop( Extra_MmStep_t * p ) if ( p->pLargeChunks ) { for ( i = 0; i < p->nLargeChunks; i++ ) - free( p->pLargeChunks[i] ); - free( p->pLargeChunks ); + ABC_FREE( p->pLargeChunks[i] ); + ABC_FREE( p->pLargeChunks ); } - free( p->pMems ); - free( p->pMap ); - free( p ); + ABC_FREE( p->pMems ); + ABC_FREE( p->pMap ); + ABC_FREE( p ); } /**Function************************************************************* @@ -556,15 +556,15 @@ char * Extra_MmStepEntryFetch( Extra_MmStep_t * p, int nBytes ) if ( nBytes > p->nMapSize ) { // printf( "Allocating %d bytes.\n", nBytes ); -// return ALLOC( char, nBytes ); +// return ABC_ALLOC( char, nBytes ); if ( p->nLargeChunks == p->nLargeChunksAlloc ) { if ( p->nLargeChunksAlloc == 0 ) p->nLargeChunksAlloc = 32; p->nLargeChunksAlloc *= 2; - p->pLargeChunks = REALLOC( void *, p->pLargeChunks, p->nLargeChunksAlloc ); + p->pLargeChunks = ABC_REALLOC( void *, p->pLargeChunks, p->nLargeChunksAlloc ); } - p->pLargeChunks[ p->nLargeChunks++ ] = ALLOC( char, nBytes ); + p->pLargeChunks[ p->nLargeChunks++ ] = ABC_ALLOC( char, nBytes ); return p->pLargeChunks[ p->nLargeChunks - 1 ]; } return Extra_MmFixedEntryFetch( p->pMap[nBytes] ); @@ -588,7 +588,7 @@ void Extra_MmStepEntryRecycle( Extra_MmStep_t * p, char * pEntry, int nBytes ) return; if ( nBytes > p->nMapSize ) { -// free( pEntry ); +// ABC_FREE( pEntry ); return; } Extra_MmFixedEntryRecycle( p->pMap[nBytes], pEntry ); diff --git a/src/misc/extra/extraUtilMisc.c b/src/misc/extra/extraUtilMisc.c index 48fca0ba..293b23e7 100644 --- a/src/misc/extra/extraUtilMisc.c +++ b/src/misc/extra/extraUtilMisc.c @@ -265,8 +265,8 @@ 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 free the resulting array, - call free() on the pointer returned by this procedure.] + two-dimentional array of the size: n! x n. To ABC_FREE the resulting array, + call ABC_FREE() on the pointer returned by this procedure.] SideEffects [] @@ -397,8 +397,8 @@ unsigned Extra_TruthPermute( unsigned Truth, char * pPerms, int nVars, int fReve assert( nVars < 6 ); nMints = (1 << nVars); - pMints = ALLOC( int, nMints ); - pMintsP = ALLOC( int, nMints ); + pMints = ABC_ALLOC( int, nMints ); + pMintsP = ABC_ALLOC( int, nMints ); for ( i = 0; i < nMints; i++ ) pMints[i] = i; @@ -418,8 +418,8 @@ unsigned Extra_TruthPermute( unsigned Truth, char * pPerms, int nVars, int fReve Result |= (1 << pMintsP[m]); } - free( pMints ); - free( pMintsP ); + ABC_FREE( pMints ); + ABC_FREE( pMintsP ); return Result; } @@ -546,7 +546,7 @@ unsigned Extra_TruthCanonP( unsigned uTruth, int nVars ) } else if ( nVarsOld != nVars ) { - free( pPerms ); + ABC_FREE( pPerms ); nPerms = Extra_Factorial( nVars ); pPerms = Extra_Permutations( nVars ); nVarsOld = nVars; @@ -589,7 +589,7 @@ unsigned Extra_TruthCanonNP( unsigned uTruth, int nVars ) } else if ( nVarsOld != nVars ) { - free( pPerms ); + ABC_FREE( pPerms ); nPerms = Extra_Factorial( nVars ); pPerms = Extra_Permutations( nVars ); nVarsOld = nVars; @@ -637,7 +637,7 @@ unsigned Extra_TruthCanonNPN( unsigned uTruth, int nVars ) } else if ( nVarsOld != nVars ) { - free( pPerms ); + ABC_FREE( pPerms ); nPerms = Extra_Factorial( nVars ); pPerms = Extra_Permutations( nVars ); nVarsOld = nVars; @@ -687,10 +687,10 @@ void Extra_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** p int i, k; nFuncs = (1 << 16); - uCanons = ALLOC( unsigned short, nFuncs ); - uPhases = ALLOC( char, nFuncs ); - uPerms = ALLOC( char, nFuncs ); - uMap = ALLOC( unsigned char, nFuncs ); + 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 ); @@ -751,23 +751,23 @@ void Extra_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** p } uPhases[(1<<16)-1] = 16; assert( nClasses == 222 ); - free( pPerms4 ); + ABC_FREE( pPerms4 ); if ( puCanons ) *puCanons = uCanons; else - free( uCanons ); + ABC_FREE( uCanons ); if ( puPhases ) *puPhases = uPhases; else - free( uPhases ); + ABC_FREE( uPhases ); if ( puPerms ) *puPerms = uPerms; else - free( uPerms ); + ABC_FREE( uPerms ); if ( puMap ) *puMap = uMap; else - free( uMap ); + ABC_FREE( uMap ); } /**Function************************************************************* @@ -790,9 +790,9 @@ void Extra_Truth3VarN( unsigned ** puCanons, char *** puPhases, char ** ppCounte int nFuncs, nClasses, i; nFuncs = (1 << 8); - uCanons = ALLOC( unsigned, nFuncs ); + uCanons = ABC_ALLOC( unsigned, nFuncs ); memset( uCanons, 0, sizeof(unsigned) * nFuncs ); - pCounters = ALLOC( char, nFuncs ); + pCounters = ABC_ALLOC( char, nFuncs ); memset( pCounters, 0, sizeof(char) * nFuncs ); uPhases = (char **)Extra_ArrayAlloc( nFuncs, nPhasesMax, sizeof(char) ); nClasses = 0; @@ -826,15 +826,15 @@ void Extra_Truth3VarN( unsigned ** puCanons, char *** puPhases, char ** ppCounte if ( puCanons ) *puCanons = uCanons; else - free( uCanons ); + ABC_FREE( uCanons ); if ( puPhases ) *puPhases = uPhases; else - free( uPhases ); + ABC_FREE( uPhases ); if ( ppCounters ) *ppCounters = pCounters; else - free( pCounters ); + ABC_FREE( pCounters ); // printf( "The number of 3N-classes = %d.\n", nClasses ); } @@ -857,9 +857,9 @@ void Extra_Truth4VarN( unsigned short ** puCanons, char *** puPhases, char ** pp int nFuncs, nClasses, i; nFuncs = (1 << 16); - uCanons = ALLOC( unsigned short, nFuncs ); + uCanons = ABC_ALLOC( unsigned short, nFuncs ); memset( uCanons, 0, sizeof(unsigned short) * nFuncs ); - pCounters = ALLOC( char, nFuncs ); + pCounters = ABC_ALLOC( char, nFuncs ); memset( pCounters, 0, sizeof(char) * nFuncs ); uPhases = (char **)Extra_ArrayAlloc( nFuncs, nPhasesMax, sizeof(char) ); nClasses = 0; @@ -892,15 +892,15 @@ void Extra_Truth4VarN( unsigned short ** puCanons, char *** puPhases, char ** pp if ( puCanons ) *puCanons = uCanons; else - free( uCanons ); + ABC_FREE( uCanons ); if ( puPhases ) *puPhases = uPhases; else - free( uPhases ); + ABC_FREE( uPhases ); if ( ppCounters ) *ppCounters = pCounters; else - free( pCounters ); + ABC_FREE( pCounters ); // printf( "The number of 4N-classes = %d.\n", nClasses ); } @@ -921,7 +921,7 @@ void ** Extra_ArrayAlloc( int nCols, int nRows, int Size ) char * pBuffer; int i; assert( nCols > 0 && nRows > 0 && Size > 0 ); - pBuffer = ALLOC( char, nCols * (sizeof(void *) + nRows * Size) ); + pBuffer = ABC_ALLOC( char, nCols * (sizeof(void *) + nRows * Size) ); pRes = (void **)pBuffer; pRes[0] = pBuffer + nCols * sizeof(void *); for ( i = 1; i < nCols; i++ ) diff --git a/src/misc/extra/extraUtilProgress.c b/src/misc/extra/extraUtilProgress.c index 6b6d5132..5e3b0f06 100644 --- a/src/misc/extra/extraUtilProgress.c +++ b/src/misc/extra/extraUtilProgress.c @@ -62,7 +62,7 @@ ProgressBar * Extra_ProgressBarStart( FILE * pFile, int nItemsTotal ) extern void * Abc_FrameGetGlobalFrame(); if ( !Abc_FrameShowProgress(Abc_FrameGetGlobalFrame()) ) return NULL; - p = ALLOC( ProgressBar, 1 ); + p = ABC_ALLOC( ProgressBar, 1 ); memset( p, 0, sizeof(ProgressBar) ); p->pFile = pFile; p->nItemsTotal = nItemsTotal; @@ -118,7 +118,7 @@ void Extra_ProgressBarStop( ProgressBar * p ) { if ( p == NULL ) return; Extra_ProgressBarClean( p ); - FREE( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/misc/extra/extraUtilReader.c b/src/misc/extra/extraUtilReader.c index b6a53fbc..46179e50 100644 --- a/src/misc/extra/extraUtilReader.c +++ b/src/misc/extra/extraUtilReader.c @@ -96,7 +96,7 @@ Extra_FileReader_t * Extra_FileReaderAlloc( char * pFileName, return NULL; } // start the file reader - p = ALLOC( Extra_FileReader_t, 1 ); + p = ABC_ALLOC( Extra_FileReader_t, 1 ); memset( p, 0, sizeof(Extra_FileReader_t) ); p->pFileName = pFileName; p->pFile = pFile; @@ -113,7 +113,7 @@ Extra_FileReader_t * Extra_FileReaderAlloc( char * pFileName, p->nFileSize = ftell( pFile ); rewind( pFile ); // allocate the buffer - p->pBuffer = ALLOC( char, EXTRA_BUFFER_SIZE+1 ); + p->pBuffer = ABC_ALLOC( char, EXTRA_BUFFER_SIZE+1 ); p->nBufferSize = EXTRA_BUFFER_SIZE; p->pBufferCur = p->pBuffer; // determine how many chars to read @@ -146,10 +146,10 @@ void Extra_FileReaderFree( Extra_FileReader_t * p ) { if ( p->pFile ) fclose( p->pFile ); - FREE( p->pBuffer ); + ABC_FREE( p->pBuffer ); Vec_PtrFree( p->vTokens ); Vec_IntFree( p->vLines ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/misc/extra/extraUtilUtil.c b/src/misc/extra/extraUtilUtil.c index 7165a0cd..3f0dd365 100644 --- a/src/misc/extra/extraUtilUtil.c +++ b/src/misc/extra/extraUtilUtil.c @@ -169,7 +169,7 @@ char * Extra_UtilStrsav( char *s ) return s; } else { - return strcpy(ALLOC(char, strlen(s)+1), s); + return strcpy(ABC_ALLOC(char, strlen(s)+1), s); } } @@ -199,7 +199,7 @@ char * Extra_UtilTildeExpand( char *fname ) home = getenv("HOME"); length = n_tildes * strlen(home) + strlen(fname); - expanded = ALLOC(char, length + 1); + expanded = ABC_ALLOC(char, length + 1); j = 0; for (i = 0; i < (int)strlen(fname); i++){ @@ -279,22 +279,22 @@ char * Extra_UtilFileSearch(char *file, char *path, char *mode) if (strcmp(path, ".") == 0) { buffer = Extra_UtilStrsav(file); } else { - buffer = ALLOC(char, strlen(path) + strlen(file) + 4); + buffer = ABC_ALLOC(char, strlen(path) + strlen(file) + 4); (void) sprintf(buffer, "%s/%s", path, file); } filename = Extra_UtilTildeExpand(buffer); - FREE(buffer); + ABC_FREE(buffer); /* see if we can access it */ if (Extra_UtilCheckFile(filename, mode)) { - FREE(save_path); + ABC_FREE(save_path); return filename; } - FREE(filename); + ABC_FREE(filename); path = ++cp; } while (! quit); - FREE(save_path); + ABC_FREE(save_path); return 0; } @@ -390,7 +390,7 @@ double Extra_CpuTimeDouble() ***********************************************************************/ void Extra_MemTest() { - malloc( 1002 ); + ABC_ALLOC( char, 1002 ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/hash/hash.h b/src/misc/hash/hash.h index 90e72868..dad4db18 100644 --- a/src/misc/hash/hash.h +++ b/src/misc/hash/hash.h @@ -21,13 +21,14 @@ #ifndef __HASH_H__ #define __HASH_H__ +#ifdef _WIN32 +#define inline __inline // compatible with MS VS 6.0 +#endif //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// -#ifdef _WIN32 -#define inline __inline // compatible with MS VS 6.0 -#endif +#include "abc_global.h" #include "hashInt.h" #include "hashFlt.h" @@ -45,16 +46,12 @@ /// MACRO DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#ifndef ABS -#define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif - //////////////////////////////////////////////////////////////////////// /// FUNCTION DECLARATIONS /// //////////////////////////////////////////////////////////////////////// int Hash_DefaultHashFunc(int key, int nBins) { - return ABS( ( (key+11)*(key)*7+3 ) % nBins ); + return ABC_ABS( ( (key+11)*(key)*7+3 ) % nBins ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/hash/hashFlt.h b/src/misc/hash/hashFlt.h index da20ee28..43b9dd7f 100644 --- a/src/misc/hash/hashFlt.h +++ b/src/misc/hash/hashFlt.h @@ -86,11 +86,11 @@ static inline Hash_Flt_t * Hash_FltAlloc( int nBins ) Hash_Flt_t * p; int i; assert(nBins > 0); - p = ALLOC( Hash_Flt_t, 1); + p = ABC_ALLOC( Hash_Flt_t, 1); p->nBins = nBins; p->fHash = Hash_DefaultHashFunc; p->nSize = 0; - p->pArray = ALLOC( Hash_Flt_Entry_t *, nBins ); + p->pArray = ABC_ALLOC( Hash_Flt_Entry_t *, nBins ); for(i=0; ipArray[i] = NULL; @@ -164,7 +164,7 @@ static inline void Hash_FltWriteEntry( Hash_Flt_t *p, int key, float data ) // this key does not currently exist // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Flt_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Flt_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = data; @@ -206,7 +206,7 @@ static inline float Hash_FltEntry( Hash_Flt_t *p, int key, int fCreate ) if (fCreate) { // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Flt_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Flt_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = 0.0; @@ -249,7 +249,7 @@ static inline float* Hash_FltEntryPtr( Hash_Flt_t *p, int key ) // this key does not currently exist // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Flt_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Flt_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = 0.0; @@ -283,7 +283,7 @@ static inline void Hash_FltRemove( Hash_Flt_t *p, int key ) if (pEntry->key == key) { p->nSize--; *pLast = pEntry->pNext; - FREE( pEntry ); + ABC_FREE( pEntry ); return; } pLast = &(pEntry->pNext); @@ -309,18 +309,18 @@ static inline void Hash_FltFree( Hash_Flt_t *p ) { int bin; Hash_Flt_Entry_t *pEntry; - // free bins + // ABC_FREE bins for(bin = 0; bin < p->nBins; bin++) { pEntry = p->pArray[bin]; while(pEntry) { pEntry = pEntry->pNext; - FREE( pEntry ); + ABC_FREE( pEntry ); } } - // free hash - FREE( p->pArray ); - FREE( p ); + // ABC_FREE hash + ABC_FREE( p->pArray ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/hash/hashInt.h b/src/misc/hash/hashInt.h index b7ec8a8c..7993e562 100644 --- a/src/misc/hash/hashInt.h +++ b/src/misc/hash/hashInt.h @@ -86,11 +86,11 @@ static inline Hash_Int_t * Hash_IntAlloc( int nBins ) Hash_Int_t * p; int i; assert(nBins > 0); - p = ALLOC( Hash_Int_t, 1); + p = ABC_ALLOC( Hash_Int_t, 1); p->nBins = nBins; p->fHash = Hash_DefaultHashFunc; p->nSize = 0; - p->pArray = ALLOC( Hash_Int_Entry_t *, nBins+1 ); + p->pArray = ABC_ALLOC( Hash_Int_Entry_t *, nBins+1 ); for(i=0; ipArray[i] = NULL; @@ -164,7 +164,7 @@ static inline void Hash_IntWriteEntry( Hash_Int_t *p, int key, int data ) // this key does not currently exist // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Int_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Int_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = data; @@ -206,7 +206,7 @@ static inline int Hash_IntEntry( Hash_Int_t *p, int key, int fCreate ) if (fCreate) { // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Int_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Int_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = 0; @@ -249,7 +249,7 @@ static inline int* Hash_IntEntryPtr( Hash_Int_t *p, int key ) // this key does not currently exist // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Int_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Int_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = 0; @@ -272,19 +272,19 @@ static inline void Hash_IntFree( Hash_Int_t *p ) { int bin; Hash_Int_Entry_t *pEntry, *pTemp; - // free bins + // ABC_FREE bins for(bin = 0; bin < p->nBins; bin++) { pEntry = p->pArray[bin]; while(pEntry) { pTemp = pEntry; pEntry = pEntry->pNext; - FREE( pTemp ); + ABC_FREE( pTemp ); } } - // free hash - FREE( p->pArray ); - FREE( p ); + // ABC_FREE hash + ABC_FREE( p->pArray ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/hash/hashPtr.h b/src/misc/hash/hashPtr.h index 15398a8a..224e5c84 100644 --- a/src/misc/hash/hashPtr.h +++ b/src/misc/hash/hashPtr.h @@ -86,11 +86,11 @@ static inline Hash_Ptr_t * Hash_PtrAlloc( int nBins ) Hash_Ptr_t * p; int i; assert(nBins > 0); - p = ALLOC( Hash_Ptr_t, 1); + p = ABC_ALLOC( Hash_Ptr_t, 1); p->nBins = nBins; p->fHash = Hash_DefaultHashFunc; p->nSize = 0; - p->pArray = ALLOC( Hash_Ptr_Entry_t *, nBins ); + p->pArray = ABC_ALLOC( Hash_Ptr_Entry_t *, nBins ); for(i=0; ipArray[i] = NULL; @@ -164,7 +164,7 @@ static inline void Hash_PtrWriteEntry( Hash_Ptr_t *p, int key, void * data ) // this key does not currently exist // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Ptr_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Ptr_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = data; @@ -206,7 +206,7 @@ static inline void * Hash_PtrEntry( Hash_Ptr_t *p, int key, int fCreate ) if (fCreate) { // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Ptr_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Ptr_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = NULL; @@ -249,7 +249,7 @@ static inline void** Hash_PtrEntryPtr( Hash_Ptr_t *p, int key ) // this key does not currently exist // create a new entry and add to bin p->nSize++; - (*pLast) = pEntry = ALLOC( Hash_Ptr_Entry_t, 1 ); + (*pLast) = pEntry = ABC_ALLOC( Hash_Ptr_Entry_t, 1 ); pEntry->pNext = NULL; pEntry->key = key; pEntry->data = NULL; @@ -310,18 +310,18 @@ static inline void Hash_PtrFree( Hash_Ptr_t *p ) { int bin; Hash_Ptr_Entry_t *pEntry; - // free bins + // ABC_FREE bins for(bin = 0; bin < p->nBins; bin++) { pEntry = p->pArray[bin]; while(pEntry) { pEntry = pEntry->pNext; - FREE( pEntry ); + ABC_FREE( pEntry ); } } - // free hash - FREE( p->pArray ); - FREE( p ); + // ABC_FREE hash + ABC_FREE( p->pArray ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/mvc/mvc.h b/src/misc/mvc/mvc.h index 70834e0a..4cc765b2 100644 --- a/src/misc/mvc/mvc.h +++ b/src/misc/mvc/mvc.h @@ -561,8 +561,8 @@ struct MvcManagerStruct // macros which work with memory // MEM_ALLOC: allocate the given number (Size) of items of type (Type) // MEM_FREE: deallocate the pointer (Pointer) to the given number (Size) of items of type (Type) -#define MEM_ALLOC( Manager, Type, Size ) ((Type *)malloc( (Size) * sizeof(Type) )) -#define MEM_FREE( Manager, Type, Size, Pointer ) if ( Pointer ) { free(Pointer); Pointer = NULL; } +#define MEM_ALLOC( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, (Size) * sizeof(Type) )) +#define MEM_FREE( Manager, Type, Size, Pointer ) if ( Pointer ) { ABC_FREE(Pointer); Pointer = NULL; } //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// diff --git a/src/misc/mvc/mvcContain.c b/src/misc/mvc/mvcContain.c index a9eae06e..950a80a2 100644 --- a/src/misc/mvc/mvcContain.c +++ b/src/misc/mvc/mvcContain.c @@ -4,7 +4,7 @@ PackageName [MVSIS 2.0: Multi-valued logic synthesis system.] - Synopsis [Making the cover single-cube containment free.] + Synopsis [Making the cover single-cube containment ABC_FREE.] Author [MVSIS Group] diff --git a/src/misc/mvc/mvcCover.c b/src/misc/mvc/mvcCover.c index d8584446..bad76170 100644 --- a/src/misc/mvc/mvcCover.c +++ b/src/misc/mvc/mvcCover.c @@ -44,7 +44,7 @@ Mvc_Cover_t * Mvc_CoverAlloc( Mvc_Manager_t * pMem, int nBits ) nBitsInUnsigned = 8 * sizeof(Mvc_CubeWord_t); #ifdef USE_SYSTEM_MEMORY_MANAGEMENT - p = (Mvc_Cover_t *)malloc( sizeof(Mvc_Cover_t) ); + p = (Mvc_Cover_t *)ABC_ALLOC( char, sizeof(Mvc_Cover_t) ); #else p = (Mvc_Cover_t *)Extra_MmFixedEntryFetch( pMem->pManC ); #endif @@ -77,7 +77,7 @@ Mvc_Cover_t * Mvc_CoverClone( Mvc_Cover_t * p ) { Mvc_Cover_t * pCover; #ifdef USE_SYSTEM_MEMORY_MANAGEMENT - pCover = (Mvc_Cover_t *)malloc( sizeof(Mvc_Cover_t) ); + pCover = (Mvc_Cover_t *)ABC_ALLOC( char, sizeof(Mvc_Cover_t) ); #else pCover = (Mvc_Cover_t *)Extra_MmFixedEntryFetch( p->pMem->pManC ); #endif @@ -144,7 +144,7 @@ void Mvc_CoverFree( Mvc_Cover_t * p ) MEM_FREE( p->pMem, int, p->nBits, p->pLits ); #ifdef USE_SYSTEM_MEMORY_MANAGEMENT - free( p ); + ABC_FREE( p ); #else Extra_MmFixedEntryRecycle( p->pMem->pManC, (char *)p ); #endif diff --git a/src/misc/mvc/mvcCube.c b/src/misc/mvc/mvcCube.c index e157879f..9ccdb427 100644 --- a/src/misc/mvc/mvcCube.c +++ b/src/misc/mvc/mvcCube.c @@ -45,9 +45,9 @@ Mvc_Cube_t * Mvc_CubeAlloc( Mvc_Cover_t * pCover ) // allocate the cube #ifdef USE_SYSTEM_MEMORY_MANAGEMENT if ( pCover->nWords == 0 ) - pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) ); + pCube = (Mvc_Cube_t *)ABC_ALLOC( char, sizeof(Mvc_Cube_t) ); else - pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); + pCube = (Mvc_Cube_t *)ABC_ALLOC( char, sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); #else switch( pCover->nWords ) { @@ -63,7 +63,7 @@ Mvc_Cube_t * Mvc_CubeAlloc( Mvc_Cover_t * pCover ) pCube = (Mvc_Cube_t *)Extra_MmFixedEntryFetch( pCover->pMem->pMan4 ); break; default: - pCube = (Mvc_Cube_t *)malloc( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); + pCube = (Mvc_Cube_t *)ABC_ALLOC( char, sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) * (pCover->nWords - 1) ); break; } #endif @@ -119,7 +119,7 @@ void Mvc_CubeFree( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube ) // deallocate the cube #ifdef USE_SYSTEM_MEMORY_MANAGEMENT - free( pCube ); + ABC_FREE( pCube ); #else switch( pCover->nWords ) { @@ -135,7 +135,7 @@ void Mvc_CubeFree( Mvc_Cover_t * pCover, Mvc_Cube_t * pCube ) Extra_MmFixedEntryRecycle( pCover->pMem->pMan4, (char *)pCube ); break; default: - free( pCube ); + ABC_FREE( pCube ); break; } #endif diff --git a/src/misc/mvc/mvcDivisor.c b/src/misc/mvc/mvcDivisor.c index ecdea75b..1ce556a5 100644 --- a/src/misc/mvc/mvcDivisor.c +++ b/src/misc/mvc/mvcDivisor.c @@ -76,7 +76,7 @@ void Mvc_CoverDivisorZeroKernel( Mvc_Cover_t * pCover ) // iLit = Mvc_CoverBestLiteral( pCover, NULL ); if ( iLit == -1 ) return; - // derive the cube-free quotient + // derive the cube-ABC_FREE quotient Mvc_CoverDivideByLiteralQuo( pCover, iLit ); // the same cover Mvc_CoverMakeCubeFree( pCover ); // the same cover // call recursively diff --git a/src/misc/mvc/mvcMan.c b/src/misc/mvc/mvcMan.c index 7b4ef2af..168410a4 100644 --- a/src/misc/mvc/mvcMan.c +++ b/src/misc/mvc/mvcMan.c @@ -41,7 +41,7 @@ Mvc_Manager_t * Mvc_ManagerStart() { Mvc_Manager_t * p; - p = ALLOC( Mvc_Manager_t, 1 ); + p = ABC_ALLOC( Mvc_Manager_t, 1 ); memset( p, 0, sizeof(Mvc_Manager_t) ); p->pMan1 = Extra_MmFixedStart( sizeof(Mvc_Cube_t) ); p->pMan2 = Extra_MmFixedStart( sizeof(Mvc_Cube_t) + sizeof(Mvc_CubeWord_t) ); @@ -67,7 +67,7 @@ void Mvc_ManagerFree( Mvc_Manager_t * p ) Extra_MmFixedStop( p->pMan2 ); Extra_MmFixedStop( p->pMan4 ); Extra_MmFixedStop( p->pManC ); - free( p ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/mvc/mvcUtils.c b/src/misc/mvc/mvcUtils.c index 4b13b23d..bb4b1191 100644 --- a/src/misc/mvc/mvcUtils.c +++ b/src/misc/mvc/mvcUtils.c @@ -329,7 +329,7 @@ int Mvc_CoverGetCubeSize( Mvc_Cube_t * pCube ) entries as there are different pairs of cubes in the cover: n(n-1)/2. Fills out the array pDiffs with the following info: For each cube pair, included in the array is the number of literals in both cubes - after they are made cube free.] + after they are made cube ABC_FREE.] SideEffects [] @@ -671,7 +671,7 @@ Mvc_Cover_t ** Mvc_CoverCofactors( Mvc_Data_t * pData, Mvc_Cover_t * pCover, int // start the covers for cofactors iValueFirst = Vm_VarMapReadValuesFirst(pData->pVm, iVar); nValues = Vm_VarMapReadValues(pData->pVm, iVar); - ppCofs = ALLOC( Mvc_Cover_t *, nValues + 1 ); + ppCofs = ABC_ALLOC( Mvc_Cover_t *, nValues + 1 ); for ( i = 0; i <= nValues; i++ ) ppCofs[i] = Mvc_CoverClone( pCover ); diff --git a/src/misc/nm/nm.h b/src/misc/nm/nm.h index c6344bbf..6f46c291 100644 --- a/src/misc/nm/nm.h +++ b/src/misc/nm/nm.h @@ -21,10 +21,6 @@ #ifndef __NM_H__ #define __NM_H__ -#ifdef __cplusplus -extern "C" { -#endif - /* This manager is designed to store ID-to-name and name-to-ID mapping for Boolean networks and And-Inverter Graphs. @@ -54,6 +50,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/nm/nmApi.c b/src/misc/nm/nmApi.c index 576882a7..7f7cbb97 100644 --- a/src/misc/nm/nmApi.c +++ b/src/misc/nm/nmApi.c @@ -43,15 +43,15 @@ Nm_Man_t * Nm_ManCreate( int nSize ) { Nm_Man_t * p; // allocate the table - p = ALLOC( Nm_Man_t, 1 ); + p = ABC_ALLOC( Nm_Man_t, 1 ); memset( p, 0, sizeof(Nm_Man_t) ); // set the parameters p->nSizeFactor = 2; // determined the limit on the grow of data before the table resizes p->nGrowthFactor = 3; // determined how much the table grows after resizing // allocate and clean the bins p->nBins = Cudd_PrimeNm(nSize); - p->pBinsI2N = ALLOC( Nm_Entry_t *, p->nBins ); - p->pBinsN2I = ALLOC( Nm_Entry_t *, p->nBins ); + p->pBinsI2N = ABC_ALLOC( Nm_Entry_t *, p->nBins ); + p->pBinsN2I = ABC_ALLOC( Nm_Entry_t *, p->nBins ); memset( p->pBinsI2N, 0, sizeof(Nm_Entry_t *) * p->nBins ); memset( p->pBinsN2I, 0, sizeof(Nm_Entry_t *) * p->nBins ); // start the memory manager @@ -73,9 +73,9 @@ Nm_Man_t * Nm_ManCreate( int nSize ) void Nm_ManFree( Nm_Man_t * p ) { Extra_MmFlexStop( p->pMem ); - FREE( p->pBinsI2N ); - FREE( p->pBinsN2I ); - FREE( p ); + ABC_FREE( p->pBinsI2N ); + ABC_FREE( p->pBinsN2I ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/misc/nm/nmInt.h b/src/misc/nm/nmInt.h index 028316e1..03948f22 100644 --- a/src/misc/nm/nmInt.h +++ b/src/misc/nm/nmInt.h @@ -21,10 +21,6 @@ #ifndef __NM_INT_H__ #define __NM_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/nm/nmTable.c b/src/misc/nm/nmTable.c index e50388ba..a147b16c 100644 --- a/src/misc/nm/nmTable.c +++ b/src/misc/nm/nmTable.c @@ -259,8 +259,8 @@ clk = clock(); // get the new table size nBinsNew = Cudd_PrimeCopy( p->nGrowthFactor * p->nBins ); // allocate a new array - pBinsNewI2N = ALLOC( Nm_Entry_t *, nBinsNew ); - pBinsNewN2I = ALLOC( Nm_Entry_t *, nBinsNew ); + pBinsNewI2N = ABC_ALLOC( Nm_Entry_t *, nBinsNew ); + pBinsNewN2I = ABC_ALLOC( Nm_Entry_t *, nBinsNew ); memset( pBinsNewI2N, 0, sizeof(Nm_Entry_t *) * nBinsNew ); memset( pBinsNewN2I, 0, sizeof(Nm_Entry_t *) * nBinsNew ); // rehash entries in Id->Name table @@ -285,10 +285,10 @@ clk = clock(); } assert( Counter == p->nEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", p->nBins, nBinsNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( p->pBinsI2N ); - free( p->pBinsN2I ); + ABC_FREE( p->pBinsI2N ); + ABC_FREE( p->pBinsN2I ); p->pBinsI2N = pBinsNewI2N; p->pBinsN2I = pBinsNewN2I; p->nBins = nBinsNew; diff --git a/src/misc/st/st.c b/src/misc/st/st.c index 2798ae99..13445e9e 100644 --- a/src/misc/st/st.c +++ b/src/misc/st/st.c @@ -9,31 +9,13 @@ */ #include #include +#include "abc_global.h" #include "st.h" -#include "port_type.h" - -#ifndef ABS -# define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif - -#ifndef ALLOC -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#endif - -#ifndef FREE -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#endif - -#ifndef REALLOC -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) -#endif #define ST_NUMCMP(x,y) ((x) != (y)) -#define ST_NUMHASH(x,size) (ABS((long)x)%(size)) -//#define ST_PTRHASH(x,size) ((int)((PORT_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007 -#define ST_PTRHASH(x,size) ((int)(((PORT_PTRUINT_T)(x)>>2)%size)) +#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 +#define ST_PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size)) #define EQUAL(func, x, y) \ ((((func) == st_numcmp) || ((func) == st_ptrcmp)) ?\ (ST_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0)) @@ -60,7 +42,7 @@ int reorder_flag; int i; st_table *new; - new = ALLOC(st_table, 1); + new = ABC_ALLOC(st_table, 1); if (new == NULL) { return NULL; } @@ -74,9 +56,9 @@ int reorder_flag; size = 1; } new->num_bins = size; - new->bins = ALLOC(st_table_entry *, size); + new->bins = ABC_ALLOC(st_table_entry *, size); if (new->bins == NULL) { - FREE(new); + ABC_FREE(new); return NULL; } for(i = 0; i < size; i++) { @@ -107,12 +89,12 @@ st_table *table; ptr = table->bins[i]; while (ptr != NULL) { next = ptr->next; - FREE(ptr); + ABC_FREE(ptr); ptr = next; } } - FREE(table->bins); - FREE(table); + ABC_FREE(table->bins); + ABC_FREE(table); } #define PTR_NOT_EQUAL(table, ptr, user_key)\ @@ -184,7 +166,7 @@ int *value; hash_val = do_hash(key,table);\ }\ \ - new = ALLOC(st_table_entry, 1);\ + new = ABC_ALLOC(st_table_entry, 1);\ \ new->key = key;\ new->record = value;\ @@ -214,7 +196,7 @@ char *value; } hash_val = do_hash(key, table); } - new = ALLOC(st_table_entry, 1); + new = ABC_ALLOC(st_table_entry, 1); if (new == NULL) { return ST_OUT_OF_MEM; } @@ -246,7 +228,7 @@ char *value; } } hash_val = do_hash(key, table); - new = ALLOC(st_table_entry, 1); + new = ABC_ALLOC(st_table_entry, 1); if (new == NULL) { return ST_OUT_OF_MEM; } @@ -278,7 +260,7 @@ char ***slot; } hash_val = do_hash(key, table); } - new = ALLOC(st_table_entry, 1); + new = ABC_ALLOC(st_table_entry, 1); if (new == NULL) { return ST_OUT_OF_MEM; } @@ -336,7 +318,7 @@ register st_table *table; table->num_bins += 1; } table->num_entries = 0; - table->bins = ALLOC(st_table_entry *, table->num_bins); + table->bins = ABC_ALLOC(st_table_entry *, table->num_bins); if (table->bins == NULL) { table->bins = old_bins; table->num_bins = old_num_bins; @@ -360,7 +342,7 @@ register st_table *table; ptr = next; } } - FREE(old_bins); + ABC_FREE(old_bins); return 1; } @@ -373,33 +355,33 @@ st_table *old_table; st_table_entry *ptr, *newptr, *next, *new; int i, j, num_bins = old_table->num_bins; - new_table = ALLOC(st_table, 1); + new_table = ABC_ALLOC(st_table, 1); if (new_table == NULL) { return NULL; } *new_table = *old_table; - new_table->bins = ALLOC(st_table_entry *, num_bins); + new_table->bins = ABC_ALLOC(st_table_entry *, num_bins); if (new_table->bins == NULL) { - FREE(new_table); + ABC_FREE(new_table); return NULL; } for(i = 0; i < num_bins ; i++) { new_table->bins[i] = NULL; ptr = old_table->bins[i]; while (ptr != NULL) { - new = ALLOC(st_table_entry, 1); + new = ABC_ALLOC(st_table_entry, 1); if (new == NULL) { for (j = 0; j <= i; j++) { newptr = new_table->bins[j]; while (newptr != NULL) { next = newptr->next; - FREE(newptr); + ABC_FREE(newptr); newptr = next; } } - FREE(new_table->bins); - FREE(new_table); + ABC_FREE(new_table->bins); + ABC_FREE(new_table); return NULL; } *new = *ptr; @@ -432,7 +414,7 @@ char **value; *last = ptr->next; if (value != NULL) *value = ptr->record; *keyp = ptr->key; - FREE(ptr); + ABC_FREE(ptr); table->num_entries--; return 1; } @@ -458,7 +440,7 @@ char **value; *last = ptr->next; if (value != NULL) *value = ptr->record; *keyp = (long) ptr->key; - FREE(ptr); + ABC_FREE(ptr); table->num_entries--; return 1; } @@ -486,7 +468,7 @@ char *arg; case ST_DELETE: *last = ptr->next; table->num_entries--; /* cstevens@ic */ - FREE(ptr); + ABC_FREE(ptr); ptr = *last; } } @@ -547,7 +529,7 @@ st_table *table; { st_generator *gen; - gen = ALLOC(st_generator, 1); + gen = ABC_ALLOC(st_generator, 1); if (gen == NULL) { return NULL; } @@ -622,5 +604,5 @@ void st_free_gen(gen) st_generator *gen; { - FREE(gen); + ABC_FREE(gen); } diff --git a/src/misc/st/stmm.c b/src/misc/st/stmm.c index 7a52c1cd..5aaf8b9d 100644 --- a/src/misc/st/stmm.c +++ b/src/misc/st/stmm.c @@ -10,16 +10,11 @@ #include #include "extra.h" #include "stmm.h" -#include "port_type.h" - -#ifndef ABS -# define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif #define STMM_NUMCMP(x,y) ((x) != (y)) -#define STMM_NUMHASH(x,size) (ABS((long)x)%(size)) -//#define STMM_PTRHASH(x,size) ((int)((PORT_PTRUINT_T)(x)>>2)%size) // 64-bit bug fix 9/17/2007 -#define STMM_PTRHASH(x,size) ((int)(((PORT_PTRUINT_T)(x)>>2)%size)) +#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 +#define STMM_PTRHASH(x,size) ((int)(((ABC_PTRUINT_T)(x)>>2)%size)) #define EQUAL(func, x, y) \ ((((func) == stmm_numcmp) || ((func) == stmm_ptrcmp)) ?\ (STMM_NUMCMP((x),(y)) == 0) : ((*func)((x), (y)) == 0)) @@ -46,7 +41,7 @@ stmm_init_table_with_params (compare, hash, size, density, grow_factor, int i; stmm_table *new; - new = ALLOC (stmm_table, 1); + new = ABC_ALLOC(stmm_table, 1); if (new == NULL) { return NULL; } @@ -60,9 +55,9 @@ stmm_init_table_with_params (compare, hash, size, density, grow_factor, size = 1; } new->num_bins = size; - new->bins = ALLOC (stmm_table_entry *, size); + new->bins = ABC_ALLOC(stmm_table_entry *, size); if (new->bins == NULL) { - FREE (new); + ABC_FREE (new); return NULL; } for (i = 0; i < size; i++) { @@ -99,7 +94,7 @@ stmm_free_table (table) while ( ptr != NULL ) { next = ptr->next; - FREE( ptr ); + ABC_FREE( ptr ); ptr = next; } } @@ -108,8 +103,8 @@ stmm_free_table (table) // added by alanmi if ( table->pMemMan ) Extra_MmFixedStop (table->pMemMan); - FREE (table->bins); - FREE (table); + ABC_FREE (table->bins); + ABC_FREE (table); } // this function recycles all the bins @@ -194,7 +189,7 @@ stmm_lookup_int (table, key, value) } // This macro contained a line -// new = ALLOC(stmm_table_entry, 1); +// new = ABC_ALLOC(stmm_table_entry, 1); // which was modified by alanmi @@ -237,7 +232,7 @@ stmm_insert (table, key, value) hash_val = do_hash (key, table); } -// new = ALLOC( stmm_table_entry, 1 ); +// new = ABC_ALLOC( stmm_table_entry, 1 ); new = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan); if (new == NULL) { return STMM_OUT_OF_MEM; @@ -273,7 +268,7 @@ stmm_add_direct (table, key, value) } hash_val = do_hash (key, table); -// new = ALLOC( stmm_table_entry, 1 ); +// new = ABC_ALLOC( stmm_table_entry, 1 ); new = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan); if (new == NULL) { return STMM_OUT_OF_MEM; @@ -308,7 +303,7 @@ stmm_find_or_add (table, key, slot) hash_val = do_hash (key, table); } - // new = ALLOC( stmm_table_entry, 1 ); + // new = ABC_ALLOC( stmm_table_entry, 1 ); new = (stmm_table_entry *) Extra_MmFixedEntryFetch (table->pMemMan); if (new == NULL) { return STMM_OUT_OF_MEM; @@ -373,7 +368,7 @@ rehash (table) table->num_bins += 1; } table->num_entries = 0; - table->bins = ALLOC (stmm_table_entry *, table->num_bins); + table->bins = ABC_ALLOC(stmm_table_entry *, table->num_bins); if (table->bins == NULL) { table->bins = old_bins; table->num_bins = old_num_bins; @@ -397,7 +392,7 @@ rehash (table) ptr = next; } } - FREE (old_bins); + ABC_FREE (old_bins); return 1; } @@ -410,15 +405,15 @@ stmm_copy (old_table) stmm_table_entry *ptr, /* *newptr, *next, */ *new; int i, /*j, */ num_bins = old_table->num_bins; - new_table = ALLOC (stmm_table, 1); + new_table = ABC_ALLOC(stmm_table, 1); if (new_table == NULL) { return NULL; } *new_table = *old_table; - new_table->bins = ALLOC (stmm_table_entry *, num_bins); + new_table->bins = ABC_ALLOC(stmm_table_entry *, num_bins); if (new_table->bins == NULL) { - FREE (new_table); + ABC_FREE (new_table); return NULL; } @@ -430,7 +425,7 @@ stmm_copy (old_table) new_table->bins[i] = NULL; ptr = old_table->bins[i]; while (ptr != NULL) { -// new = ALLOC( stmm_table_entry, 1 ); +// new = ABC_ALLOC( stmm_table_entry, 1 ); new = (stmm_table_entry *) Extra_MmFixedEntryFetch (new_table-> pMemMan); @@ -443,15 +438,15 @@ stmm_copy (old_table) while ( newptr != NULL ) { next = newptr->next; - FREE( newptr ); + ABC_FREE( newptr ); newptr = next; } } */ Extra_MmFixedStop (new_table->pMemMan); - FREE (new_table->bins); - FREE (new_table); + ABC_FREE (new_table->bins); + ABC_FREE (new_table); return NULL; } *new = *ptr; @@ -485,7 +480,7 @@ stmm_delete (table, keyp, value) if (value != NULL) *value = ptr->record; *keyp = ptr->key; -// FREE( ptr ); +// ABC_FREE( ptr ); Extra_MmFixedEntryRecycle (table->pMemMan, (char *) ptr); table->num_entries--; @@ -514,7 +509,7 @@ stmm_delete_int (table, keyp, value) if (value != NULL) *value = ptr->record; *keyp = (long) ptr->key; -// FREE( ptr ); +// ABC_FREE( ptr ); Extra_MmFixedEntryRecycle (table->pMemMan, (char *) ptr); table->num_entries--; @@ -546,7 +541,7 @@ stmm_foreach (table, func, arg) case STMM_DELETE: *last = ptr->next; table->num_entries--; /* cstevens@ic */ -// FREE( ptr ); +// ABC_FREE( ptr ); Extra_MmFixedEntryRecycle (table->pMemMan, (char *) ptr); ptr = *last; @@ -609,7 +604,7 @@ stmm_init_gen (table) { stmm_generator *gen; - gen = ALLOC (stmm_generator, 1); + gen = ABC_ALLOC(stmm_generator, 1); if (gen == NULL) { return NULL; } @@ -685,5 +680,5 @@ void stmm_free_gen (gen) stmm_generator *gen; { - FREE (gen); + ABC_FREE (gen); } diff --git a/src/misc/st/stmm.h b/src/misc/st/stmm.h index 4330416e..9dede7d8 100644 --- a/src/misc/st/stmm.h +++ b/src/misc/st/stmm.h @@ -14,12 +14,12 @@ #ifndef STMM_INCLUDED #define STMM_INCLUDED +#include "extra.h" + #ifdef __cplusplus extern "C" { #endif -#include "extra.h" - typedef struct stmm_table_entry stmm_table_entry; typedef struct stmm_table stmm_table; typedef struct stmm_generator stmm_generator; diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h new file mode 100644 index 00000000..35a391ba --- /dev/null +++ b/src/misc/util/abc_global.h @@ -0,0 +1,178 @@ +/**CFile**************************************************************** + + FileName [abc_global.h] + + SystemName [ABC: Logic synthesis and verification system.] + + PackageName [Global declarations.] + + Synopsis [Global declarations.] + + Author [Alan Mishchenko] + + Affiliation [UC Berkeley] + + Date [Ver. 1.0. Started - Jan 30, 2009.] + + Revision [$Id: abc_global.h,v 1.00 2009/01/30 00:00:00 alanmi Exp $] + +***********************************************************************/ + +#ifndef __ABC_GLOBAL_H__ +#define __ABC_GLOBAL_H__ + +//////////////////////////////////////////////////////////////////////// +/// 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 : 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 +//#pragma warning( disable : 4273 ) +#endif + +#ifdef WIN32 +#define ABC_DLLEXPORT __declspec(dllexport) +#define ABC_DLLIMPORT __declspec(dllimport) +#else /* defined(WIN32) */ +#define ABC_DLLIMPORT +#endif /* defined(WIN32) */ + +#ifndef ABC_DLL +#define ABC_DLL ABC_DLLIMPORT +#endif + +// catch memory leaks in Visual Studio +#ifdef _DEBUG +#define _CRTDBG_MAP_ALLOC +#include +#endif + +//////////////////////////////////////////////////////////////////////// +/// PARAMETERS /// +//////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif + +//////////////////////////////////////////////////////////////////////// +/// BASIC TYPES /// +//////////////////////////////////////////////////////////////////////// + +/** + * Pointer difference type; replacement for ptrdiff_t. + * This is a signed integral type that is the same size as a pointer. + * NOTE: This type may be different sizes on different platforms. + */ +#if defined(__ccdoc__) +typedef platform_dependent_type ABC_PTRDIFF_T; +#elif defined(LIN64) +typedef long ABC_PTRDIFF_T; +#elif defined(NT64) +typedef long long ABC_PTRDIFF_T; +#elif defined(NT) || defined(LIN) || defined(WIN32) +typedef int ABC_PTRDIFF_T; +#else + #error unknown platform +#endif /* defined(PLATFORM) */ + +/** + * Unsigned integral type that can contain a pointer. + * This is an unsigned integral type that is the same size as a pointer. + * NOTE: This type may be different sizes on different platforms. + */ +#if defined(__ccdoc__) +typedef platform_dependent_type ABC_PTRUINT_T; +#elif defined(LIN64) +typedef unsigned long ABC_PTRUINT_T; +#elif defined(NT64) +typedef unsigned long long ABC_PTRUINT_T; +#elif defined(NT) || defined(LIN) || defined(WIN32) +typedef unsigned int ABC_PTRUINT_T; +#else + #error unknown platform +#endif /* defined(PLATFORM) */ + +/** + * Signed integral type that can contain a pointer. + * This is a signed integral type that is the same size as a pointer. + * NOTE: This type may be different sizes on different platforms. + */ +#if defined(__ccdoc__) +typedef platform_dependent_type ABC_PTRINT_T; +#elif defined(LIN64) +typedef long ABC_PTRINT_T; +#elif defined(NT64) +typedef long long ABC_PTRINT_T; +#elif defined(NT) || defined(LIN) || defined(WIN32) +typedef int ABC_PTRINT_T; +#else + #error unknown platform +#endif /* defined(PLATFORM) */ + +/** + * 64-bit signed integral type. + */ +#if defined(__ccdoc__) +typedef platform_dependent_type ABC_INT64_T; +#elif defined(LIN64) +typedef long ABC_INT64_T; +#elif defined(NT64) || defined(LIN) +typedef long long ABC_INT64_T; +#elif defined(WIN32) || defined(NT) +typedef signed __int64 ABC_INT64_T; +#else + #error unknown platform +#endif /* defined(PLATFORM) */ + +/** + * 64-bit unsigned integral type. + */ +#if defined(__ccdoc__) +typedef platform_dependent_type ABC_UINT64_T; +#elif defined(LIN64) +typedef unsigned long ABC_UINT64_T; +#elif defined(NT64) || defined(LIN) +typedef unsigned long long ABC_UINT64_T; +#elif defined(WIN32) || defined(NT) +typedef unsigned __int64 ABC_UINT64_T; +#else + #error unknown platform +#endif /* defined(PLATFORM) */ + +//////////////////////////////////////////////////////////////////////// +/// 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)) +#define ABC_INFINITY (100000000) + +#define ABC_ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) +#define ABC_CALLOC(type, num) ((type *) calloc((num), sizeof(type))) +#define ABC_FALLOC(type, num) ((type *) memset(malloc(sizeof(type) * (num)), 0xff, sizeof(type) * (num))) +#define ABC_FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) +#define ABC_REALLOC(type, obj, num) \ + ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ + ((type *) malloc(sizeof(type) * (num)))) + +#define ABC_PRT(a,t) (printf("%s = ", (a)), printf("%7.2f sec\n", (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))) + +#ifdef __cplusplus +} +#endif + +#endif + +//////////////////////////////////////////////////////////////////////// +/// END OF FILE /// +//////////////////////////////////////////////////////////////////////// + diff --git a/src/misc/util/port_type.h b/src/misc/util/port_type.h deleted file mode 100644 index 67b7d454..00000000 --- a/src/misc/util/port_type.h +++ /dev/null @@ -1,78 +0,0 @@ -// Portable Data Types - -#ifndef __PORT_TYPE__ -#define __PORT_TYPE__ - -/** - * Pointer difference type; replacement for ptrdiff_t. - * - * This is a signed integral type that is the same size as a pointer. - * - * NOTE: This type may be different sizes on different platforms. - */ -#if defined(__ccdoc__) -typedef platform_dependent_type PORT_PTRDIFF_T; -#elif defined(LIN64) -typedef long PORT_PTRDIFF_T; -#elif defined(NT64) -typedef long long PORT_PTRDIFF_T; -#elif defined(NT) || defined(LIN) || defined(WIN32) -typedef int PORT_PTRDIFF_T; -#else - #error unknown platform -#endif /* defined(PLATFORM) */ - -/** - * Unsigned integral type that can contain a pointer. - * - * This is an unsigned integral type that is the same size as a pointer. - * - * NOTE: This type may be different sizes on different platforms. - */ -#if defined(__ccdoc__) -typedef platform_dependent_type PORT_PTRUINT_T; -#elif defined(LIN64) -typedef unsigned long PORT_PTRUINT_T; -#elif defined(NT64) -typedef unsigned long long PORT_PTRUINT_T; -#elif defined(NT) || defined(LIN) || defined(WIN32) -typedef unsigned int PORT_PTRUINT_T; -#else - #error unknown platform -#endif /* defined(PLATFORM) */ - -/** - * Signed integral type that can contain a pointer. - * - * This is a signed integral type that is the same size as a pointer. - * - * NOTE: This type may be different sizes on different platforms. - */ -#if defined(__ccdoc__) -typedef platform_dependent_type PORT_PTRINT_T; -#elif defined(LIN64) -typedef long PORT_PTRINT_T; -#elif defined(NT64) -typedef long long PORT_PTRINT_T; -#elif defined(NT) || defined(LIN) || defined(WIN32) -typedef int PORT_PTRINT_T; -#else - #error unknown platform -#endif /* defined(PLATFORM) */ - -/** - * 64-bit signed integral type. - */ -#if defined(__ccdoc__) -typedef platform_dependent_type PORT_INT64_T; -#elif defined(LIN64) -typedef long PORT_INT64_T; -#elif defined(NT64) || defined(LIN) -typedef long long PORT_INT64_T; -#elif defined(WIN32) || defined(NT) -typedef signed __int64 PORT_INT64_T; -#else - #error unknown platform -#endif /* defined(PLATFORM) */ - -#endif diff --git a/src/misc/util/util_hack.h b/src/misc/util/util_hack.h index 3fdb7ffb..825c8bee 100644 --- a/src/misc/util/util_hack.h +++ b/src/misc/util/util_hack.h @@ -21,16 +21,17 @@ #ifndef __UTIL_HACK_H__ #define __UTIL_HACK_H__ -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include #include #include #include +#include "abc_global.h" + +#ifdef __cplusplus +extern "C" { +#endif #ifndef EXTERN #define EXTERN extern @@ -60,24 +61,6 @@ extern "C" { # endif #endif -#ifndef ABS -# define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif - -#ifndef MAX -# define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -# define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) - extern long Extra_CpuTime(); extern int Extra_GetSoftDataLimit(); extern void Extra_UtilGetoptReset(); diff --git a/src/misc/vec/vec.h b/src/misc/vec/vec.h index 67ec44aa..915265f3 100644 --- a/src/misc/vec/vec.h +++ b/src/misc/vec/vec.h @@ -21,93 +21,31 @@ #ifndef __VEC_H__ #define __VEC_H__ -#ifdef __cplusplus -extern "C" { -#endif - -#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 : 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 -#endif - -#ifndef SINT64 -#define SINT64 - -#ifdef _WIN32 -typedef signed __int64 sint64; // compatible with MS VS 6.0 -#else -typedef long long sint64; -#endif - -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// -// catch memory leaks in Visual Studio -#ifdef _DEBUG -#define _CRTDBG_MAP_ALLOC -#include -#endif - -//////////////////////////////////////////////////////////////////////// -/// MACRO DEFINITIONS /// -//////////////////////////////////////////////////////////////////////// - -#ifndef ABS -#define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif - -#ifndef MAX -#define MAX(a,b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#endif - -#ifndef ALLOC -#define ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#endif - -#ifndef CALLOC -#define CALLOC(type, num) ((type *) calloc((num), sizeof(type))) -#endif - -#ifndef FREE -#define FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#endif - -#ifndef REALLOC -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) -#endif - -#ifndef PRT -#define PRT(a,t) printf("%s = ", (a)); printf("%7.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)) -#endif - -#ifndef PRTP -#define 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) -#endif - +#include "abc_global.h" #include "vecInt.h" #include "vecFlt.h" #include "vecStr.h" #include "vecPtr.h" #include "vecVec.h" #include "vecAtt.h" -#include "port_type.h" + +//////////////////////////////////////////////////////////////////////// +/// MACRO DEFINITIONS /// +//////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/misc/vec/vecAtt.h b/src/misc/vec/vecAtt.h index 8d0a034b..9129321c 100644 --- a/src/misc/vec/vecAtt.h +++ b/src/misc/vec/vecAtt.h @@ -65,9 +65,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 free the manager + void (*pFuncFreeMan) (void *); // the procedure to ABC_FREE the manager void*(*pFuncStartObj)(void *); // the procedure to start one attribute - void (*pFuncFreeObj) (void *, void *); // the procedure to free one attribute + void (*pFuncFreeObj) (void *, void *); // the procedure to ABC_FREE one attribute }; //////////////////////////////////////////////////////////////////////// @@ -96,14 +96,14 @@ static inline Vec_Att_t * Vec_AttAlloc( void (*pFuncFreeObj) (void *, void *) ) { Vec_Att_t * p; - p = ALLOC( Vec_Att_t, 1 ); + p = ABC_ALLOC( Vec_Att_t, 1 ); memset( p, 0, sizeof(Vec_Att_t) ); p->pMan = pMan; p->pFuncFreeMan = pFuncFreeMan; p->pFuncStartObj = pFuncStartObj; p->pFuncFreeObj = pFuncFreeObj; p->nCap = nSize? nSize : 16; - p->pArrayPtr = ALLOC( void *, p->nCap ); + p->pArrayPtr = ABC_ALLOC( void *, p->nCap ); memset( p->pArrayPtr, 0, sizeof(void *) * p->nCap ); return p; } @@ -124,7 +124,7 @@ static inline void * Vec_AttFree( Vec_Att_t * p, int fFreeMan ) void * pMan; if ( p == NULL ) return NULL; - // free the attributes of objects + // ABC_FREE the attributes of objects if ( p->pFuncFreeObj ) { int i; @@ -132,12 +132,12 @@ static inline void * Vec_AttFree( Vec_Att_t * p, int fFreeMan ) if ( p->pArrayPtr[i] ) p->pFuncFreeObj( p->pMan, p->pArrayPtr[i] ); } - // free the memory manager + // ABC_FREE the memory manager pMan = fFreeMan? NULL : p->pMan; if ( p->pMan && fFreeMan ) p->pFuncFreeMan( p->pMan ); - FREE( p->pArrayPtr ); - FREE( p ); + ABC_FREE( p->pArrayPtr ); + ABC_FREE( p ); return pMan; } @@ -154,7 +154,7 @@ static inline void * Vec_AttFree( Vec_Att_t * p, int fFreeMan ) ***********************************************************************/ static inline void Vec_AttClear( Vec_Att_t * p ) { - // free the attributes of objects + // ABC_FREE the attributes of objects if ( p->pFuncFreeObj ) { int i; @@ -204,7 +204,7 @@ static inline void Vec_AttGrow( Vec_Att_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArrayPtr = REALLOC( void *, p->pArrayPtr, nCapMin ); + p->pArrayPtr = ABC_REALLOC( void *, p->pArrayPtr, nCapMin ); memset( p->pArrayPtr + p->nCap, 0, sizeof(void *) * (nCapMin - p->nCap) ); p->nCap = nCapMin; } diff --git a/src/misc/vec/vecFlt.h b/src/misc/vec/vecFlt.h index 513c7dc6..93402cf2 100644 --- a/src/misc/vec/vecFlt.h +++ b/src/misc/vec/vecFlt.h @@ -74,12 +74,12 @@ struct Vec_Flt_t_ static inline Vec_Flt_t * Vec_FltAlloc( int nCap ) { Vec_Flt_t * p; - p = ALLOC( Vec_Flt_t, 1 ); + p = ABC_ALLOC( Vec_Flt_t, 1 ); if ( nCap > 0 && nCap < 16 ) nCap = 16; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( float, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( float, p->nCap ) : NULL; return p; } @@ -117,7 +117,7 @@ static inline Vec_Flt_t * Vec_FltStart( int nSize ) static inline Vec_Flt_t * Vec_FltAllocArray( float * pArray, int nSize ) { Vec_Flt_t * p; - p = ALLOC( Vec_Flt_t, 1 ); + p = ABC_ALLOC( Vec_Flt_t, 1 ); p->nSize = nSize; p->nCap = nSize; p->pArray = pArray; @@ -138,10 +138,10 @@ static inline Vec_Flt_t * Vec_FltAllocArray( float * pArray, int nSize ) static inline Vec_Flt_t * Vec_FltAllocArrayCopy( float * pArray, int nSize ) { Vec_Flt_t * p; - p = ALLOC( Vec_Flt_t, 1 ); + p = ABC_ALLOC( Vec_Flt_t, 1 ); p->nSize = nSize; p->nCap = nSize; - p->pArray = ALLOC( float, nSize ); + p->pArray = ABC_ALLOC( float, nSize ); memcpy( p->pArray, pArray, sizeof(float) * nSize ); return p; } @@ -160,10 +160,10 @@ static inline Vec_Flt_t * Vec_FltAllocArrayCopy( float * pArray, int nSize ) static inline Vec_Flt_t * Vec_FltDup( Vec_Flt_t * pVec ) { Vec_Flt_t * p; - p = ALLOC( Vec_Flt_t, 1 ); + p = ABC_ALLOC( Vec_Flt_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; - p->pArray = p->nCap? ALLOC( float, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( float, p->nCap ) : NULL; memcpy( p->pArray, pVec->pArray, sizeof(float) * pVec->nSize ); return p; } @@ -182,7 +182,7 @@ static inline Vec_Flt_t * Vec_FltDup( Vec_Flt_t * pVec ) static inline Vec_Flt_t * Vec_FltDupArray( Vec_Flt_t * pVec ) { Vec_Flt_t * p; - p = ALLOC( Vec_Flt_t, 1 ); + p = ABC_ALLOC( Vec_Flt_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; p->pArray = pVec->pArray; @@ -205,8 +205,8 @@ static inline Vec_Flt_t * Vec_FltDupArray( Vec_Flt_t * pVec ) ***********************************************************************/ static inline void Vec_FltFree( Vec_Flt_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -343,7 +343,7 @@ static inline void Vec_FltGrow( Vec_Flt_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( float, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( float, p->pArray, nCapMin ); p->nCap = nCapMin; } diff --git a/src/misc/vec/vecInt.h b/src/misc/vec/vecInt.h index c944df3f..0f7a41ab 100644 --- a/src/misc/vec/vecInt.h +++ b/src/misc/vec/vecInt.h @@ -51,6 +51,8 @@ struct Vec_Int_t_ for ( i = 0; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) #define Vec_IntForEachEntryStart( vVec, Entry, i, Start ) \ for ( i = Start; (i < Vec_IntSize(vVec)) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) +#define Vec_IntForEachEntryStop( vVec, Entry, i, Stop ) \ + for ( i = 0; (i < Stop) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) #define Vec_IntForEachEntryStartStop( vVec, Entry, i, Start, Stop ) \ for ( i = Start; (i < Stop) && (((Entry) = Vec_IntEntry(vVec, i)), 1); i++ ) #define Vec_IntForEachEntryReverse( vVec, pEntry, i ) \ @@ -74,12 +76,12 @@ struct Vec_Int_t_ static inline Vec_Int_t * Vec_IntAlloc( int nCap ) { Vec_Int_t * p; - p = ALLOC( Vec_Int_t, 1 ); + p = ABC_ALLOC( Vec_Int_t, 1 ); if ( nCap > 0 && nCap < 16 ) nCap = 16; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( int, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL; return p; } @@ -139,7 +141,7 @@ static inline Vec_Int_t * Vec_IntStartNatural( int nSize ) static inline Vec_Int_t * Vec_IntAllocArray( int * pArray, int nSize ) { Vec_Int_t * p; - p = ALLOC( Vec_Int_t, 1 ); + p = ABC_ALLOC( Vec_Int_t, 1 ); p->nSize = nSize; p->nCap = nSize; p->pArray = pArray; @@ -160,10 +162,10 @@ static inline Vec_Int_t * Vec_IntAllocArray( int * pArray, int nSize ) static inline Vec_Int_t * Vec_IntAllocArrayCopy( int * pArray, int nSize ) { Vec_Int_t * p; - p = ALLOC( Vec_Int_t, 1 ); + p = ABC_ALLOC( Vec_Int_t, 1 ); p->nSize = nSize; p->nCap = nSize; - p->pArray = ALLOC( int, nSize ); + p->pArray = ABC_ALLOC( int, nSize ); memcpy( p->pArray, pArray, sizeof(int) * nSize ); return p; } @@ -182,10 +184,10 @@ static inline Vec_Int_t * Vec_IntAllocArrayCopy( int * pArray, int nSize ) static inline Vec_Int_t * Vec_IntDup( Vec_Int_t * pVec ) { Vec_Int_t * p; - p = ALLOC( Vec_Int_t, 1 ); + p = ABC_ALLOC( Vec_Int_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nSize; - p->pArray = p->nCap? ALLOC( int, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL; memcpy( p->pArray, pVec->pArray, sizeof(int) * pVec->nSize ); return p; } @@ -204,7 +206,7 @@ static inline Vec_Int_t * Vec_IntDup( Vec_Int_t * pVec ) static inline Vec_Int_t * Vec_IntDupArray( Vec_Int_t * pVec ) { Vec_Int_t * p; - p = ALLOC( Vec_Int_t, 1 ); + p = ABC_ALLOC( Vec_Int_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; p->pArray = pVec->pArray; @@ -227,8 +229,8 @@ static inline Vec_Int_t * Vec_IntDupArray( Vec_Int_t * pVec ) ***********************************************************************/ static inline void Vec_IntFree( Vec_Int_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -366,7 +368,7 @@ static inline void Vec_IntGrow( Vec_Int_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( int, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( int, p->pArray, nCapMin ); assert( p->pArray ); p->nCap = nCapMin; } diff --git a/src/misc/vec/vecPtr.h b/src/misc/vec/vecPtr.h index 27643043..4d09acb7 100644 --- a/src/misc/vec/vecPtr.h +++ b/src/misc/vec/vecPtr.h @@ -77,12 +77,12 @@ struct Vec_Ptr_t_ static inline Vec_Ptr_t * Vec_PtrAlloc( int nCap ) { Vec_Ptr_t * p; - p = ALLOC( Vec_Ptr_t, 1 ); + p = ABC_ALLOC( Vec_Ptr_t, 1 ); if ( nCap > 0 && nCap < 8 ) nCap = 8; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( void *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( void *, p->nCap ) : NULL; return p; } @@ -120,7 +120,7 @@ static inline Vec_Ptr_t * Vec_PtrStart( int nSize ) static inline Vec_Ptr_t * Vec_PtrAllocArray( void ** pArray, int nSize ) { Vec_Ptr_t * p; - p = ALLOC( Vec_Ptr_t, 1 ); + p = ABC_ALLOC( Vec_Ptr_t, 1 ); p->nSize = nSize; p->nCap = nSize; p->pArray = pArray; @@ -141,10 +141,10 @@ static inline Vec_Ptr_t * Vec_PtrAllocArray( void ** pArray, int nSize ) static inline Vec_Ptr_t * Vec_PtrAllocArrayCopy( void ** pArray, int nSize ) { Vec_Ptr_t * p; - p = ALLOC( Vec_Ptr_t, 1 ); + p = ABC_ALLOC( Vec_Ptr_t, 1 ); p->nSize = nSize; p->nCap = nSize; - p->pArray = ALLOC( void *, nSize ); + p->pArray = ABC_ALLOC( void *, nSize ); memcpy( p->pArray, pArray, sizeof(void *) * nSize ); return p; } @@ -163,10 +163,10 @@ static inline Vec_Ptr_t * Vec_PtrAllocArrayCopy( void ** pArray, int nSize ) static inline Vec_Ptr_t * Vec_PtrDup( Vec_Ptr_t * pVec ) { Vec_Ptr_t * p; - p = ALLOC( Vec_Ptr_t, 1 ); + p = ABC_ALLOC( Vec_Ptr_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; - p->pArray = p->nCap? ALLOC( void *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( void *, p->nCap ) : NULL; memcpy( p->pArray, pVec->pArray, sizeof(void *) * pVec->nSize ); return p; } @@ -185,7 +185,7 @@ static inline Vec_Ptr_t * Vec_PtrDup( Vec_Ptr_t * pVec ) static inline Vec_Ptr_t * Vec_PtrDupArray( Vec_Ptr_t * pVec ) { Vec_Ptr_t * p; - p = ALLOC( Vec_Ptr_t, 1 ); + p = ABC_ALLOC( Vec_Ptr_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; p->pArray = pVec->pArray; @@ -208,8 +208,8 @@ static inline Vec_Ptr_t * Vec_PtrDupArray( Vec_Ptr_t * pVec ) ***********************************************************************/ static inline void Vec_PtrFree( Vec_Ptr_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -347,7 +347,7 @@ static inline void Vec_PtrGrow( Vec_Ptr_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( void *, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( void *, p->pArray, nCapMin ); p->nCap = nCapMin; } @@ -678,13 +678,29 @@ static inline Vec_Ptr_t * Vec_PtrAllocSimInfo( int nEntries, int nWords ) void ** pMemory; unsigned * pInfo; int i; - pMemory = (void **)ALLOC( char, (sizeof(void *) + sizeof(unsigned) * nWords) * nEntries ); + pMemory = (void **)ABC_ALLOC( char, (sizeof(void *) + sizeof(unsigned) * nWords) * nEntries ); pInfo = (unsigned *)(pMemory + nEntries); for ( i = 0; i < nEntries; i++ ) pMemory[i] = pInfo + i * nWords; return Vec_PtrAllocArray( pMemory, nEntries ); } +/**Function************************************************************* + + Synopsis [Cleans simulation info of each entry beginning with iWord.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +static inline int Vec_PtrReadWordsSimInfo( Vec_Ptr_t * p ) +{ + return (unsigned *)Vec_PtrEntry(p,1) - (unsigned *)Vec_PtrEntry(p,0); +} + /**Function************************************************************* Synopsis [Cleans simulation info of each entry beginning with iWord.] @@ -743,13 +759,13 @@ static inline void Vec_PtrDoubleSimInfo( Vec_Ptr_t * vInfo ) // copy the simulation info memcpy( Vec_PtrEntry(vInfoNew,0), Vec_PtrEntry(vInfo,0), Vec_PtrSize(vInfo) * nWords * 4 ); // replace the array - free( vInfo->pArray ); + ABC_FREE( vInfo->pArray ); vInfo->pArray = vInfoNew->pArray; vInfo->nSize *= 2; vInfo->nCap *= 2; - // free the old array + // ABC_FREE the old array vInfoNew->pArray = NULL; - free( vInfoNew ); + ABC_FREE( vInfoNew ); } /**Function************************************************************* @@ -775,11 +791,11 @@ static inline void Vec_PtrReallocSimInfo( Vec_Ptr_t * vInfo ) for ( i = 0; i < vInfo->nSize; i++ ) memcpy( Vec_PtrEntry(vInfoNew,i), Vec_PtrEntry(vInfo,i), nWords * 4 ); // replace the array - free( vInfo->pArray ); + ABC_FREE( vInfo->pArray ); vInfo->pArray = vInfoNew->pArray; - // free the old array + // ABC_FREE the old array vInfoNew->pArray = NULL; - free( vInfoNew ); + ABC_FREE( vInfoNew ); } /**Function************************************************************* diff --git a/src/misc/vec/vecStr.h b/src/misc/vec/vecStr.h index a00aaa68..dc0b2bad 100644 --- a/src/misc/vec/vecStr.h +++ b/src/misc/vec/vecStr.h @@ -68,12 +68,12 @@ struct Vec_Str_t_ static inline Vec_Str_t * Vec_StrAlloc( int nCap ) { Vec_Str_t * p; - p = ALLOC( Vec_Str_t, 1 ); + p = ABC_ALLOC( Vec_Str_t, 1 ); if ( nCap > 0 && nCap < 16 ) nCap = 16; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( char, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( char, p->nCap ) : NULL; return p; } @@ -111,7 +111,7 @@ static inline Vec_Str_t * Vec_StrStart( int nSize ) static inline Vec_Str_t * Vec_StrAllocArray( char * pArray, int nSize ) { Vec_Str_t * p; - p = ALLOC( Vec_Str_t, 1 ); + p = ABC_ALLOC( Vec_Str_t, 1 ); p->nSize = nSize; p->nCap = nSize; p->pArray = pArray; @@ -132,10 +132,10 @@ static inline Vec_Str_t * Vec_StrAllocArray( char * pArray, int nSize ) static inline Vec_Str_t * Vec_StrAllocArrayCopy( char * pArray, int nSize ) { Vec_Str_t * p; - p = ALLOC( Vec_Str_t, 1 ); + p = ABC_ALLOC( Vec_Str_t, 1 ); p->nSize = nSize; p->nCap = nSize; - p->pArray = ALLOC( char, nSize ); + p->pArray = ABC_ALLOC( char, nSize ); memcpy( p->pArray, pArray, sizeof(char) * nSize ); return p; } @@ -154,10 +154,10 @@ static inline Vec_Str_t * Vec_StrAllocArrayCopy( char * pArray, int nSize ) static inline Vec_Str_t * Vec_StrDup( Vec_Str_t * pVec ) { Vec_Str_t * p; - p = ALLOC( Vec_Str_t, 1 ); + p = ABC_ALLOC( Vec_Str_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; - p->pArray = p->nCap? ALLOC( char, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( char, p->nCap ) : NULL; memcpy( p->pArray, pVec->pArray, sizeof(char) * pVec->nSize ); return p; } @@ -176,7 +176,7 @@ static inline Vec_Str_t * Vec_StrDup( Vec_Str_t * pVec ) static inline Vec_Str_t * Vec_StrDupArray( Vec_Str_t * pVec ) { Vec_Str_t * p; - p = ALLOC( Vec_Str_t, 1 ); + p = ABC_ALLOC( Vec_Str_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; p->pArray = pVec->pArray; @@ -199,8 +199,8 @@ static inline Vec_Str_t * Vec_StrDupArray( Vec_Str_t * pVec ) ***********************************************************************/ static inline void Vec_StrFree( Vec_Str_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -321,7 +321,7 @@ static inline void Vec_StrGrow( Vec_Str_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( char, p->pArray, 2 * nCapMin ); + p->pArray = ABC_REALLOC( char, p->pArray, 2 * nCapMin ); p->nCap = 2 * nCapMin; } diff --git a/src/misc/vec/vecVec.h b/src/misc/vec/vecVec.h index 0557e9c0..a77cdf76 100644 --- a/src/misc/vec/vecVec.h +++ b/src/misc/vec/vecVec.h @@ -99,12 +99,12 @@ struct Vec_Vec_t_ static inline Vec_Vec_t * Vec_VecAlloc( int nCap ) { Vec_Vec_t * p; - p = ALLOC( Vec_Vec_t, 1 ); + p = ABC_ALLOC( Vec_Vec_t, 1 ); if ( nCap > 0 && nCap < 8 ) nCap = 8; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( void *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( void *, p->nCap ) : NULL; return p; } diff --git a/src/opt/cut/cut.h b/src/opt/cut/cut.h index faa249f2..394138db 100644 --- a/src/opt/cut/cut.h +++ b/src/opt/cut/cut.h @@ -21,10 +21,6 @@ #ifndef __CUT_H__ #define __CUT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #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 diff --git a/src/opt/cut/cutMan.c b/src/opt/cut/cutMan.c index 882567fd..28264e33 100644 --- a/src/opt/cut/cutMan.c +++ b/src/opt/cut/cutMan.c @@ -47,7 +47,7 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams ) // extern int nTruthDsd; // nTruthDsd = 0; assert( pParams->nVarsMax >= 3 && pParams->nVarsMax <= CUT_SIZE_MAX ); - p = ALLOC( Cut_Man_t, 1 ); + p = ABC_ALLOC( Cut_Man_t, 1 ); memset( p, 0, sizeof(Cut_Man_t) ); // set and correct parameters p->pParams = pParams; @@ -82,7 +82,7 @@ Cut_Man_t * Cut_ManStart( Cut_Params_t * pParams ) p->nTruthWords = Cut_TruthWords( pParams->nVarsMax ); p->EntrySize += p->nTruthWords * sizeof(unsigned); } - p->puTemp[0] = ALLOC( unsigned, 4 * p->nTruthWords ); + p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords ); p->puTemp[1] = p->puTemp[0] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords; @@ -132,10 +132,10 @@ void Cut_ManStop( Cut_Man_t * p ) if ( p->vNodeCuts ) Vec_IntFree( p->vNodeCuts ); if ( p->vNodeStarts ) Vec_IntFree( p->vNodeStarts ); if ( p->vCutPairs ) Vec_IntFree( p->vCutPairs ); - if ( p->puTemp[0] ) free( p->puTemp[0] ); + if ( p->puTemp[0] ) ABC_FREE( p->puTemp[0] ); Extra_MmFixedStop( p->pMmCuts ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -176,11 +176,11 @@ void Cut_ManPrintStats( Cut_Man_t * p ) if ( p->pParams->fMap && !p->pParams->fSeq ) printf( "Mapping delay = %8d.\n", p->nDelayMin ); - PRT( "Merge ", p->timeMerge ); - PRT( "Union ", p->timeUnion ); - PRT( "Filter", p->timeFilter ); - PRT( "Truth ", p->timeTruth ); - PRT( "Map ", p->timeMap ); + ABC_PRT( "Merge ", p->timeMerge ); + ABC_PRT( "Union ", p->timeUnion ); + ABC_PRT( "Filter", p->timeFilter ); + ABC_PRT( "Truth ", p->timeTruth ); + ABC_PRT( "Map ", p->timeMap ); // printf( "Nodes = %d. Multi = %d. Cuts = %d. Multi = %d.\n", // p->nNodes, p->nNodesMulti, p->nCutsCur-p->nCutsTriv, p->nCutsMulti ); // printf( "Count0 = %d. Count1 = %d. Count2 = %d.\n\n", p->Count0, p->Count1, p->Count2 ); diff --git a/src/opt/cut/cutOracle.c b/src/opt/cut/cutOracle.c index 4ec6bc05..32798f4f 100644 --- a/src/opt/cut/cutOracle.c +++ b/src/opt/cut/cutOracle.c @@ -74,7 +74,7 @@ Cut_Oracle_t * Cut_OracleStart( Cut_Man_t * pMan ) assert( pMan->pParams->nVarsMax >= 3 && pMan->pParams->nVarsMax <= CUT_SIZE_MAX ); assert( pMan->pParams->fRecord ); - p = ALLOC( Cut_Oracle_t, 1 ); + p = ABC_ALLOC( Cut_Oracle_t, 1 ); memset( p, 0, sizeof(Cut_Oracle_t) ); // set and correct parameters @@ -130,7 +130,7 @@ void Cut_OracleStop( Cut_Oracle_t * p ) { printf( "Cut computation statistics with oracle:\n" ); printf( "Current cuts = %8d. (Trivial = %d.)\n", p->nCuts-p->nCutsTriv, p->nCutsTriv ); - PRT( "Total time ", p->timeTotal ); + ABC_PRT( "Total time ", p->timeTotal ); } Vec_PtrForEachEntry( p->vCutsNew, pCut, i ) @@ -145,7 +145,7 @@ void Cut_OracleStop( Cut_Oracle_t * p ) if ( p->vCutPairs ) Vec_IntFree( p->vCutPairs ); Extra_MmFixedStop( p->pMmCuts ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/opt/cut/cutPre22.c b/src/opt/cut/cutPre22.c index 5ba860c9..bda612f7 100644 --- a/src/opt/cut/cutPre22.c +++ b/src/opt/cut/cutPre22.c @@ -398,7 +398,7 @@ void Cut_CellPrecompute() } printf( "BASIC: Total = %d. Good = %d. Entry = %d. ", (int)p->nTotal, (int)p->nGood, (int)sizeof(Cut_Cell_t) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); printf( "Cells: " ); for ( i = 0; i <= 9; i++ ) printf( "%d=%d ", i, p->nVarCounts[i] ); @@ -482,7 +482,7 @@ void Cut_CellPrecompute() } printf( "VAR %d: Total = %d. Good = %d. Entry = %d. ", k, p->nTotal, p->nGood, (int)sizeof(Cut_Cell_t) ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); printf( "Cells: " ); for ( i = 0; i <= 9; i++ ) printf( "%d=%d ", i, p->nVarCounts[i] ); @@ -495,9 +495,9 @@ void Cut_CellPrecompute() printf( "\n" ); } // printf( "\n" ); - PRT( "Supp ", p->timeSupp ); - PRT( "Canon", p->timeCanon ); - PRT( "Table", p->timeTable ); + ABC_PRT( "Supp ", p->timeSupp ); + ABC_PRT( "Canon", p->timeCanon ); + ABC_PRT( "Table", p->timeTable ); // Cut_CManStop( p ); } @@ -517,7 +517,7 @@ int Cut_CellTableLookup( Cut_CMan_t * p, Cut_Cell_t * pCell ) Cut_Cell_t ** pSlot, * pTemp; unsigned Hash; Hash = Extra_TruthHash( pCell->uTruth, Extra_TruthWordNum( pCell->nVars ) ); - if ( !st_find_or_add( p->tTable, (char *)(PORT_PTRUINT_T)Hash, (char ***)&pSlot ) ) + if ( !st_find_or_add( p->tTable, (char *)(ABC_PTRUINT_T)Hash, (char ***)&pSlot ) ) *pSlot = NULL; for ( pTemp = *pSlot; pTemp; pTemp = pTemp->pNext ) { @@ -770,7 +770,7 @@ Cut_CMan_t * Cut_CManStart() int i, k; // start the manager assert( sizeof(unsigned) == 4 ); - p = ALLOC( Cut_CMan_t, 1 ); + 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); @@ -799,7 +799,7 @@ void Cut_CManStop( Cut_CMan_t * p ) { st_free_table( p->tTable ); Extra_MmFixedStop( p->pMem ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -916,7 +916,7 @@ void Cut_CellDumpToFile() printf( "Library composed of %d functions is written into file \"%s\". ", Counter, pFileName ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } @@ -962,7 +962,7 @@ int Cut_CellTruthLookup( unsigned * pTruth, int nVars ) // check if the cell exists Hash = Extra_TruthHash( pCell->uTruth, Extra_TruthWordNum(pCell->nVars) ); - if ( st_lookup( p->tTable, (char *)(PORT_PTRUINT_T)Hash, (char **)&pTemp ) ) + if ( st_lookup( p->tTable, (char *)(ABC_PTRUINT_T)Hash, (char **)&pTemp ) ) { for ( ; pTemp; pTemp = pTemp->pNext ) { diff --git a/src/opt/dec/dec.h b/src/opt/dec/dec.h index d0d9981d..4042ac65 100644 --- a/src/opt/dec/dec.h +++ b/src/opt/dec/dec.h @@ -21,10 +21,6 @@ #ifndef __DEC_H__ #define __DEC_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -212,12 +212,12 @@ static inline Dec_Edge_t Dec_IntToEdge_( unsigned Edge ) static inline Dec_Graph_t * Dec_GraphCreate( int nLeaves ) { Dec_Graph_t * pGraph; - pGraph = ALLOC( Dec_Graph_t, 1 ); + pGraph = ABC_ALLOC( Dec_Graph_t, 1 ); memset( pGraph, 0, sizeof(Dec_Graph_t) ); pGraph->nLeaves = nLeaves; pGraph->nSize = nLeaves; pGraph->nCap = 2 * nLeaves + 50; - pGraph->pNodes = ALLOC( Dec_Node_t, pGraph->nCap ); + pGraph->pNodes = ABC_ALLOC( Dec_Node_t, pGraph->nCap ); memset( pGraph->pNodes, 0, sizeof(Dec_Node_t) * pGraph->nSize ); return pGraph; } @@ -236,7 +236,7 @@ static inline Dec_Graph_t * Dec_GraphCreate( int nLeaves ) static inline Dec_Graph_t * Dec_GraphCreateConst0() { Dec_Graph_t * pGraph; - pGraph = ALLOC( Dec_Graph_t, 1 ); + pGraph = ABC_ALLOC( Dec_Graph_t, 1 ); memset( pGraph, 0, sizeof(Dec_Graph_t) ); pGraph->fConst = 1; pGraph->eRoot.fCompl = 1; @@ -257,7 +257,7 @@ static inline Dec_Graph_t * Dec_GraphCreateConst0() static inline Dec_Graph_t * Dec_GraphCreateConst1() { Dec_Graph_t * pGraph; - pGraph = ALLOC( Dec_Graph_t, 1 ); + pGraph = ABC_ALLOC( Dec_Graph_t, 1 ); memset( pGraph, 0, sizeof(Dec_Graph_t) ); pGraph->fConst = 1; return pGraph; @@ -297,8 +297,8 @@ static inline Dec_Graph_t * Dec_GraphCreateLeaf( int iLeaf, int nLeaves, int fCo ***********************************************************************/ static inline void Dec_GraphFree( Dec_Graph_t * pGraph ) { - FREE( pGraph->pNodes ); - free( pGraph ); + ABC_FREE( pGraph->pNodes ); + ABC_FREE( pGraph ); } /**Function************************************************************* @@ -560,7 +560,7 @@ static inline Dec_Node_t * Dec_GraphAppendNode( Dec_Graph_t * pGraph ) Dec_Node_t * pNode; if ( pGraph->nSize == pGraph->nCap ) { - pGraph->pNodes = REALLOC( Dec_Node_t, pGraph->pNodes, 2 * pGraph->nCap ); + pGraph->pNodes = ABC_REALLOC( Dec_Node_t, pGraph->pNodes, 2 * pGraph->nCap ); pGraph->nCap = 2 * pGraph->nCap; } pNode = pGraph->pNodes + pGraph->nSize++; diff --git a/src/opt/dec/decFactor.c b/src/opt/dec/decFactor.c index 94205196..16e65b79 100644 --- a/src/opt/dec/decFactor.c +++ b/src/opt/dec/decFactor.c @@ -57,7 +57,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 free (should be done before CST) + // make sure the cover is CCS ABC_FREE (should be done before CST) Mvc_CoverContain( pCover ); // check for trivial functions if ( Mvc_CoverIsEmpty(pCover) ) @@ -130,7 +130,7 @@ Dec_Edge_t Dec_Factor_rec( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover ) return eNode; } - // make the quotient cube free + // make the quotient cube ABC_FREE Mvc_CoverMakeCubeFree( pQuo ); // divide the cover by the quotient diff --git a/src/opt/dec/decMan.c b/src/opt/dec/decMan.c index 3d65ffc5..63a96966 100644 --- a/src/opt/dec/decMan.c +++ b/src/opt/dec/decMan.c @@ -43,13 +43,13 @@ Dec_Man_t * Dec_ManStart() { Dec_Man_t * p; // int clk = clock(); - p = ALLOC( Dec_Man_t, 1 ); + p = ABC_ALLOC( Dec_Man_t, 1 ); p->pMvcMem = Mvc_ManagerStart(); p->vCubes = Vec_IntAlloc( 8 ); p->vLits = Vec_IntAlloc( 8 ); // canonical forms, phases, perms Extra_Truth4VarNPN( &p->puCanons, &p->pPhases, &p->pPerms, &p->pMap ); -//PRT( "NPN classes precomputation time", clock() - clk ); +//ABC_PRT( "NPN classes precomputation time", clock() - clk ); return p; } @@ -69,11 +69,11 @@ void Dec_ManStop( Dec_Man_t * p ) Mvc_ManagerFree( p->pMvcMem ); Vec_IntFree( p->vCubes ); Vec_IntFree( p->vLits ); - free( p->puCanons ); - free( p->pPhases ); - free( p->pPerms ); - free( p->pMap ); - free( p ); + ABC_FREE( p->puCanons ); + ABC_FREE( p->pPhases ); + ABC_FREE( p->pPerms ); + ABC_FREE( p->pMap ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/dec/decUtil.c b/src/opt/dec/decUtil.c index aeabeac4..b8ae4b8a 100644 --- a/src/opt/dec/decUtil.c +++ b/src/opt/dec/decUtil.c @@ -110,17 +110,17 @@ unsigned Dec_GraphDeriveTruth( Dec_Graph_t * pGraph ) // assign the elementary variables Dec_GraphForEachLeaf( pGraph, pNode, i ) - pNode->pFunc = (void *)(PORT_PTRUINT_T)uTruths[i]; + pNode->pFunc = (void *)(ABC_PTRUINT_T)uTruths[i]; // compute the function for each internal node Dec_GraphForEachNode( pGraph, pNode, i ) { - uTruth0 = (unsigned)(PORT_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc; - uTruth1 = (unsigned)(PORT_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc; + uTruth0 = (unsigned)(ABC_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc; + uTruth1 = (unsigned)(ABC_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc; uTruth0 = pNode->eEdge0.fCompl? ~uTruth0 : uTruth0; uTruth1 = pNode->eEdge1.fCompl? ~uTruth1 : uTruth1; uTruth = uTruth0 & uTruth1; - pNode->pFunc = (void *)(PORT_PTRUINT_T)uTruth; + pNode->pFunc = (void *)(ABC_PTRUINT_T)uTruth; } // complement the result if necessary diff --git a/src/opt/fxu/fxu.c b/src/opt/fxu/fxu.c index b49ef9aa..9102d289 100644 --- a/src/opt/fxu/fxu.c +++ b/src/opt/fxu/fxu.c @@ -44,7 +44,7 @@ static int s_MemoryPeak; The entries corresponding to the PI and objects with trivial covers are NULL. The number of extracted covers (not exceeding p->nNodesExt) is returned. Two other things are important for the correct operation of this procedure: - (1) The input covers do not have duplicated fanins and are SCC-free. + (1) The input covers do not have duplicated fanins and are SCC-ABC_FREE. (2) The fanins array contains the numbers of the fanin objects.] SideEffects [] @@ -225,7 +225,7 @@ char * Fxu_MemFetch( Fxu_Matrix * p, int nBytes ) s_MemoryTotal += nBytes; if ( s_MemoryPeak < s_MemoryTotal ) s_MemoryPeak = s_MemoryTotal; -// return malloc( nBytes ); +// return ABC_ALLOC( char, nBytes ); return Extra_MmFixedEntryFetch( p->pMemMan ); } @@ -243,7 +243,7 @@ char * Fxu_MemFetch( Fxu_Matrix * p, int nBytes ) void Fxu_MemRecycle( Fxu_Matrix * p, char * pItem, int nBytes ) { s_MemoryTotal -= nBytes; -// free( pItem ); +// ABC_FREE( pItem ); Extra_MmFixedEntryRecycle( p->pMemMan, pItem ); } diff --git a/src/opt/fxu/fxu.h b/src/opt/fxu/fxu.h index e6d0b69e..b9a56b23 100644 --- a/src/opt/fxu/fxu.h +++ b/src/opt/fxu/fxu.h @@ -19,10 +19,6 @@ #ifndef __FXU_H__ #define __FXU_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/fxu/fxuCreate.c b/src/opt/fxu/fxuCreate.c index 21dfd419..008cac46 100644 --- a/src/opt/fxu/fxuCreate.c +++ b/src/opt/fxu/fxuCreate.c @@ -98,13 +98,13 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) // start the matrix p = Fxu_MatrixAllocate(); // create the column labels - p->ppVars = ALLOC( Fxu_Var *, 2 * (pData->nNodesOld + pData->nNodesExt) ); + p->ppVars = ABC_ALLOC( Fxu_Var *, 2 * (pData->nNodesOld + pData->nNodesExt) ); for ( i = 0; i < 2 * pData->nNodesOld; i++ ) p->ppVars[i] = Fxu_MatrixAddVar( p ); // allocate storage for all cube pairs at once - p->pppPairs = ALLOC( Fxu_Pair **, nCubesTotal + 100 ); - p->ppPairs = ALLOC( Fxu_Pair *, nPairsStore + 100 ); + p->pppPairs = ABC_ALLOC( Fxu_Pair **, nCubesTotal + 100 ); + p->ppPairs = ABC_ALLOC( Fxu_Pair *, nPairsStore + 100 ); memset( p->ppPairs, 0, sizeof(Fxu_Pair *) * nPairsStore ); iCube = 0; iPair = 0; @@ -133,7 +133,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) // allocate room for the reordered literals - pOrder = ALLOC( int, nBitsMax ); + pOrder = ABC_ALLOC( int, nBitsMax ); // create the rows for ( i = 0; i < pData->nNodesOld; i++ ) if ( (pSopCover = pData->vSops->pArray[i]) ) @@ -174,7 +174,7 @@ Fxu_Matrix * Fxu_CreateMatrix( Fxu_Data_t * pData ) Fxu_MatrixAddDivisor( p, pCube1, pCube2 ); } } - FREE( pOrder ); + ABC_FREE( pOrder ); // consider the case when cube pairs should be preprocessed // before adding them to the set of divisors diff --git a/src/opt/fxu/fxuHeapD.c b/src/opt/fxu/fxuHeapD.c index c81ad818..9a8eb124 100644 --- a/src/opt/fxu/fxuHeapD.c +++ b/src/opt/fxu/fxuHeapD.c @@ -55,11 +55,11 @@ static void Fxu_HeapDoubleMoveDn( Fxu_HeapDouble * p, Fxu_Double * pDiv ); Fxu_HeapDouble * Fxu_HeapDoubleStart() { Fxu_HeapDouble * p; - p = ALLOC( Fxu_HeapDouble, 1 ); + p = ABC_ALLOC( Fxu_HeapDouble, 1 ); memset( p, 0, sizeof(Fxu_HeapDouble) ); p->nItems = 0; p->nItemsAlloc = 10000; - p->pTree = ALLOC( Fxu_Double *, p->nItemsAlloc + 1 ); + p->pTree = ABC_ALLOC( Fxu_Double *, p->nItemsAlloc + 1 ); p->pTree[0] = NULL; return p; } @@ -79,7 +79,7 @@ Fxu_HeapDouble * Fxu_HeapDoubleStart() void Fxu_HeapDoubleResize( Fxu_HeapDouble * p ) { p->nItemsAlloc *= 2; - p->pTree = REALLOC( Fxu_Double *, p->pTree, p->nItemsAlloc + 1 ); + p->pTree = ABC_REALLOC( Fxu_Double *, p->pTree, p->nItemsAlloc + 1 ); } /**Function************************************************************* @@ -95,8 +95,8 @@ void Fxu_HeapDoubleResize( Fxu_HeapDouble * p ) ***********************************************************************/ void Fxu_HeapDoubleStop( Fxu_HeapDouble * p ) { - free( p->pTree ); - free( p ); + ABC_FREE( p->pTree ); + ABC_FREE( p ); } diff --git a/src/opt/fxu/fxuHeapS.c b/src/opt/fxu/fxuHeapS.c index eaca8363..4a9bd3a4 100644 --- a/src/opt/fxu/fxuHeapS.c +++ b/src/opt/fxu/fxuHeapS.c @@ -55,11 +55,11 @@ static void Fxu_HeapSingleMoveDn( Fxu_HeapSingle * p, Fxu_Single * pSingle ); Fxu_HeapSingle * Fxu_HeapSingleStart() { Fxu_HeapSingle * p; - p = ALLOC( Fxu_HeapSingle, 1 ); + p = ABC_ALLOC( Fxu_HeapSingle, 1 ); memset( p, 0, sizeof(Fxu_HeapSingle) ); p->nItems = 0; p->nItemsAlloc = 2000; - p->pTree = ALLOC( Fxu_Single *, p->nItemsAlloc + 10 ); + p->pTree = ABC_ALLOC( Fxu_Single *, p->nItemsAlloc + 10 ); p->pTree[0] = NULL; return p; } @@ -79,7 +79,7 @@ Fxu_HeapSingle * Fxu_HeapSingleStart() void Fxu_HeapSingleResize( Fxu_HeapSingle * p ) { p->nItemsAlloc *= 2; - p->pTree = REALLOC( Fxu_Single *, p->pTree, p->nItemsAlloc + 10 ); + p->pTree = ABC_REALLOC( Fxu_Single *, p->pTree, p->nItemsAlloc + 10 ); } /**Function************************************************************* @@ -97,9 +97,9 @@ void Fxu_HeapSingleStop( Fxu_HeapSingle * p ) { int i; i = 0; - free( p->pTree ); + ABC_FREE( p->pTree ); i = 1; - free( p ); + ABC_FREE( p ); } diff --git a/src/opt/fxu/fxuInt.h b/src/opt/fxu/fxuInt.h index 4e3d72eb..7483c896 100644 --- a/src/opt/fxu/fxuInt.h +++ b/src/opt/fxu/fxuInt.h @@ -365,7 +365,7 @@ struct FxuSingle // 7 words #define Fxu_CubeForEachPair( pCube, pPair, i )\ for ( i = 0;\ i < pCube->pVar->nCubes &&\ - (((unsigned)(PORT_PTRUINT_T)(pPair = pCube->pVar->ppPairs[pCube->iCube][i])) >= 0);\ + (((unsigned)(ABC_PTRUINT_T)(pPair = pCube->pVar->ppPairs[pCube->iCube][i])) >= 0);\ i++ )\ if ( pPair ) @@ -421,8 +421,8 @@ extern void Fxu_MatrixRingVarsUnmark( Fxu_Matrix * p ); // MEM_ALLOC: allocate the given number (Size) of items of type (Type) // MEM_FREE: deallocate the pointer (Pointer) to the given number (Size) of items of type (Type) #ifdef USE_SYSTEM_MEMORY_MANAGEMENT -#define MEM_ALLOC_FXU( Manager, Type, Size ) ((Type *)malloc( (Size) * sizeof(Type) )) -#define MEM_FREE_FXU( Manager, Type, Size, Pointer ) if ( Pointer ) { free(Pointer); Pointer = NULL; } +#define MEM_ALLOC_FXU( Manager, Type, Size ) ((Type *)ABC_ALLOC( char, (Size) * sizeof(Type) )) +#define MEM_FREE_FXU( Manager, Type, Size, Pointer ) if ( Pointer ) { ABC_FREE(Pointer); Pointer = NULL; } #else #define MEM_ALLOC_FXU( Manager, Type, Size )\ ((Type *)Fxu_MemFetch( Manager, (Size) * sizeof(Type) )) diff --git a/src/opt/fxu/fxuMatrix.c b/src/opt/fxu/fxuMatrix.c index 93ec7b90..590370c9 100644 --- a/src/opt/fxu/fxuMatrix.c +++ b/src/opt/fxu/fxuMatrix.c @@ -42,10 +42,10 @@ extern unsigned int Cudd_Prime( unsigned int p ); Fxu_Matrix * Fxu_MatrixAllocate() { Fxu_Matrix * p; - p = ALLOC( Fxu_Matrix, 1 ); + p = ABC_ALLOC( Fxu_Matrix, 1 ); memset( p, 0, sizeof(Fxu_Matrix) ); p->nTableSize = Cudd_Prime(10000); - p->pTable = ALLOC( Fxu_ListDouble, p->nTableSize ); + p->pTable = ABC_ALLOC( Fxu_ListDouble, p->nTableSize ); memset( p->pTable, 0, sizeof(Fxu_ListDouble) * p->nTableSize ); #ifndef USE_SYSTEM_MEMORY_MANAGEMENT { @@ -134,12 +134,12 @@ void Fxu_MatrixDelete( Fxu_Matrix * p ) #endif Vec_PtrFree( p->vPairs ); - FREE( p->pppPairs ); - FREE( p->ppPairs ); -// FREE( p->pPairsTemp ); - FREE( p->pTable ); - FREE( p->ppVars ); - FREE( p ); + ABC_FREE( p->pppPairs ); + ABC_FREE( p->ppPairs ); +// ABC_FREE( p->pPairsTemp ); + ABC_FREE( p->pTable ); + ABC_FREE( p->ppVars ); + ABC_FREE( p ); } diff --git a/src/opt/fxu/fxuPair.c b/src/opt/fxu/fxuPair.c index 87645cc7..62cc792b 100644 --- a/src/opt/fxu/fxuPair.c +++ b/src/opt/fxu/fxuPair.c @@ -86,7 +86,7 @@ void Fxu_PairCanonicize( Fxu_Cube ** ppCube1, Fxu_Cube ** ppCube2 ) pLit2 = pLit2->pHNext; continue; } - assert( pLit1 && pLit2 ); // this is true if the covers are SCC-free + assert( pLit1 && pLit2 ); // this is true if the covers are SCC-ABC_FREE if ( pLit1->iVar > pLit2->iVar ) { // swap the cubes pCubeTemp = *ppCube1; @@ -149,7 +149,7 @@ unsigned Fxu_PairHashKeyArray( Fxu_Matrix * p, int piVarsC1[], int piVarsC2[], i Synopsis [Computes the hash key of the divisor represented by the pair of cubes.] Description [Goes through the variables in both cubes. Skips the identical - ones (this corresponds to making the cubes cube-free). Computes the hash + ones (this corresponds to making the cubes cube-ABC_FREE). Computes the hash value of the cubes. Assigns the number of literals in the base and in the cubes without base.] @@ -178,7 +178,7 @@ unsigned Fxu_PairHashKey( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_Cube * pCube2, if ( pLit1 && pLit2 ) { if ( pLit1->iVar == pLit2->iVar ) - { // ensure cube-free + { // ensure cube-ABC_FREE pLit1 = pLit1->pHNext; pLit2 = pLit2->pHNext; // add this literal to the base @@ -452,8 +452,8 @@ void Fxu_PairAllocStorage( Fxu_Var * pVar, int nCubes ) // assert( pVar->nCubes == 0 ); pVar->nCubes = nCubes; // allocate memory for all the pairs - pVar->ppPairs = ALLOC( Fxu_Pair **, nCubes ); - pVar->ppPairs[0] = ALLOC( Fxu_Pair *, nCubes * nCubes ); + pVar->ppPairs = ABC_ALLOC( Fxu_Pair **, nCubes ); + pVar->ppPairs[0] = ABC_ALLOC( Fxu_Pair *, nCubes * nCubes ); memset( pVar->ppPairs[0], 0, sizeof(Fxu_Pair *) * nCubes * nCubes ); for ( k = 1; k < nCubes; k++ ) pVar->ppPairs[k] = pVar->ppPairs[k-1] + nCubes; @@ -497,8 +497,8 @@ void Fxu_PairFreeStorage( Fxu_Var * pVar ) { if ( pVar->ppPairs ) { - FREE( pVar->ppPairs[0] ); - FREE( pVar->ppPairs ); + ABC_FREE( pVar->ppPairs[0] ); + ABC_FREE( pVar->ppPairs ); } } diff --git a/src/opt/fxu/fxuPrint.c b/src/opt/fxu/fxuPrint.c index 232b109a..652a830e 100644 --- a/src/opt/fxu/fxuPrint.c +++ b/src/opt/fxu/fxuPrint.c @@ -161,7 +161,7 @@ void Fxu_MatrixPrintDivisorProfile( FILE * pFile, Fxu_Matrix * p ) int i; WeightMax = Fxu_HeapDoubleReadMaxWeight( p->pHeapDouble ); - pProfile = ALLOC( int, (WeightMax + 1) ); + pProfile = ABC_ALLOC( int, (WeightMax + 1) ); memset( pProfile, 0, sizeof(int) * (WeightMax + 1) ); Counter1 = 0; @@ -184,7 +184,7 @@ void Fxu_MatrixPrintDivisorProfile( FILE * pFile, Fxu_Matrix * p ) if ( pProfile[i] ) fprintf( pFile, "Weight %3d divisors = %6d\n", i, pProfile[i] ); fprintf( pFile, "End of divisor profile printout\n" ); - FREE( pProfile ); + ABC_FREE( pProfile ); } diff --git a/src/opt/fxu/fxuReduce.c b/src/opt/fxu/fxuReduce.c index 38032bfa..6b892971 100644 --- a/src/opt/fxu/fxuReduce.c +++ b/src/opt/fxu/fxuReduce.c @@ -40,7 +40,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-free form.] + cube-ABC_FREE form.] SideEffects [] @@ -64,7 +64,7 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota assert( nPairsMax < nPairsTotal ); // allocate storage for counter of diffs - pnLitsDiff = ALLOC( unsigned char, nPairsTotal ); + pnLitsDiff = ABC_ALLOC( unsigned char, nPairsTotal ); // go through the covers and precompute the distances between the pairs iPair = 0; nBitsMax = -1; @@ -83,7 +83,7 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota assert( iPair == nPairsTotal ); // allocate storage for counters of cube pairs by difference - pnPairCounters = ALLOC( int, 2 * nBitsMax ); + pnPairCounters = ABC_ALLOC( int, 2 * nBitsMax ); memset( pnPairCounters, 0, sizeof(int) * 2 * nBitsMax ); // count the number of different pairs for ( k = 0; k < nPairsTotal; k++ ) @@ -92,16 +92,16 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota // so that there would be exactly pPairsMax pairs if ( pnPairCounters[0] != 0 ) { - printf( "The SOPs of the nodes are not cube-free. Run \"bdd; sop\" before \"fx\".\n" ); + printf( "The SOPs of the nodes are not cube-ABC_FREE. Run \"bdd; sop\" before \"fx\".\n" ); return 0; } if ( pnPairCounters[1] != 0 ) { - printf( "The SOPs of the nodes are not SCC-free. Run \"bdd; sop\" before \"fx\".\n" ); + printf( "The SOPs of the nodes are not SCC-ABC_FREE. Run \"bdd; sop\" before \"fx\".\n" ); return 0; } - assert( pnPairCounters[0] == 0 ); // otherwise, covers are not dup-free - assert( pnPairCounters[1] == 0 ); // otherwise, covers are not SCC-free + assert( pnPairCounters[0] == 0 ); // otherwise, covers are not dup-ABC_FREE + assert( pnPairCounters[1] == 0 ); // otherwise, covers are not SCC-ABC_FREE nSum = 0; for ( k = 0; k < 2 * nBitsMax; k++ ) { @@ -113,7 +113,7 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota break; } } - FREE( pnPairCounters ); + ABC_FREE( pnPairCounters ); // set to 0 all the pairs above the cut-off number and quantity iQuant = 0; @@ -156,8 +156,8 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota } } assert( iPair == nPairsTotal ); - FREE( pnLitsDiff ); -//PRT( "Preprocess", clock() - clk ); + ABC_FREE( pnLitsDiff ); +//ABC_PRT( "Preprocess", clock() - clk ); return 1; } @@ -171,7 +171,7 @@ int Fxu_PreprocessCubePairs( Fxu_Matrix * p, Vec_Ptr_t * vCovers, int nPairsTota entries as there are different pairs of cubes in the cover: n(n-1)/2. Fills out the array pDiffs with the following info: For each cube pair, included in the array is the number of literals in both cubes - after they are made cube free.] + after they are made cube ABC_FREE.] SideEffects [] diff --git a/src/opt/fxu/fxuSelect.c b/src/opt/fxu/fxuSelect.c index b9265487..20f5ab97 100644 --- a/src/opt/fxu/fxuSelect.c +++ b/src/opt/fxu/fxuSelect.c @@ -416,7 +416,7 @@ void Fxu_MatrixGetDoubleVars( Fxu_Matrix * p, Fxu_Double * pDouble, if ( pLit1 && pLit2 ) { if ( pLit1->iVar == pLit2->iVar ) - { // ensure cube-free + { // ensure cube-ABC_FREE pLit1 = pLit1->pHNext; pLit2 = pLit2->pHNext; } diff --git a/src/opt/fxu/fxuSingle.c b/src/opt/fxu/fxuSingle.c index d2e3607c..6e90a2a2 100644 --- a/src/opt/fxu/fxuSingle.c +++ b/src/opt/fxu/fxuSingle.c @@ -59,11 +59,11 @@ void Fxu_MatrixComputeSingles( Fxu_Matrix * p, int fUse0, int nSingleMax ) int * pWeigtCounts, nDivCount, Weight, i, c;; assert( Vec_PtrSize(vSingles) % 3 == 0 ); // count how many divisors have the given weight - pWeigtCounts = ALLOC( int, 1000 ); + pWeigtCounts = ABC_ALLOC( int, 1000 ); memset( pWeigtCounts, 0, sizeof(int) * 1000 ); for ( i = 2; i < Vec_PtrSize(vSingles); i += 3 ) { - Weight = (int)(PORT_PTRUINT_T)Vec_PtrEntry(vSingles, i); + Weight = (int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles, i); if ( Weight >= 999 ) pWeigtCounts[999]++; else @@ -77,12 +77,12 @@ void Fxu_MatrixComputeSingles( Fxu_Matrix * p, int fUse0, int nSingleMax ) if ( nDivCount >= nSingleMax ) break; } - free( pWeigtCounts ); + ABC_FREE( pWeigtCounts ); // collect singles with the given costs k = 0; for ( i = 2; i < Vec_PtrSize(vSingles); i += 3 ) { - Weight = (int)(PORT_PTRUINT_T)Vec_PtrEntry(vSingles, i); + Weight = (int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles, i); if ( Weight < c ) continue; Vec_PtrWriteEntry( vSingles, k++, Vec_PtrEntry(vSingles, i-2) ); @@ -102,7 +102,7 @@ void Fxu_MatrixComputeSingles( Fxu_Matrix * p, int fUse0, int nSingleMax ) Fxu_MatrixAddSingle( p, Vec_PtrEntry(vSingles,i), Vec_PtrEntry(vSingles,i+1), - (int)(PORT_PTRUINT_T)Vec_PtrEntry(vSingles,i+2) ); + (int)(ABC_PTRUINT_T)Vec_PtrEntry(vSingles,i+2) ); } Vec_PtrFree( vSingles ); } @@ -159,7 +159,7 @@ void Fxu_MatrixComputeSinglesOneCollect( Fxu_Matrix * p, Fxu_Var * pVar, Vec_Ptr { Vec_PtrPush( vSingles, pVar2 ); Vec_PtrPush( vSingles, pVar ); - Vec_PtrPush( vSingles, (void *)(PORT_PTRUINT_T)WeightCur ); + Vec_PtrPush( vSingles, (void *)(ABC_PTRUINT_T)WeightCur ); } } diff --git a/src/opt/fxu/fxuUpdate.c b/src/opt/fxu/fxuUpdate.c index 274f79f6..cdbe313d 100644 --- a/src/opt/fxu/fxuUpdate.c +++ b/src/opt/fxu/fxuUpdate.c @@ -344,7 +344,7 @@ void Fxu_UpdateMatrixDoubleCreateCubes( Fxu_Matrix * p, Fxu_Cube * pCube1, Fxu_C if ( pLit1 && pLit2 ) { if ( pLit1->iVar == pLit2->iVar ) - { // skip the cube free part + { // skip the cube ABC_FREE part pLit1 = pLit1->pHNext; pLit2 = pLit2->pHNext; nBase++; diff --git a/src/opt/lpk/lpk.h b/src/opt/lpk/lpk.h index 2a642db2..d7e4af29 100644 --- a/src/opt/lpk/lpk.h +++ b/src/opt/lpk/lpk.h @@ -21,10 +21,6 @@ #ifndef __LPK_H__ #define __LPK_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/lpk/lpkAbcDsd.c b/src/opt/lpk/lpkAbcDsd.c index a1cd9def..c2a46d3e 100644 --- a/src/opt/lpk/lpkAbcDsd.c +++ b/src/opt/lpk/lpkAbcDsd.c @@ -420,7 +420,7 @@ Kit_DsdPrint( stdout, pNtks[i] ); pvBSets[i][k] = Lpk_MergeBoundSets( pvBSets[i+1][2*k+0], pvBSets[i+1][2*k+1], p->nLutK - nCofDepth ); // compare bound-sets Lpk_FunCompareBoundSets( p, pvBSets[0][0], nCofDepth, uNonDecSupp, uLateArrSupp, pRes ); - // free the bound sets + // ABC_FREE the bound sets for ( i = nCofDepth; i >= 0; i-- ) for ( k = 0; k < (1<pIfMan == NULL ); // set defaults - pPars = ALLOC( If_Par_t, 1 ); + pPars = ABC_ALLOC( If_Par_t, 1 ); memset( pPars, 0, sizeof(If_Par_t) ); // user-controlable paramters pPars->nLutSize = p->pPars->nLutSize; @@ -75,7 +75,7 @@ void Lpk_IfManStart( Lpk_Man_t * p ) // start the mapping manager and set its parameters p->pIfMan = If_ManStart( pPars ); If_ManSetupSetAll( p->pIfMan, 1000 ); - p->pIfMan->pPars->pTimesArr = ALLOC( float, 32 ); + p->pIfMan->pPars->pTimesArr = ABC_ALLOC( float, 32 ); } /**Function************************************************************* @@ -100,7 +100,7 @@ int Lpk_NodeHasChanged( Lpk_Man_t * p, int iNode ) Vec_PtrForEachEntry( vNodes, pTemp, i ) { // check if the node has changed - pTemp = Abc_NtkObj( p->pNtk, (int)(PORT_PTRUINT_T)pTemp ); + pTemp = Abc_NtkObj( p->pNtk, (int)(ABC_PTRUINT_T)pTemp ); if ( pTemp == NULL ) return 1; // check if the number of fanouts has changed @@ -563,7 +563,7 @@ int Lpk_Resynthesize( Abc_Ntk_t * pNtk, Lpk_Par_t * pPars ) /* // save the number of fanouts of all objects nObjMax = Abc_NtkObjNumMax( pNtk ); - pnFanouts = ALLOC( int, nObjMax ); + pnFanouts = ABC_ALLOC( int, nObjMax ); memset( pnFanouts, 0, sizeof(int) * nObjMax ); Abc_NtkForEachObj( pNtk, pObj, i ) pnFanouts[pObj->Id] = Abc_ObjFanoutNum(pObj); @@ -654,18 +654,18 @@ int Lpk_Resynthesize( Abc_Ntk_t * pNtk, Lpk_Par_t * pPars ) p->timeTotal = clock() - clk; p->timeEval = p->timeEval - p->timeMap; p->timeOther = p->timeTotal - p->timeCuts - p->timeTruth - p->timeEval - p->timeMap; - PRTP( "Cuts ", p->timeCuts, p->timeTotal ); - PRTP( "Truth ", p->timeTruth, p->timeTotal ); - PRTP( "CSupps", p->timeSupps, p->timeTotal ); - PRTP( "Eval ", p->timeEval, p->timeTotal ); - PRTP( " MuxAn", p->timeEvalMuxAn, p->timeEval ); - PRTP( " MuxSp", p->timeEvalMuxSp, p->timeEval ); - PRTP( " DsdAn", p->timeEvalDsdAn, p->timeEval ); - PRTP( " DsdSp", p->timeEvalDsdSp, p->timeEval ); - PRTP( " Other", p->timeEval-p->timeEvalMuxAn-p->timeEvalMuxSp-p->timeEvalDsdAn-p->timeEvalDsdSp, p->timeEval ); - PRTP( "Map ", p->timeMap, p->timeTotal ); - PRTP( "Other ", p->timeOther, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + ABC_PRTP( "Cuts ", p->timeCuts, p->timeTotal ); + ABC_PRTP( "Truth ", p->timeTruth, p->timeTotal ); + ABC_PRTP( "CSupps", p->timeSupps, p->timeTotal ); + ABC_PRTP( "Eval ", p->timeEval, p->timeTotal ); + ABC_PRTP( " MuxAn", p->timeEvalMuxAn, p->timeEval ); + ABC_PRTP( " MuxSp", p->timeEvalMuxSp, p->timeEval ); + ABC_PRTP( " DsdAn", p->timeEvalDsdAn, p->timeEval ); + ABC_PRTP( " DsdSp", p->timeEvalDsdSp, p->timeEval ); + ABC_PRTP( " Other", p->timeEval-p->timeEvalMuxAn-p->timeEvalMuxSp-p->timeEvalDsdAn-p->timeEvalDsdSp, p->timeEval ); + ABC_PRTP( "Map ", p->timeMap, p->timeTotal ); + ABC_PRTP( "Other ", p->timeOther, p->timeTotal ); + ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); } Lpk_ManStop( p ); diff --git a/src/opt/lpk/lpkCut.c b/src/opt/lpk/lpkCut.c index a2f46b09..6f0eed84 100644 --- a/src/opt/lpk/lpkCut.c +++ b/src/opt/lpk/lpkCut.c @@ -46,7 +46,7 @@ CloudNode * Lpk_CutTruthBdd_rec( CloudManager * dd, Hop_Man_t * pMan, Hop_Obj_t assert( !Hop_IsComplement(pObj) ); if ( pObj->pData ) { - assert( ((unsigned)(PORT_PTRUINT_T)pObj->pData) & 0xffff0000 ); + assert( ((unsigned)(ABC_PTRUINT_T)pObj->pData) & 0xffff0000 ); return pObj->pData; } // get the plan for a new truth table @@ -103,7 +103,7 @@ CloudNode * Lpk_CutTruthBdd( Lpk_Man_t * p, Lpk_Cut_t * pCut ) // set the initial truth tables at the fanins Abc_ObjForEachFanin( pObj, pFanin, k ) { - assert( ((unsigned)(PORT_PTRUINT_T)pFanin->pCopy) & 0xffff0000 ); + assert( ((unsigned)(ABC_PTRUINT_T)pFanin->pCopy) & 0xffff0000 ); Hop_ManPi( pManHop, k )->pData = pFanin->pCopy; } // compute the truth table of internal nodes @@ -138,7 +138,7 @@ unsigned * Lpk_CutTruth_rec( Hop_Man_t * pMan, Hop_Obj_t * pObj, int nVars, Vec_ assert( !Hop_IsComplement(pObj) ); if ( pObj->pData ) { - assert( ((unsigned)(PORT_PTRUINT_T)pObj->pData) & 0xffff0000 ); + assert( ((unsigned)(ABC_PTRUINT_T)pObj->pData) & 0xffff0000 ); return pObj->pData; } // get the plan for a new truth table @@ -194,7 +194,7 @@ unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv ) // set the initial truth tables at the fanins Abc_ObjForEachFanin( pObj, pFanin, k ) { - assert( ((unsigned)(PORT_PTRUINT_T)pFanin->pCopy) & 0xffff0000 ); + assert( ((unsigned)(ABC_PTRUINT_T)pFanin->pCopy) & 0xffff0000 ); Hop_ManPi( pManHop, k )->pData = pFanin->pCopy; } // compute the truth table of internal nodes @@ -209,7 +209,7 @@ unsigned * Lpk_CutTruth( Lpk_Man_t * p, Lpk_Cut_t * pCut, int fInv ) if ( fInv == 0 ) { pTruth = Vec_PtrEntry( p->vTtNodes, iCount++ ); - Kit_TruthCopy( pTruth, (unsigned *)(PORT_PTRUINT_T)pObj->pCopy, pCut->nLeaves ); + Kit_TruthCopy( pTruth, (unsigned *)(ABC_PTRUINT_T)pObj->pCopy, pCut->nLeaves ); } assert( iCount <= Vec_PtrSize(p->vTtNodes) ); return pTruth; @@ -244,14 +244,14 @@ void Lpk_NodeRecordImpact( Lpk_Man_t * p ) if ( pNode->fMarkC ) continue; pNode->fMarkC = 1; - Vec_PtrPush( vNodes, (void *)(PORT_PTRUINT_T)pNode->Id ); - Vec_PtrPush( vNodes, (void *)(PORT_PTRUINT_T)Abc_ObjFanoutNum(pNode) ); + Vec_PtrPush( vNodes, (void *)(ABC_PTRUINT_T)pNode->Id ); + Vec_PtrPush( vNodes, (void *)(ABC_PTRUINT_T)Abc_ObjFanoutNum(pNode) ); } } // clear the marks Vec_PtrForEachEntry( vNodes, pNode, i ) { - pNode = Abc_NtkObj( p->pNtk, (int)(PORT_PTRUINT_T)pNode ); + pNode = Abc_NtkObj( p->pNtk, (int)(ABC_PTRUINT_T)pNode ); pNode->fMarkC = 0; i++; } @@ -281,7 +281,7 @@ int Lpk_NodeCutsCheckDsd( Lpk_Man_t * p, Lpk_Cut_t * pCut ) { assert( pObj->fMarkA == 0 ); pObj->fMarkA = 1; - pObj->pCopy = (void *)(PORT_PTRUINT_T)i; + pObj->pCopy = (void *)(ABC_PTRUINT_T)i; } // ref leaves pointed from the internal nodes nCands = 0; @@ -290,7 +290,7 @@ int Lpk_NodeCutsCheckDsd( Lpk_Man_t * p, Lpk_Cut_t * pCut ) fLeavesOnly = 1; Abc_ObjForEachFanin( pObj, pFanin, k ) if ( pFanin->fMarkA ) - p->pRefs[(int)(PORT_PTRUINT_T)pFanin->pCopy]++; + p->pRefs[(int)(ABC_PTRUINT_T)pFanin->pCopy]++; else fLeavesOnly = 0; if ( fLeavesOnly ) @@ -304,7 +304,7 @@ int Lpk_NodeCutsCheckDsd( Lpk_Man_t * p, Lpk_Cut_t * pCut ) Abc_ObjForEachFanin( pObj, pFanin, k ) { assert( pFanin->fMarkA == 1 ); - if ( p->pRefs[(int)(PORT_PTRUINT_T)pFanin->pCopy] > 1 ) + if ( p->pRefs[(int)(ABC_PTRUINT_T)pFanin->pCopy] > 1 ) break; } if ( k == Abc_ObjFaninNum(pObj) ) diff --git a/src/opt/lpk/lpkInt.h b/src/opt/lpk/lpkInt.h index 960599e4..26bb846a 100644 --- a/src/opt/lpk/lpkInt.h +++ b/src/opt/lpk/lpkInt.h @@ -21,10 +21,6 @@ #ifndef __LPK_INT_H__ #define __LPK_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -38,6 +34,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/lpk/lpkMan.c b/src/opt/lpk/lpkMan.c index af6a5307..024f724a 100644 --- a/src/opt/lpk/lpkMan.c +++ b/src/opt/lpk/lpkMan.c @@ -45,7 +45,7 @@ Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars ) int i, nWords; assert( pPars->nLutsMax <= 16 ); assert( pPars->nVarsMax > 0 && pPars->nVarsMax <= 16 ); - p = ALLOC( Lpk_Man_t, 1 ); + p = ABC_ALLOC( Lpk_Man_t, 1 ); memset( p, 0, sizeof(Lpk_Man_t) ); p->pPars = pPars; p->nCutsMax = LPK_CUTS_MAX; @@ -61,7 +61,7 @@ Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars ) p->vBddInv = Vec_IntAlloc( 256 ); // allocate temporary storage for truth tables nWords = Kit_TruthWordNum(pPars->nVarsMax); - p->ppTruths[0][0] = ALLOC( unsigned, 32 * nWords ); + p->ppTruths[0][0] = ABC_ALLOC( unsigned, 32 * nWords ); p->ppTruths[1][0] = p->ppTruths[0][0] + 1 * nWords; for ( i = 1; i < 2; i++ ) p->ppTruths[1][i] = p->ppTruths[1][0] + i * nWords; @@ -91,7 +91,7 @@ Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars ) void Lpk_ManStop( Lpk_Man_t * p ) { int i; - free( p->ppTruths[0][0] ); + ABC_FREE( p->ppTruths[0][0] ); Vec_IntFree( p->vBddDir ); Vec_IntFree( p->vBddInv ); Vec_IntFree( p->vMemory ); @@ -102,7 +102,7 @@ void Lpk_ManStop( Lpk_Man_t * p ) { void * pPars = p->pIfMan->pPars; If_ManStop( p->pIfMan ); - free( pPars ); + ABC_FREE( pPars ); } if ( p->vLevels ) Vec_VecFree( p->vLevels ); @@ -112,7 +112,7 @@ void Lpk_ManStop( Lpk_Man_t * p ) Vec_IntFree( p->vCover ); Vec_PtrFree( p->vTtElems ); Vec_PtrFree( p->vTtNodes ); - free( p ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/lpk/lpkMulti.c b/src/opt/lpk/lpkMulti.c index 3d2093e7..b013570e 100644 --- a/src/opt/lpk/lpkMulti.c +++ b/src/opt/lpk/lpkMulti.c @@ -375,7 +375,7 @@ If_Obj_t * Lpk_MapTreeMulti( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj // allocate storage for cofactors nMemSize = Kit_TruthWordNum(nVars); - ppCofs[0][0] = ALLOC( unsigned, 32 * nMemSize ); + ppCofs[0][0] = ABC_ALLOC( unsigned, 32 * nMemSize ); nSize = 0; for ( i = 0; i < 4; i++ ) for ( k = 0; k < 8; k++ ) @@ -492,11 +492,11 @@ If_Obj_t * Lpk_MapTreeMulti( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj printf( "Verification failed.\n" ); - // free the networks + // ABC_FREE the networks for ( i = 0; i < 8; i++ ) if ( ppNtks[i] ) Kit_DsdNtkFree( ppNtks[i] ); - free( ppCofs[0][0] ); + ABC_FREE( ppCofs[0][0] ); return pResult; } diff --git a/src/opt/lpk/lpkSets.c b/src/opt/lpk/lpkSets.c index 90e46863..6cb3f12d 100644 --- a/src/opt/lpk/lpkSets.c +++ b/src/opt/lpk/lpkSets.c @@ -362,7 +362,7 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i Lpk_PrintSets( vSets0 ); if ( fVerbose ) Lpk_PrintSets( vSets1 ); - // free the networks + // ABC_FREE the networks Kit_DsdNtkFree( ppNtks[0] ); Kit_DsdNtkFree( ppNtks[1] ); // evaluate the pair diff --git a/src/opt/mfs/mfs.h b/src/opt/mfs/mfs.h index bddb9328..375f93b7 100644 --- a/src/opt/mfs/mfs.h +++ b/src/opt/mfs/mfs.h @@ -21,10 +21,6 @@ #ifndef __MFS_H__ #define __MFS_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/mfs/mfsCore.c b/src/opt/mfs/mfsCore.c index e8820acd..456b5d71 100644 --- a/src/opt/mfs/mfsCore.c +++ b/src/opt/mfs/mfsCore.c @@ -63,16 +63,15 @@ void Abc_NtkMfsParsDefault( Mfs_Par_t * pPars ) int Abc_NtkMfsEdgePower( Mfs_Man_t * p, Abc_Obj_t * pNode ) { Abc_Obj_t * pFanin; - float * pProbab = (float *)p->vProbs->pArray; int i; // try replacing area critical fanins Abc_ObjForEachFanin( pNode, pFanin, i ) { - if ( pProbab[pFanin->Id] >= 0.4 ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.4 ) { if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) return 1; - } else if ( pProbab[pFanin->Id] >= 0.3 ) + } else if ( Abc_MfsObjProb(p, pFanin) >= 0.3 ) { if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) ) return 1; @@ -86,7 +85,6 @@ int Abc_WinNode(Mfs_Man_t * p, Abc_Obj_t *pNode) { // int clk; // Abc_Obj_t * pFanin; - float * pProbab = (float *)p->vProbs->pArray; // int i; p->nNodesTried++; @@ -120,7 +118,6 @@ int Abc_NtkMfsPowerResubNode( Mfs_Man_t * p, Abc_Obj_t * pNode ) { int clk; Abc_Obj_t * pFanin; - float * pProbab = (float *)p->vProbs->pArray; int i; if (Abc_WinNode(p, pNode) // something wrong @@ -130,11 +127,11 @@ int Abc_NtkMfsPowerResubNode( Mfs_Man_t * p, Abc_Obj_t * pNode ) // Abc_NtkMfsEdgePower( p, pNode ); // try replacing area critical fanins Abc_ObjForEachFanin( pNode, pFanin, i ) - if ( pProbab[pFanin->Id] >= 0.37 && Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.37 && Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) return 1; Abc_ObjForEachFanin( pNode, pFanin, i ) - if ( pProbab[pFanin->Id] >= 0.1 && Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.1 && Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) ) return 1; if ( Abc_ObjFaninNum(pNode) == p->nFaninMax ) @@ -142,7 +139,7 @@ int Abc_NtkMfsPowerResubNode( Mfs_Man_t * p, Abc_Obj_t * pNode ) // try replacing area critical fanins while adding two new fanins Abc_ObjForEachFanin( pNode, pFanin, i ) - if ( pProbab[pFanin->Id] >= 0.37 && Abc_NtkMfsSolveSatResub2( p, pNode, i, -1 ) ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.37 && Abc_NtkMfsSolveSatResub2( p, pNode, i, -1 ) ) return 1; } return 0; @@ -157,7 +154,6 @@ Abc_NtkMfsPowerResub( Mfs_Man_t * p, Mfs_Par_t * pPars) Abc_Obj_t *pFanin, *pNode; Abc_Ntk_t *pNtk = p->pNtk; int nFaninMax = Abc_NtkGetFaninMax(p->pNtk); - float * pProbab = (float *)p->vProbs->pArray; Abc_NtkForEachNode( pNtk, pNode, k ) { @@ -172,7 +168,7 @@ Abc_NtkMfsPowerResub( Mfs_Man_t * p, Mfs_Par_t * pPars) // Abc_NtkMfsEdgePower( p, pNode ); // try replacing area critical fanins Abc_ObjForEachFanin( pNode, pFanin, i ) - if ( pProbab[pFanin->Id] >= 0.35 && Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.35 && Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) continue; } @@ -189,7 +185,7 @@ Abc_NtkMfsPowerResub( Mfs_Man_t * p, Mfs_Par_t * pPars) // Abc_NtkMfsEdgePower( p, pNode ); // try replacing area critical fanins Abc_ObjForEachFanin( pNode, pFanin, i ) - if ( pProbab[pFanin->Id] >= 0.35 && Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.35 && Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) continue; } @@ -203,7 +199,7 @@ Abc_NtkMfsPowerResub( Mfs_Man_t * p, Mfs_Par_t * pPars) continue; Abc_ObjForEachFanin( pNode, pFanin, i ) - if ( pProbab[pFanin->Id] >= 0.2 && Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.2 && Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) ) continue; } /* @@ -217,7 +213,7 @@ Abc_NtkMfsPowerResub( Mfs_Man_t * p, Mfs_Par_t * pPars) continue; Abc_ObjForEachFanin( pNode, pFanin, i ) - if ( pProbab[pFanin->Id] >= 0.37 && Abc_NtkMfsSolveSatResub2( p, pNode, i, -1 ) ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.37 && Abc_NtkMfsSolveSatResub2( p, pNode, i, -1 ) ) continue; } */ @@ -456,7 +452,7 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars ) if ( p->pCare ) { Abc_NtkForEachCi( pNtk, pObj, i ) - pObj->pData = (void *)(PORT_PTRUINT_T)i; + pObj->pData = (void *)(ABC_PTRUINT_T)i; } // compute levels @@ -531,7 +527,7 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars ) 1.0*p->nNodesGainedLevel/Vec_PtrSize(vNodes), 1.0*p->nTotConfLevel/Vec_PtrSize(vNodes), 100.0*p->nTimeOutsLevel/Vec_PtrSize(vNodes) ); - PRT( "Time", clock() - clk2 ); + ABC_PRT( "Time", clock() - clk2 ); */ } } @@ -571,7 +567,7 @@ int Abc_NtkMfs( Abc_Ntk_t * pNtk, Mfs_Par_t * pPars ) #endif } - // free the manager + // ABC_FREE the manager p->timeTotal = clock() - clk; Mfs_ManStop( p ); return 1; diff --git a/src/opt/mfs/mfsInt.h b/src/opt/mfs/mfsInt.h index 9eb6e4a4..13f0bce2 100644 --- a/src/opt/mfs/mfsInt.h +++ b/src/opt/mfs/mfsInt.h @@ -21,10 +21,6 @@ #ifndef __MFS_INT_H__ #define __MFS_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -41,6 +37,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + #define MFS_FANIN_MAX 12 typedef struct Mfs_Man_t_ Mfs_Man_t; @@ -116,6 +116,8 @@ struct Mfs_Man_t_ int timeTotal; }; +static inline float Abc_MfsObjProb( Mfs_Man_t * p, Abc_Obj_t * pObj ) { return (p->vProbs && pObj->Id < Vec_IntSize(p->vProbs))? Abc_Int2Float(Vec_IntEntry(p->vProbs,pObj->Id)) : 0.0; } + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/mfs/mfsInter.c b/src/opt/mfs/mfsInter.c index 6e50d444..8fc30056 100644 --- a/src/opt/mfs/mfsInter.c +++ b/src/opt/mfs/mfsInter.c @@ -239,7 +239,7 @@ unsigned * Abc_NtkMfsInterplateTruth( Mfs_Man_t * p, int * pCands, int nCands, i pSat = Abc_MfsCreateSolverResub( p, pCands, nCands, fInvert ); // solve the problem - status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status != l_False ) { p->nTimeOuts++; @@ -339,7 +339,7 @@ Hop_Obj_t * Abc_NtkMfsInterplate( Mfs_Man_t * p, int * pCands, int nCands ) pSat = Abc_MfsCreateSolverResub( p, pCands, nCands, 0 ); // solve the problem - status = sat_solver_solve( pSat, NULL, NULL, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status != l_False ) { p->nTimeOuts++; diff --git a/src/opt/mfs/mfsMan.c b/src/opt/mfs/mfsMan.c index 9a043ed8..e947bd52 100644 --- a/src/opt/mfs/mfsMan.c +++ b/src/opt/mfs/mfsMan.c @@ -43,7 +43,7 @@ Mfs_Man_t * Mfs_ManAlloc( Mfs_Par_t * pPars ) { Mfs_Man_t * p; // start the manager - p = ALLOC( Mfs_Man_t, 1 ); + p = ABC_ALLOC( Mfs_Man_t, 1 ); memset( p, 0, sizeof(Mfs_Man_t) ); p->pPars = pPars; p->vProjVars = Vec_IntAlloc( 100 ); @@ -158,13 +158,13 @@ void Mfs_ManPrint( Mfs_Man_t * p ) p->nNodesDec, 1.0 * p->nNodesDec / p->nNodesTried, p->nNodesGained, p->nTimeOuts ); } /* - PRTP( "Win", p->timeWin , p->timeTotal ); - PRTP( "Div", p->timeDiv , p->timeTotal ); - PRTP( "Aig", p->timeAig , p->timeTotal ); - PRTP( "Cnf", p->timeCnf , p->timeTotal ); - PRTP( "Sat", p->timeSat-p->timeInt , p->timeTotal ); - PRTP( "Int", p->timeInt , p->timeTotal ); - PRTP( "ALL", p->timeTotal , p->timeTotal ); + ABC_PRTP( "Win", p->timeWin , p->timeTotal ); + ABC_PRTP( "Div", p->timeDiv , p->timeTotal ); + ABC_PRTP( "Aig", p->timeAig , p->timeTotal ); + ABC_PRTP( "Cnf", p->timeCnf , p->timeTotal ); + ABC_PRTP( "Sat", p->timeSat-p->timeInt , p->timeTotal ); + ABC_PRTP( "Int", p->timeInt , p->timeTotal ); + ABC_PRTP( "ALL", p->timeTotal , p->timeTotal ); */ } @@ -201,7 +201,7 @@ void Mfs_ManStop( Mfs_Man_t * p ) Vec_IntFree( p->vProjVars ); Vec_IntFree( p->vDivLits ); Vec_PtrFree( p->vDivCexes ); - free( p ); + ABC_FREE( p ); } //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/mfs/mfsResub.c b/src/opt/mfs/mfsResub.c index e9ea2c40..e49fd61d 100644 --- a/src/opt/mfs/mfsResub.c +++ b/src/opt/mfs/mfsResub.c @@ -100,7 +100,7 @@ int Abc_NtkMfsTryResubOnce( Mfs_Man_t * p, int * pCands, int nCands ) unsigned * pData; int RetValue, iVar, i; p->nSatCalls++; - RetValue = sat_solver_solve( p->pSat, pCands, pCands + nCands, (sint64)p->pPars->nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSat, pCands, pCands + nCands, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); // assert( RetValue == l_False || RetValue == l_True ); if ( RetValue == l_False ) return 1; @@ -209,8 +209,6 @@ p->timeInt += clock() - clk; iVar = -1; while ( 1 ) { - float * pProbab = (float *)(p->vProbs? p->vProbs->pArray : NULL); - assert( (pProbab != NULL) == p->pPars->fPower ); if ( fVeryVerbose ) { printf( "%3d: %2d ", p->nCexes, iVar ); @@ -231,7 +229,7 @@ p->timeInt += clock() - clk; { Abc_Obj_t * pDiv = Vec_PtrEntry(p->vDivs, iVar); // only accept the divisor if it is "cool" - if ( pProbab[Abc_ObjId(pDiv)] >= 0.15 ) + if ( Abc_MfsObjProb(p, pDiv) >= 0.15 ) continue; } pData = Vec_PtrEntry( p->vDivCexes, iVar ); @@ -355,8 +353,6 @@ p->timeInt += clock() - clk; while ( 1 ) { #if 1 // sjang - float * pProbab = (float *)(p->vProbs? p->vProbs->pArray : NULL); - assert( (pProbab != NULL) == p->pPars->fPower ); #endif if ( fVeryVerbose ) { @@ -381,7 +377,7 @@ p->timeInt += clock() - clk; { Abc_Obj_t * pDiv = Vec_PtrEntry(p->vDivs, iVar); // only accept the divisor if it is "cool" - if ( pProbab[Abc_ObjId(pDiv)] >= 0.12 ) + if ( Abc_MfsObjProb(p, pDiv) >= 0.12 ) continue; } #endif @@ -393,7 +389,7 @@ p->timeInt += clock() - clk; { Abc_Obj_t * pDiv = Vec_PtrEntry(p->vDivs, iVar2); // only accept the divisor if it is "cool" - if ( pProbab[Abc_ObjId(pDiv)] >= 0.12 ) + if ( Abc_MfsObjProb(p, pDiv) >= 0.12 ) continue; } #endif @@ -477,16 +473,15 @@ int Abc_NtkMfsEdgeSwapEval( Mfs_Man_t * p, Abc_Obj_t * pNode ) int Abc_NtkMfsEdgePower( Mfs_Man_t * p, Abc_Obj_t * pNode ) { Abc_Obj_t * pFanin; - float * pProbab = (float *)p->vProbs->pArray; int i; // try replacing area critical fanins Abc_ObjForEachFanin( pNode, pFanin, i ) { - if ( pProbab[pFanin->Id] >= 0.35 ) + if ( Abc_MfsObjProb(p, pFanin) >= 0.35 ) { if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) ) return 1; - } else if ( pProbab[pFanin->Id] >= 0.25 ) // sjang + } else if ( Abc_MfsObjProb(p, pFanin) >= 0.25 ) // sjang { if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) ) return 1; diff --git a/src/opt/mfs/mfsSat.c b/src/opt/mfs/mfsSat.c index 6cc0f0fd..a35d67e4 100644 --- a/src/opt/mfs/mfsSat.c +++ b/src/opt/mfs/mfsSat.c @@ -46,7 +46,7 @@ int Abc_NtkMfsSolveSat_iter( Mfs_Man_t * p ) if ( p->nTotConfLim && p->nTotConfLim <= p->pSat->stats.conflicts ) return -1; nBTLimit = p->nTotConfLim? p->nTotConfLim - p->pSat->stats.conflicts : 0; - RetValue = sat_solver_solve( p->pSat, NULL, NULL, (sint64)nBTLimit, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( p->pSat, NULL, NULL, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); assert( RetValue == l_Undef || RetValue == l_True || RetValue == l_False ); if ( RetValue == l_Undef ) return -1; diff --git a/src/opt/mfs/mfsStrash.c b/src/opt/mfs/mfsStrash.c index 1153e4fd..578c2fbe 100644 --- a/src/opt/mfs/mfsStrash.c +++ b/src/opt/mfs/mfsStrash.c @@ -193,14 +193,14 @@ Aig_Man_t * Abc_NtkConstructAig( Mfs_Man_t * p, Abc_Obj_t * pNode ) Aig_ManIncrementTravId( p->pCare ); Vec_PtrForEachEntry( p->vSupp, pFanin, i ) { - pPi = Aig_ManPi( p->pCare, (int)(PORT_PTRUINT_T)pFanin->pData ); + 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 ) { - vOuts = Vec_PtrEntry( p->vSuppsInv, (int)(PORT_PTRUINT_T)pFanin->pData ); + vOuts = Vec_PtrEntry( p->vSuppsInv, (int)(ABC_PTRUINT_T)pFanin->pData ); Vec_IntForEachEntry( vOuts, iOut, k ) { pPo = Aig_ManPo( p->pCare, iOut ); @@ -280,7 +280,7 @@ Aig_Man_t * Abc_NtkAigForConstraints( Mfs_Man_t * p, Abc_Obj_t * pNode ) Aig_ManIncrementTravId( p->pCare ); Vec_PtrForEachEntry( p->vSupp, pFanin, i ) { - pPi = Aig_ManPi( p->pCare, (int)(PORT_PTRUINT_T)pFanin->pData ); + pPi = Aig_ManPi( p->pCare, (int)(ABC_PTRUINT_T)pFanin->pData ); Aig_ObjSetTravIdCurrent( p->pCare, pPi ); pPi->pData = Aig_ObjCreatePi(pMan); } @@ -288,7 +288,7 @@ Aig_Man_t * Abc_NtkAigForConstraints( Mfs_Man_t * p, Abc_Obj_t * pNode ) pObjRoot = Aig_ManConst1(pMan); Vec_PtrForEachEntry( p->vSupp, pFanin, i ) { - vOuts = Vec_PtrEntry( p->vSuppsInv, (int)(PORT_PTRUINT_T)pFanin->pData ); + vOuts = Vec_PtrEntry( p->vSuppsInv, (int)(ABC_PTRUINT_T)pFanin->pData ); Vec_IntForEachEntry( vOuts, iOut, k ) { pPo = Aig_ManPo( p->pCare, iOut ); diff --git a/src/opt/res/res.h b/src/opt/res/res.h index 3c3431bf..88d985a3 100644 --- a/src/opt/res/res.h +++ b/src/opt/res/res.h @@ -21,10 +21,6 @@ #ifndef __RES_H__ #define __RES_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/res/resCore.c b/src/opt/res/resCore.c index a19a1573..cce3b48a 100644 --- a/src/opt/res/resCore.c +++ b/src/opt/res/resCore.c @@ -93,7 +93,7 @@ extern int s_ResynTime; Res_Man_t * Res_ManAlloc( Res_Par_t * pPars ) { Res_Man_t * p; - p = ALLOC( Res_Man_t, 1 ); + p = ABC_ALLOC( Res_Man_t, 1 ); memset( p, 0, sizeof(Res_Man_t) ); assert( pPars->nWindow > 0 && pPars->nWindow < 100 ); assert( pPars->nCands > 0 && pPars->nCands < 100 ); @@ -143,18 +143,18 @@ void Res_ManFree( Res_Man_t * p ) printf( "Proved = %d.", p->nProvedSets ); printf( "\n" ); - PRTP( "Windowing ", p->timeWin, p->timeTotal ); - PRTP( "Divisors ", p->timeDiv, p->timeTotal ); - PRTP( "Strashing ", p->timeAig, p->timeTotal ); - PRTP( "Simulation ", p->timeSim, p->timeTotal ); - PRTP( "Candidates ", p->timeCand, p->timeTotal ); - PRTP( "SAT solver ", p->timeSatTotal, p->timeTotal ); - PRTP( " sat ", p->timeSatSat, p->timeTotal ); - PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); - PRTP( " simul ", p->timeSatSim, p->timeTotal ); - PRTP( "Interpol ", p->timeInt, p->timeTotal ); - PRTP( "Undating ", p->timeUpd, p->timeTotal ); - PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); + ABC_PRTP( "Windowing ", p->timeWin, p->timeTotal ); + ABC_PRTP( "Divisors ", p->timeDiv, p->timeTotal ); + ABC_PRTP( "Strashing ", p->timeAig, p->timeTotal ); + ABC_PRTP( "Simulation ", p->timeSim, p->timeTotal ); + ABC_PRTP( "Candidates ", p->timeCand, p->timeTotal ); + ABC_PRTP( "SAT solver ", p->timeSatTotal, p->timeTotal ); + ABC_PRTP( " sat ", p->timeSatSat, p->timeTotal ); + ABC_PRTP( " unsat ", p->timeSatUnsat, p->timeTotal ); + ABC_PRTP( " simul ", p->timeSatSim, p->timeTotal ); + ABC_PRTP( "Interpol ", p->timeInt, p->timeTotal ); + ABC_PRTP( "Undating ", p->timeUpd, p->timeTotal ); + ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal ); } Res_WinFree( p->pWin ); if ( p->pAig ) Abc_NtkDelete( p->pAig ); @@ -165,7 +165,7 @@ void Res_ManFree( Res_Man_t * p ) Vec_VecFree( p->vResubs ); Vec_VecFree( p->vResubsW ); Vec_VecFree( p->vLevels ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/opt/res/resInt.h b/src/opt/res/resInt.h index 5aae46cc..172b5369 100644 --- a/src/opt/res/resInt.h +++ b/src/opt/res/resInt.h @@ -21,10 +21,6 @@ #ifndef __RES_INT_H__ #define __RES_INT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -35,6 +31,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/res/resSat.c b/src/opt/res/resSat.c index 798e7abc..d5983942 100644 --- a/src/opt/res/resSat.c +++ b/src/opt/res/resSat.c @@ -63,50 +63,50 @@ void * Res_SatProveUnsat( Abc_Ntk_t * pAig, Vec_Ptr_t * vFanins ) // assign unique numbers to each node nNodes = 0; - Abc_AigConst1(pAig)->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + Abc_AigConst1(pAig)->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; Abc_NtkForEachPi( pAig, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; Vec_PtrForEachEntry( vNodes, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; Vec_PtrForEachEntry( vFanins, pObj, i ) // useful POs - pObj->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; // start the solver pSat = sat_solver_new(); sat_solver_store_alloc( pSat ); // add clause for the constant node - Res_SatAddConst1( pSat, (int)(PORT_PTRUINT_T)Abc_AigConst1(pAig)->pCopy, 0 ); + Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)Abc_AigConst1(pAig)->pCopy, 0 ); // add clauses for AND gates Vec_PtrForEachEntry( vNodes, pObj, i ) - Res_SatAddAnd( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, - (int)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, (int)(PORT_PTRUINT_T)Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) ); + 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 ) - Res_SatAddEqual( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, - (int)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ); + 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); - Res_SatAddConst1( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, 0 ); // care-set + Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, 0 ); // care-set pObj = Vec_PtrEntry(vFanins, 1); - Res_SatAddConst1( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, 0 ); // on-set + 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); - Sat_SolverDoubleClauses( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy ); + Sat_SolverDoubleClauses( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy ); // add the equality constraints Vec_PtrForEachEntryStart( vFanins, pObj, i, 2 ) - Res_SatAddEqual( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, ((int)(PORT_PTRUINT_T)pObj->pCopy) + nNodes, 0 ); + Res_SatAddEqual( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, ((int)(ABC_PTRUINT_T)pObj->pCopy) + nNodes, 0 ); // bookmark the roots sat_solver_store_mark_roots( pSat ); // solve the problem - status = sat_solver_solve( pSat, NULL, NULL, (sint64)10000, (sint64)0, (sint64)0, (sint64)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)10000, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status == l_False ) { pCnf = sat_solver_store_release( pSat ); @@ -155,39 +155,39 @@ void * Res_SatSimulateConstr( Abc_Ntk_t * pAig, int fOnSet ) // assign unique numbers to each node nNodes = 0; - Abc_AigConst1(pAig)->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + Abc_AigConst1(pAig)->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; Abc_NtkForEachPi( pAig, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; Vec_PtrForEachEntry( vNodes, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; Vec_PtrForEachEntry( vFanins, pObj, i ) // useful POs - pObj->pCopy = (void *)(PORT_PTRUINT_T)nNodes++; + pObj->pCopy = (void *)(ABC_PTRUINT_T)nNodes++; // start the solver pSat = sat_solver_new(); // add clause for the constant node - Res_SatAddConst1( pSat, (int)(PORT_PTRUINT_T)Abc_AigConst1(pAig)->pCopy, 0 ); + Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)Abc_AigConst1(pAig)->pCopy, 0 ); // add clauses for AND gates Vec_PtrForEachEntry( vNodes, pObj, i ) - Res_SatAddAnd( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, - (int)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, (int)(PORT_PTRUINT_T)Abc_ObjFanin1(pObj)->pCopy, Abc_ObjFaninC0(pObj), Abc_ObjFaninC1(pObj) ); + 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 the first PO pObj = Abc_NtkPo( pAig, 0 ); - Res_SatAddEqual( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, - (int)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ); + Res_SatAddEqual( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, + (int)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ); // add clauses for the second PO pObj = Abc_NtkPo( pAig, 1 ); - Res_SatAddEqual( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, - (int)(PORT_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ); + Res_SatAddEqual( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, + (int)(ABC_PTRUINT_T)Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj) ); // add trivial clauses pObj = Abc_NtkPo( pAig, 0 ); - Res_SatAddConst1( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, 0 ); // care-set + Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, 0 ); // care-set pObj = Abc_NtkPo( pAig, 1 ); - Res_SatAddConst1( pSat, (int)(PORT_PTRUINT_T)pObj->pCopy, !fOnSet ); // on-set + Res_SatAddConst1( pSat, (int)(ABC_PTRUINT_T)pObj->pCopy, !fOnSet ); // on-set Vec_PtrFree( vFanins ); return pSat; @@ -218,7 +218,7 @@ int Res_SatSimulate( Res_Sim_t * p, int nPatsLimit, int fOnSet ) //printf( "Looking for %s: ", fOnSet? "onset " : "offset" ); // decide what problem should be solved - Lit = toLitCond( (int)(PORT_PTRUINT_T)Abc_NtkPo(p->pAig,1)->pCopy, !fOnSet ); + Lit = toLitCond( (int)(ABC_PTRUINT_T)Abc_NtkPo(p->pAig,1)->pCopy, !fOnSet ); if ( fOnSet ) { iPat = p->nPats1; @@ -254,8 +254,8 @@ int Res_SatSimulate( Res_Sim_t * p, int nPatsLimit, int fOnSet ) for ( k = iPat; k < nPatsLimit; k++ ) { // solve with the assumption -// status = sat_solver_solve( pSat, &Lit, &Lit + 1, (sint64)10000, (sint64)0, (sint64)0, (sint64)0 ); - status = sat_solver_solve( pSat, NULL, NULL, (sint64)10000, (sint64)0, (sint64)0, (sint64)0 ); +// status = sat_solver_solve( pSat, &Lit, &Lit + 1, (ABC_INT64_T)10000, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); + status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)10000, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); if ( status == l_False ) { //printf( "Const %d\n", !fOnSet ); @@ -275,7 +275,7 @@ int Res_SatSimulate( Res_Sim_t * p, int nPatsLimit, int fOnSet ) Vec_IntClear( vLits ); for ( i = 0; i < p->nTruePis; i++ ) { - Var = (int)(PORT_PTRUINT_T)Abc_NtkPi(p->pAig,i)->pCopy; + 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 ); diff --git a/src/opt/res/resSim.c b/src/opt/res/resSim.c index 5c1dd2b6..59b2b6ea 100644 --- a/src/opt/res/resSim.c +++ b/src/opt/res/resSim.c @@ -43,7 +43,7 @@ Res_Sim_t * Res_SimAlloc( int nWords ) { Res_Sim_t * p; - p = ALLOC( Res_Sim_t, 1 ); + p = ABC_ALLOC( Res_Sim_t, 1 ); memset( p, 0, sizeof(Res_Sim_t) ); // simulation parameters p->nWords = nWords; @@ -128,7 +128,7 @@ void Res_SimFree( Res_Sim_t * p ) Vec_PtrFree( p->vPats1 ); Vec_PtrFree( p->vOuts ); Vec_VecFree( p->vCands ); - free( p ); + ABC_FREE( p ); } diff --git a/src/opt/res/resWin.c b/src/opt/res/resWin.c index a3648925..e46fdc70 100644 --- a/src/opt/res/resWin.c +++ b/src/opt/res/resWin.c @@ -44,7 +44,7 @@ Res_Win_t * Res_WinAlloc() { Res_Win_t * p; // start the manager - p = ALLOC( Res_Win_t, 1 ); + p = ABC_ALLOC( Res_Win_t, 1 ); memset( p, 0, sizeof(Res_Win_t) ); // set internal parameters p->nFanoutLimit = 10; @@ -78,7 +78,7 @@ void Res_WinFree( Res_Win_t * p ) Vec_PtrFree( p->vNodes ); Vec_PtrFree( p->vDivs ); Vec_VecFree( p->vMatrix ); - free( p ); + ABC_FREE( p ); } diff --git a/src/opt/ret/retArea.c b/src/opt/ret/retArea.c index 318147f5..63503916 100644 --- a/src/opt/ret/retArea.c +++ b/src/opt/ret/retArea.c @@ -264,22 +264,22 @@ int Abc_NtkRetimeMinAreaInitValues_rec( Abc_Obj_t * pObj ) int i; // skip visited nodes if ( Abc_NodeIsTravIdCurrent(pObj) ) - return (int)(PORT_PTRUINT_T)pObj->pCopy; + return (int)(ABC_PTRUINT_T)pObj->pCopy; Abc_NodeSetTravIdCurrent(pObj); // consider the case of a latch output if ( Abc_ObjIsBo(pObj) ) { assert( Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) ); - pObj->pCopy = (void *)(PORT_PTRUINT_T)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) ); - return (int)(PORT_PTRUINT_T)pObj->pCopy; + pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) ); + return (int)(ABC_PTRUINT_T)pObj->pCopy; } assert( Abc_ObjIsNode(pObj) ); // visit the fanins Abc_ObjForEachFanin( pObj, pFanin, i ) Abc_NtkRetimeMinAreaInitValues_rec( pFanin ); // compute the value of the node - pObj->pCopy = (void *)(PORT_PTRUINT_T)Abc_ObjSopSimulate(pObj); - return (int)(PORT_PTRUINT_T)pObj->pCopy; + pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate(pObj); + return (int)(ABC_PTRUINT_T)pObj->pCopy; } /**Function************************************************************* @@ -301,7 +301,7 @@ void Abc_NtkRetimeMinAreaInitValues( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut ) Abc_NtkIncrementTravId(pNtk); Abc_NtkForEachLatch( pNtk, pObj, i ) { - pObj->pCopy = (void *)(PORT_PTRUINT_T)Abc_LatchIsInit1(pObj); + pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj); Abc_NodeSetTravIdCurrent( pObj ); } // propagate initial values @@ -478,7 +478,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i Abc_ObjAddFanin( pLatch, pLatchIn ); if ( fForward ) { - pLatch->pData = (void *)(PORT_PTRUINT_T)(pObj->pCopy? ABC_INIT_ONE : ABC_INIT_ZERO); + 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 ) diff --git a/src/opt/ret/retCore.c b/src/opt/ret/retCore.c index 47b2cbbc..9de1b723 100644 --- a/src/opt/ret/retCore.c +++ b/src/opt/ret/retCore.c @@ -94,7 +94,7 @@ int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOn { printf( "Reduction in area = %3d. Reduction in delay = %3d. ", nLatches - Abc_NtkLatchNum(pNtk), nLevels - Abc_NtkLevel(pNtk) ); - PRT( "Total runtime", clock() - clkTotal ); + ABC_PRT( "Total runtime", clock() - clkTotal ); } timeRetime = clock() - clkTotal; return RetValue; diff --git a/src/opt/ret/retFlow.c b/src/opt/ret/retFlow.c index bad4b7e7..7c17c1f6 100644 --- a/src/opt/ret/retFlow.c +++ b/src/opt/ret/retFlow.c @@ -228,7 +228,7 @@ Vec_Ptr_t * Abc_NtkMaxFlow( Abc_Ntk_t * pNtk, int fForward, int fVerbose ) { printf( "L = %6d. %s max-flow = %6d. Min-cut = %6d. ", Abc_NtkLatchNum(pNtk), fForward? "Forward " : "Backward", Flow, Vec_PtrSize(vMinCut) ); -PRT( "Time", clock() - clk ); +ABC_PRT( "Time", clock() - clk ); } // Abc_NtkMaxFlowPrintCut( pNtk, vMinCut ); diff --git a/src/opt/ret/retIncrem.c b/src/opt/ret/retIncrem.c index 140e5dcc..233fb436 100644 --- a/src/opt/ret/retIncrem.c +++ b/src/opt/ret/retIncrem.c @@ -113,7 +113,7 @@ st_table * Abc_NtkRetimePrepareLatches( Abc_Ntk_t * pNtk ) Abc_NtkForEachLatch( pNtk, pLatch, i ) { // map latch into its true number - st_insert( tLatches, (void *)(PORT_PTRUINT_T)pLatch, (void *)(PORT_PTRUINT_T)(i-nOffSet) ); + st_insert( tLatches, (void *)(ABC_PTRUINT_T)pLatch, (void *)(ABC_PTRUINT_T)(i-nOffSet) ); // disconnect LI pLatchIn = Abc_ObjFanin0(pLatch); pFanin = Abc_ObjFanin0(pLatchIn); @@ -194,7 +194,7 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId Vec_PtrPush( vCosNew, pLatchIn ); Vec_PtrPush( vBoxesNew, pLatch ); } - // free useless Cis/Cos + // ABC_FREE useless Cis/Cos Vec_PtrForEachEntry( vCisOld, pObj, i ) if ( !Abc_ObjIsPi(pObj) && Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 ) Abc_NtkDeleteObj(pObj); @@ -320,7 +320,7 @@ void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial ) { // compute the initial value if ( fInitial ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)Abc_ObjSopSimulate( pObj ); + pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj ); // collect fanins Abc_NodeCollectFanins( pObj, vNodes ); // make the node point to the fanins fanins @@ -400,10 +400,10 @@ int Abc_NtkRetimeCheckCompatibleLatchFanouts( Abc_Obj_t * pObj ) continue; if ( Init == -1 ) { - Init = (int)(PORT_PTRUINT_T)pObj->pData; + Init = (int)(ABC_PTRUINT_T)pObj->pData; nLatches++; } - else if ( Init == (int)(PORT_PTRUINT_T)pObj->pData ) + else if ( Init == (int)(ABC_PTRUINT_T)pObj->pData ) nLatches++; } return nLatches; diff --git a/src/opt/ret/retInit.c b/src/opt/ret/retInit.c index 8de0ef47..72b384d9 100644 --- a/src/opt/ret/retInit.c +++ b/src/opt/ret/retInit.c @@ -57,9 +57,9 @@ Vec_Int_t * Abc_NtkRetimeInitialValues( Abc_Ntk_t * pNtkCone, Vec_Int_t * vValue printf( "The miter for initial state computation has %d AIG nodes. ", Abc_NtkNodeNum(pNtkMiter) ); // solve the miter clk = clock(); - RetValue = Abc_NtkMiterSat( pNtkMiter, (sint64)500000, (sint64)50000000, 0, NULL, NULL ); + RetValue = Abc_NtkMiterSat( pNtkMiter, (ABC_INT64_T)500000, (ABC_INT64_T)50000000, 0, NULL, NULL ); if ( fVerbose ) - { PRT( "SAT solving time", clock() - clk ); } + { ABC_PRT( "SAT solving time", clock() - clk ); } // analyze the result if ( RetValue == 1 ) printf( "Abc_NtkRetimeInitialValues(): The problem is unsatisfiable. DC latch values are used.\n" ); @@ -100,9 +100,9 @@ int Abc_ObjSopSimulate( Abc_Obj_t * pObj ) Abc_CubeForEachVar( pCube, Value, v ) { if ( Value == '0' ) - ResVar = 1 ^ ((int)(PORT_PTRUINT_T)Abc_ObjFanin(pObj, v)->pCopy); + ResVar = 1 ^ ((int)(ABC_PTRUINT_T)Abc_ObjFanin(pObj, v)->pCopy); else if ( Value == '1' ) - ResVar = (int)(PORT_PTRUINT_T)Abc_ObjFanin(pObj, v)->pCopy; + ResVar = (int)(ABC_PTRUINT_T)Abc_ObjFanin(pObj, v)->pCopy; else continue; ResAnd &= ResVar; @@ -134,17 +134,17 @@ 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 *)(PORT_PTRUINT_T)pModel[i]; + pObj->pCopy = (void *)(ABC_PTRUINT_T)pModel[i]; // simulate the internal nodes vNodes = Abc_NtkDfs( pNtkCone, 0 ); Vec_PtrForEachEntry( vNodes, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)Abc_ObjSopSimulate( pObj ); + pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj ); Vec_PtrFree( vNodes ); // compare the outputs Abc_NtkForEachPo( pNtkCone, pObj, i ) pObj->pCopy = Abc_ObjFanin0(pObj)->pCopy; Abc_NtkForEachPo( pNtkCone, pObj, i ) - Counter += (Vec_IntEntry(vValues, i) != (int)(PORT_PTRUINT_T)pObj->pCopy); + Counter += (Vec_IntEntry(vValues, i) != (int)(ABC_PTRUINT_T)pObj->pCopy); if ( Counter > 0 ) printf( "%d outputs (out of %d) have a value mismatch.\n", Counter, Abc_NtkPoNum(pNtkCone) ); return 1; @@ -167,7 +167,7 @@ void Abc_NtkRetimeTranferToCopy( Abc_Ntk_t * pNtk ) int i; Abc_NtkForEachObj( pNtk, pObj, i ) if ( Abc_ObjIsLatch(pObj) ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)Abc_LatchIsInit1(pObj); + pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj); } /**Function************************************************************* @@ -187,7 +187,7 @@ void Abc_NtkRetimeTranferFromCopy( Abc_Ntk_t * pNtk ) int i; Abc_NtkForEachObj( pNtk, pObj, i ) if ( Abc_ObjIsLatch(pObj) ) - pObj->pData = (void *)(PORT_PTRUINT_T)(pObj->pCopy? ABC_INIT_ONE : ABC_INIT_ZERO); + pObj->pData = (void *)(ABC_PTRUINT_T)(pObj->pCopy? ABC_INIT_ONE : ABC_INIT_ZERO); } /**Function************************************************************* @@ -230,10 +230,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 *)(PORT_PTRUINT_T)Counter++; + pObj->pCopy = (void *)(ABC_PTRUINT_T)Counter++; Abc_NtkForEachObj( pNtk, pObj, i ) if ( Abc_ObjIsLatch(pObj) ) - pObj->pData = (void *)(PORT_PTRUINT_T)(vValues? (Vec_IntEntry(vValues,(int)(PORT_PTRUINT_T)pObj->pCopy)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC); + 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); } /**Function************************************************************* @@ -316,22 +316,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 *)(PORT_PTRUINT_T)(rand() & 1); + pObj->pCopy = (void *)(ABC_PTRUINT_T)(rand() & 1); Abc_NtkForEachLatch( pNtk, pObj, i ) - pObj->pCopy = (void *)(PORT_PTRUINT_T)Abc_LatchIsInit1(pObj); + pObj->pCopy = (void *)(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 *)(PORT_PTRUINT_T)Abc_ObjSopSimulate( pObj ); + pObj->pCopy = (void *)(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 *)(PORT_PTRUINT_T)(rand() & 1); + pObj->pCopy = (void *)(ABC_PTRUINT_T)(rand() & 1); // transfer the latch values Abc_NtkForEachLatch( pNtk, pObj, i ) Abc_ObjFanout0(pObj)->pCopy = Abc_ObjFanin0(pObj)->pCopy; @@ -339,7 +339,7 @@ void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose ) Vec_PtrFree( vNodes ); // set the final values Abc_NtkForEachLatch( pNtk, pObj, i ) - pObj->pData = (void *)(PORT_PTRUINT_T)(Abc_ObjFanout0(pObj)->pCopy ? ABC_INIT_ONE : ABC_INIT_ZERO); + pObj->pData = (void *)(ABC_PTRUINT_T)(Abc_ObjFanout0(pObj)->pCopy ? ABC_INIT_ONE : ABC_INIT_ZERO); } //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/ret/retLvalue.c b/src/opt/ret/retLvalue.c index 26f51f09..02d9cac2 100644 --- a/src/opt/ret/retLvalue.c +++ b/src/opt/ret/retLvalue.c @@ -37,8 +37,8 @@ static Vec_Ptr_t * Abc_ManCollectLatches( Abc_Ntk_t * pNtk ); static int Abc_NtkRetimeUsingLags( Abc_Ntk_t * pNtk, Vec_Int_t * vLags, int fVerbose ); 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)(PORT_PTRUINT_T)pNode->pCopy; } -static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { pNode->pCopy = (void *)(PORT_PTRUINT_T)Value; } +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; } //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// diff --git a/src/opt/rwr/rwr.h b/src/opt/rwr/rwr.h index 64e916e2..5adc3b4b 100644 --- a/src/opt/rwr/rwr.h +++ b/src/opt/rwr/rwr.h @@ -21,10 +21,6 @@ #ifndef __RWR_H__ #define __RWR_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -36,6 +32,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// @@ -111,10 +111,10 @@ struct Rwr_Node_t_ // 24 bytes }; // manipulation of complemented attributes -static inline bool Rwr_IsComplement( Rwr_Node_t * p ) { return (bool)(((PORT_PTRUINT_T)p) & 01); } -static inline Rwr_Node_t * Rwr_Regular( Rwr_Node_t * p ) { return (Rwr_Node_t *)((PORT_PTRUINT_T)(p) & ~01); } -static inline Rwr_Node_t * Rwr_Not( Rwr_Node_t * p ) { return (Rwr_Node_t *)((PORT_PTRUINT_T)(p) ^ 01); } -static inline Rwr_Node_t * Rwr_NotCond( Rwr_Node_t * p, int c ) { return (Rwr_Node_t *)((PORT_PTRUINT_T)(p) ^ (c)); } +static inline bool Rwr_IsComplement( Rwr_Node_t * p ) { return (bool)(((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)); } //////////////////////////////////////////////////////////////////////// /// MACRO DEFINITIONS /// diff --git a/src/opt/rwr/rwrDec.c b/src/opt/rwr/rwrDec.c index ae01b896..81c7e307 100644 --- a/src/opt/rwr/rwrDec.c +++ b/src/opt/rwr/rwrDec.c @@ -49,7 +49,7 @@ void Rwr_ManPreprocess( Rwr_Man_t * p ) Rwr_Node_t * pNode; int i, k; // put the nodes into the structure - p->pMapInv = ALLOC( unsigned short, 222 ); + p->pMapInv = ABC_ALLOC( unsigned short, 222 ); memset( p->pMapInv, 0, sizeof(unsigned short) * 222 ); p->vClasses = Vec_VecStart( 222 ); for ( i = 0; i < p->nFuncs; i++ ) diff --git a/src/opt/rwr/rwrExp.c b/src/opt/rwr/rwrExp.c index 5729cdbc..543cae07 100644 --- a/src/opt/rwr/rwrExp.c +++ b/src/opt/rwr/rwrExp.c @@ -64,14 +64,14 @@ static Rwr_Man5_t * s_pManRwrExp5 = NULL; void Rwt_Man4ExploreStart() { Rwr_Man4_t * p; - p = ALLOC( Rwr_Man4_t, 1 ); + p = ABC_ALLOC( Rwr_Man4_t, 1 ); memset( p, 0, sizeof(Rwr_Man4_t) ); // canonical forms p->nFuncs = (1<<16); // canonical forms, phases, perms Extra_Truth4VarNPN( &p->puCanons, NULL, NULL, NULL ); // counters - p->pnCounts = ALLOC( int, p->nFuncs ); + p->pnCounts = ABC_ALLOC( int, p->nFuncs ); memset( p->pnCounts, 0, sizeof(int) * p->nFuncs ); s_pManRwrExp4 = p; } @@ -124,8 +124,8 @@ void Rwt_Man4ExplorePrint() printf( "Number of cuts considered = %8d.\n", nCuts ); printf( "Classes occurring at least once = %8d.\n", nClasses ); // print the distribution of classes - pDistrib = ALLOC( int, CountMax + 1 ); - pReprs = ALLOC( int, CountMax + 1 ); + pDistrib = ABC_ALLOC( int, CountMax + 1 ); + pReprs = ABC_ALLOC( int, CountMax + 1 ); memset( pDistrib, 0, sizeof(int)*(CountMax + 1) ); for ( i = 0; i < s_pManRwrExp4->nFuncs; i++ ) { @@ -141,8 +141,8 @@ void Rwt_Man4ExplorePrint() Extra_PrintBinary( stdout, (unsigned*)&(pReprs[i]), 16 ); printf( "\n" ); } - free( pDistrib ); - free( pReprs ); + ABC_FREE( pDistrib ); + ABC_FREE( pReprs ); // write into a file all classes above limit (5) CountWrite = 0; pFile = fopen( "npnclass_stats4.txt", "w" ); @@ -175,7 +175,7 @@ void Rwt_Man4ExplorePrint() void Rwt_Man5ExploreStart() { Rwr_Man5_t * p; - p = ALLOC( Rwr_Man5_t, 1 ); + p = ABC_ALLOC( Rwr_Man5_t, 1 ); memset( p, 0, sizeof(Rwr_Man5_t) ); p->tTableNN = stmm_init_table( st_numcmp, st_numhash ); p->tTableNPN = stmm_init_table( st_numcmp, st_numhash ); @@ -199,7 +199,7 @@ void Rwt_Man5ExploreStart() void Rwt_Man5ExploreCount( unsigned uTruth ) { int * pCounter; - if ( !stmm_find_or_add( s_pManRwrExp5->tTableNN, (char *)(PORT_PTRUINT_T)uTruth, (char***)&pCounter ) ) + if ( !stmm_find_or_add( s_pManRwrExp5->tTableNN, (char *)(ABC_PTRUINT_T)uTruth, (char***)&pCounter ) ) *pCounter = 0; (*pCounter)++; } @@ -240,8 +240,8 @@ void Rwt_Man5ExplorePrint() printf( "The largest number of occurence = %8d.\n", CountMax ); // print the distribution of classes - pDistrib = ALLOC( int, CountMax + 1 ); - pReprs = ALLOC( unsigned, CountMax + 1 ); + pDistrib = ABC_ALLOC( int, CountMax + 1 ); + pReprs = ABC_ALLOC( unsigned, CountMax + 1 ); memset( pDistrib, 0, sizeof(int)*(CountMax + 1) ); stmm_foreach_item( s_pManRwrExp5->tTableNN, gen, (char **)&uTruth, (char **)&Counter ) { @@ -257,8 +257,8 @@ void Rwt_Man5ExplorePrint() Extra_PrintBinary( stdout, pReprs + i, 32 ); printf( "\n" ); } - free( pDistrib ); - free( pReprs ); + ABC_FREE( pDistrib ); + ABC_FREE( pReprs ); // put them into an array @@ -271,7 +271,7 @@ void Rwt_Man5ExplorePrint() pFile = fopen( "nnclass_stats5.txt", "w" ); Vec_IntForEachEntry( vClassesNN, uTruth, i ) { - if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)(PORT_PTRUINT_T)uTruth, (char **)&Counter ) ) + if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)(ABC_PTRUINT_T)uTruth, (char **)&Counter ) ) { assert( 0 ); } @@ -288,16 +288,16 @@ clk = clock(); { int * pCounter; uTruthC = Extra_TruthCanonNPN( uTruth, 5 ); - if ( !stmm_find_or_add( s_pManRwrExp5->tTableNPN, (char *)(PORT_PTRUINT_T)uTruthC, (char***)&pCounter ) ) + if ( !stmm_find_or_add( s_pManRwrExp5->tTableNPN, (char *)(ABC_PTRUINT_T)uTruthC, (char***)&pCounter ) ) *pCounter = 0; - if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)(PORT_PTRUINT_T)uTruth, (char **)&Counter ) ) + if ( !stmm_lookup( s_pManRwrExp5->tTableNN, (char *)(ABC_PTRUINT_T)uTruth, (char **)&Counter ) ) { assert( 0 ); } (*pCounter) += Counter; } printf( "The numbe of NPN classes = %d.\n", stmm_count(s_pManRwrExp5->tTableNPN) ); -PRT( "Computing NPN classes", clock() - clk ); +ABC_PRT( "Computing NPN classes", clock() - clk ); // put them into an array vClassesNPN = Vec_IntAlloc( stmm_count(s_pManRwrExp5->tTableNPN) ); @@ -309,7 +309,7 @@ PRT( "Computing NPN classes", clock() - clk ); pFile = fopen( "npnclass_stats5.txt", "w" ); Vec_IntForEachEntry( vClassesNPN, uTruth, i ) { - if ( !stmm_lookup( s_pManRwrExp5->tTableNPN, (char *)(PORT_PTRUINT_T)uTruth, (char **)&Counter ) ) + if ( !stmm_lookup( s_pManRwrExp5->tTableNPN, (char *)(ABC_PTRUINT_T)uTruth, (char **)&Counter ) ) { assert( 0 ); } diff --git a/src/opt/rwr/rwrMan.c b/src/opt/rwr/rwrMan.c index 87a080c7..e7d21164 100644 --- a/src/opt/rwr/rwrMan.c +++ b/src/opt/rwr/rwrMan.c @@ -47,7 +47,7 @@ Rwr_Man_t * Rwr_ManStart( bool fPrecompute ) Rwr_Man_t * p; int clk = clock(); clk = clock(); - p = ALLOC( Rwr_Man_t, 1 ); + p = ABC_ALLOC( Rwr_Man_t, 1 ); memset( p, 0, sizeof(Rwr_Man_t) ); p->nFuncs = (1<<16); pManDec = Abc_FrameReadManDec(); @@ -58,7 +58,7 @@ clk = clock(); // initialize practical NPN classes p->pPractical = Rwr_ManGetPractical( p ); // create the table - p->pTable = ALLOC( Rwr_Node_t *, p->nFuncs ); + p->pTable = ABC_ALLOC( Rwr_Node_t *, p->nFuncs ); memset( p->pTable, 0, sizeof(Rwr_Node_t *) * p->nFuncs ); // create the elementary nodes p->pMmNode = Extra_MmFixedStart( sizeof(Rwr_Node_t) ); @@ -119,11 +119,11 @@ void Rwr_ManStop( Rwr_Man_t * p ) Vec_PtrFree( p->vFanins ); Vec_PtrFree( p->vFaninsCur ); Extra_MmFixedStop( p->pMmNode ); - FREE( p->pMapInv ); - free( p->pTable ); - free( p->pPractical ); - free( p->pPerms4 ); - free( p ); + ABC_FREE( p->pMapInv ); + ABC_FREE( p->pTable ); + ABC_FREE( p->pPractical ); + ABC_FREE( p->pPerms4 ); + ABC_FREE( p ); } /**Function************************************************************* @@ -151,13 +151,13 @@ void Rwr_ManPrintStats( Rwr_Man_t * p ) printf( "Nodes considered = %8d.\n", p->nNodesConsidered ); printf( "Nodes rewritten = %8d.\n", p->nNodesRewritten ); printf( "Gain = %8d. (%6.2f %%).\n", p->nNodesBeg-p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg ); - PRT( "Start ", p->timeStart ); - PRT( "Cuts ", p->timeCut ); - PRT( "Resynthesis ", p->timeRes ); - PRT( " Mffc ", p->timeMffc ); - PRT( " Eval ", p->timeEval ); - PRT( "Update ", p->timeUpdate ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Start ", p->timeStart ); + ABC_PRT( "Cuts ", p->timeCut ); + ABC_PRT( "Resynthesis ", p->timeRes ); + ABC_PRT( " Mffc ", p->timeMffc ); + ABC_PRT( " Eval ", p->timeEval ); + ABC_PRT( "Update ", p->timeUpdate ); + ABC_PRT( "TOTAL ", p->timeTotal ); /* printf( "The scores are:\n" ); diff --git a/src/opt/rwr/rwrUtil.c b/src/opt/rwr/rwrUtil.c index b2add2bf..8da3b6eb 100644 --- a/src/opt/rwr/rwrUtil.c +++ b/src/opt/rwr/rwrUtil.c @@ -78,7 +78,7 @@ void Rwr_ManWriteToArray( Rwr_Man_t * p ) Extra_PrintHex( pFile, 0, 4 ); fprintf( pFile, " \n};\n" ); fclose( pFile ); - printf( "The number of nodes saved = %d. ", nEntries ); PRT( "Saving", clock() - clk ); + printf( "The number of nodes saved = %d. ", nEntries ); ABC_PRT( "Saving", clock() - clk ); } /**Function************************************************************* @@ -127,7 +127,7 @@ void Rwr_ManLoadFromArray( Rwr_Man_t * p, int fVerbose ) if ( fVerbose ) { printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded ); - printf( "The number of nodes loaded = %d. ", nEntries ); PRT( "Loading", clock() - clk ); + printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", clock() - clk ); } } @@ -151,7 +151,7 @@ void Rwr_ManWriteToFile( Rwr_Man_t * p, char * pFileName ) int i, nEntries, clk = clock(); // prepare the buffer nEntries = p->vForest->nSize - 5; - pBuffer = ALLOC( unsigned, nEntries * 2 ); + pBuffer = ABC_ALLOC( unsigned, nEntries * 2 ); for ( i = 0; i < nEntries; i++ ) { pNode = p->vForest->pArray[i+5]; @@ -164,9 +164,9 @@ void Rwr_ManWriteToFile( Rwr_Man_t * p, char * pFileName ) pFile = fopen( pFileName, "wb" ); fwrite( &nEntries, sizeof(int), 1, pFile ); fwrite( pBuffer, sizeof(unsigned), nEntries * 2, pFile ); - free( pBuffer ); + ABC_FREE( pBuffer ); fclose( pFile ); - printf( "The number of nodes saved = %d. ", nEntries ); PRT( "Saving", clock() - clk ); + printf( "The number of nodes saved = %d. ", nEntries ); ABC_PRT( "Saving", clock() - clk ); } /**Function************************************************************* @@ -196,7 +196,7 @@ void Rwr_ManLoadFromFile( Rwr_Man_t * p, char * pFileName ) return; } fread( &nEntries, sizeof(int), 1, pFile ); - pBuffer = ALLOC( unsigned, nEntries * 2 ); + pBuffer = ABC_ALLOC( unsigned, nEntries * 2 ); fread( pBuffer, sizeof(unsigned), nEntries * 2, pFile ); fclose( pFile ); // reconstruct the forest @@ -218,9 +218,9 @@ void Rwr_ManLoadFromFile( Rwr_Man_t * p, char * pFileName ) // Rwr_ManTryNode( p, p0, p1, Level, Volume ); Rwr_ManAddNode( p, p0, p1, fExor, Level, Volume + fExor ); } - free( pBuffer ); + ABC_FREE( pBuffer ); printf( "The number of classes = %d. Canonical nodes = %d.\n", p->nClasses, p->nAdded ); - printf( "The number of nodes loaded = %d. ", nEntries ); PRT( "Loading", clock() - clk ); + printf( "The number of nodes loaded = %d. ", nEntries ); ABC_PRT( "Loading", clock() - clk ); } @@ -260,7 +260,7 @@ char * Rwr_ManGetPractical( Rwr_Man_t * p ) { char * pPractical; int i; - pPractical = ALLOC( char, p->nFuncs ); + pPractical = ABC_ALLOC( char, p->nFuncs ); memset( pPractical, 0, sizeof(char) * p->nFuncs ); pPractical[0] = 1; for ( i = 1; ; i++ ) diff --git a/src/opt/sim/sim.h b/src/opt/sim/sim.h index 7fcf5ae6..89eaafac 100644 --- a/src/opt/sim/sim.h +++ b/src/opt/sim/sim.h @@ -21,10 +21,6 @@ #ifndef __SIM_H__ #define __SIM_H__ -#ifdef __cplusplus -extern "C" { -#endif - /* The ideas realized in this package are described in the paper: "Detecting Symmetries in Boolean Functions using Circuit Representation, @@ -39,6 +35,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/opt/sim/simMan.c b/src/opt/sim/simMan.c index 139a1a05..6a86e25f 100644 --- a/src/opt/sim/simMan.c +++ b/src/opt/sim/simMan.c @@ -45,7 +45,7 @@ Sym_Man_t * Sym_ManStart( Abc_Ntk_t * pNtk, int fVerbose ) Sym_Man_t * p; int i, v; // start the manager - p = ALLOC( Sym_Man_t, 1 ); + p = ABC_ALLOC( Sym_Man_t, 1 ); memset( p, 0, sizeof(Sym_Man_t) ); p->pNtk = pNtk; p->vNodes = Abc_NtkDfs( pNtk, 0 ); @@ -66,9 +66,9 @@ Sym_Man_t * Sym_ManStart( Abc_Ntk_t * pNtk, int fVerbose ) p->vMatrNonSymms->pArray[i] = Extra_BitMatrixStart( p->nInputs ); } // temporary patterns - p->uPatRand = ALLOC( unsigned, p->nSimWords ); - p->uPatCol = ALLOC( unsigned, p->nSimWords ); - p->uPatRow = ALLOC( unsigned, p->nSimWords ); + p->uPatRand = ABC_ALLOC( unsigned, p->nSimWords ); + p->uPatCol = ABC_ALLOC( unsigned, p->nSimWords ); + p->uPatRow = ABC_ALLOC( unsigned, p->nSimWords ); p->vVarsU = Vec_IntStart( 100 ); p->vVarsV = Vec_IntStart( 100 ); // compute supports @@ -77,7 +77,7 @@ Sym_Man_t * Sym_ManStart( Abc_Ntk_t * pNtk, int fVerbose ) for ( i = 0; i < p->nOutputs; i++ ) for ( v = 0; v < p->nInputs; v++ ) if ( Sim_SuppFunHasVar( p->vSuppFun, i, v ) ) - Vec_VecPush( p->vSupports, i, (void *)(PORT_PTRUINT_T)v ); + Vec_VecPush( p->vSupports, i, (void *)(ABC_PTRUINT_T)v ); return p; } @@ -112,10 +112,10 @@ void Sym_ManStop( Sym_Man_t * p ) Vec_IntFree( p->vPairsTotal ); Vec_IntFree( p->vPairsSym ); Vec_IntFree( p->vPairsNonSym ); - FREE( p->uPatRand ); - FREE( p->uPatCol ); - FREE( p->uPatRow ); - free( p ); + ABC_FREE( p->uPatRand ); + ABC_FREE( p->uPatCol ); + ABC_FREE( p->uPatRow ); + ABC_FREE( p ); } /**Function************************************************************* @@ -139,13 +139,13 @@ void Sym_ManPrintStats( Sym_Man_t * p ) printf( "Total var pairs = %8d.\n", p->nPairsTotal ); printf( "Sat runs SAT = %8d.\n", p->nSatRunsSat ); printf( "Sat runs UNSAT = %8d.\n", p->nSatRunsUnsat ); - PRT( "Structural ", p->timeStruct ); - PRT( "Simulation ", p->timeSim ); - PRT( "Matrix ", p->timeMatr ); - PRT( "Counting ", p->timeCount ); - PRT( "Fraiging ", p->timeFraig ); - PRT( "SAT ", p->timeSat ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Structural ", p->timeStruct ); + ABC_PRT( "Simulation ", p->timeSim ); + ABC_PRT( "Matrix ", p->timeMatr ); + ABC_PRT( "Counting ", p->timeCount ); + ABC_PRT( "Fraiging ", p->timeFraig ); + ABC_PRT( "SAT ", p->timeSat ); + ABC_PRT( "TOTAL ", p->timeTotal ); } @@ -164,7 +164,7 @@ Sim_Man_t * Sim_ManStart( Abc_Ntk_t * pNtk, int fLightweight ) { Sim_Man_t * p; // start the manager - p = ALLOC( Sim_Man_t, 1 ); + p = ABC_ALLOC( Sim_Man_t, 1 ); memset( p, 0, sizeof(Sim_Man_t) ); p->pNtk = pNtk; p->nInputs = Abc_NtkCiNum(p->pNtk); @@ -213,7 +213,7 @@ void Sim_ManStop( Sim_Man_t * p ) if ( p->pMmPat ) Extra_MmFixedStop( p->pMmPat ); if ( p->vFifo ) Vec_PtrFree( p->vFifo ); if ( p->vDiffs ) Vec_IntFree( p->vDiffs ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -235,11 +235,11 @@ void Sim_ManPrintStats( Sim_Man_t * p ) printf( "Total struct supps = %8d.\n", Sim_UtilCountSuppSizes(p, 1) ); printf( "Sat runs SAT = %8d.\n", p->nSatRunsSat ); printf( "Sat runs UNSAT = %8d.\n", p->nSatRunsUnsat ); - PRT( "Simulation ", p->timeSim ); - PRT( "Traversal ", p->timeTrav ); - PRT( "Fraiging ", p->timeFraig ); - PRT( "SAT ", p->timeSat ); - PRT( "TOTAL ", p->timeTotal ); + ABC_PRT( "Simulation ", p->timeSim ); + ABC_PRT( "Traversal ", p->timeTrav ); + ABC_PRT( "Fraiging ", p->timeFraig ); + ABC_PRT( "SAT ", p->timeSat ); + ABC_PRT( "TOTAL ", p->timeTotal ); } diff --git a/src/opt/sim/simSupp.c b/src/opt/sim/simSupp.c index e6ba853c..f84fedc4 100644 --- a/src/opt/sim/simSupp.c +++ b/src/opt/sim/simSupp.c @@ -319,7 +319,7 @@ void Sim_ComputeSuppSetTargets( Sim_Man_t * p ) // 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 ) - Vec_VecPush( p->vSuppTargs, Num, (void *)(PORT_PTRUINT_T)i ); + Vec_VecPush( p->vSuppTargs, Num, (void *)(ABC_PTRUINT_T)i ); } } @@ -460,7 +460,7 @@ void Sim_SolveTargetsUsingSat( Sim_Man_t * p, int Limit ) Vec_VecForEachEntryReverse( p->vSuppTargs, pEntry, Input, k ) { p->nSatRuns++; - Output = (int)(PORT_PTRUINT_T)pEntry; + Output = (int)(ABC_PTRUINT_T)pEntry; // set up the miter for the two cofactors of this output w.r.t. this input pMiter = Abc_NtkMiterForCofactors( p->pNtk, Output, Input, -1 ); @@ -545,7 +545,7 @@ int Sim_NtkSimTwoPats_rec( Abc_Obj_t * pNode ) { int Value0, Value1; if ( Abc_NodeIsTravIdCurrent( pNode ) ) - return (int)(PORT_PTRUINT_T)pNode->pCopy; + return (int)(ABC_PTRUINT_T)pNode->pCopy; Abc_NodeSetTravIdCurrent( pNode ); Value0 = Sim_NtkSimTwoPats_rec( Abc_ObjFanin0(pNode) ); Value1 = Sim_NtkSimTwoPats_rec( Abc_ObjFanin1(pNode) ); @@ -553,7 +553,7 @@ int Sim_NtkSimTwoPats_rec( Abc_Obj_t * pNode ) Value0 = ~Value0; if ( Abc_ObjFaninC1(pNode) ) Value1 = ~Value1; - pNode->pCopy = (Abc_Obj_t *)(PORT_PTRUINT_T)(Value0 & Value1); + pNode->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)(Value0 & Value1); return Value0 & Value1; } diff --git a/src/opt/sim/simSymStr.c b/src/opt/sim/simSymStr.c index d52c4328..9ff2f590 100644 --- a/src/opt/sim/simSymStr.c +++ b/src/opt/sim/simSymStr.c @@ -96,7 +96,7 @@ void Sim_SymmsStructCompute( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMatrs, Vec_Ptr_t * v // if ( !Abc_NodeIsConst(pTemp) ) Vec_IntFree( SIM_READ_SYMMS(pTemp) ); Vec_PtrFree( vNodes ); - free( pMap ); + ABC_FREE( pMap ); } /**Function************************************************************* @@ -471,7 +471,7 @@ int * Sim_SymmsCreateMap( Abc_Ntk_t * pNtk ) int * pMap; Abc_Obj_t * pNode; int i; - pMap = ALLOC( int, Abc_NtkObjNumMax(pNtk) ); + pMap = ABC_ALLOC( int, Abc_NtkObjNumMax(pNtk) ); for ( i = 0; i < Abc_NtkObjNumMax(pNtk); i++ ) pMap[i] = -1; Abc_NtkForEachCi( pNtk, pNode, i ) diff --git a/src/opt/sim/simUtils.c b/src/opt/sim/simUtils.c index b74f3abe..dba487d8 100644 --- a/src/opt/sim/simUtils.c +++ b/src/opt/sim/simUtils.c @@ -57,7 +57,7 @@ Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, bool fClean ) int i; assert( nSize > 0 && nWords > 0 ); vInfo = Vec_PtrAlloc( nSize ); - vInfo->pArray[0] = ALLOC( unsigned, nSize * nWords ); + vInfo->pArray[0] = ABC_ALLOC( unsigned, nSize * nWords ); if ( fClean ) memset( vInfo->pArray[0], 0, sizeof(unsigned) * nSize * nWords ); for ( i = 1; i < nSize; i++ ) @@ -79,7 +79,7 @@ Vec_Ptr_t * Sim_UtilInfoAlloc( int nSize, int nWords, bool fClean ) ***********************************************************************/ void Sim_UtilInfoFree( Vec_Ptr_t * p ) { - free( p->pArray[0] ); + ABC_FREE( p->pArray[0] ); Vec_PtrFree( p ); } diff --git a/src/sat/bsat/satInter.c b/src/sat/bsat/satInter.c index fe2ed113..849ceb71 100644 --- a/src/sat/bsat/satInter.c +++ b/src/sat/bsat/satInter.c @@ -55,7 +55,7 @@ struct Int_Man_t_ Sto_Cls_t ** pWatches; // watched clauses for each literal (size 2*nVars) // interpolation data int nVarsAB; // the number of global variables - char * pVarTypes; // variable type (size nVars) [1=A, 0=B, <0=AB] + int * pVarTypes; // variable type (size nVars) [1=A, 0=B, <0=AB] unsigned * pInters; // storage for interpolants as truth tables (size nClauses) int nIntersAlloc; // the allocated size of truth table array int nWords; // the number of words in the truth table @@ -105,11 +105,11 @@ Int_Man_t * Int_ManAlloc() { Int_Man_t * p; // allocate the manager - p = (Int_Man_t *)malloc( sizeof(Int_Man_t) ); + p = (Int_Man_t *)ABC_ALLOC( char, sizeof(Int_Man_t) ); memset( p, 0, sizeof(Int_Man_t) ); // verification p->nResLitsAlloc = (1<<16); - p->pResLits = malloc( sizeof(lit) * p->nResLitsAlloc ); + p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc ); // parameters p->fProofWrite = 0; p->fProofVerif = 1; @@ -214,18 +214,18 @@ void Int_ManResize( Int_Man_t * p ) while ( p->nVarsAlloc < p->pCnf->nVars ) p->nVarsAlloc *= 2; // resize the arrays - p->pTrail = (lit *) realloc( p->pTrail, sizeof(lit) * p->nVarsAlloc ); - p->pAssigns = (lit *) realloc( p->pAssigns, sizeof(lit) * p->nVarsAlloc ); - p->pSeens = (char *) realloc( p->pSeens, sizeof(char) * p->nVarsAlloc ); - p->pVarTypes = (char *) realloc( p->pVarTypes, sizeof(char) * p->nVarsAlloc ); - p->pReasons = (Sto_Cls_t **)realloc( p->pReasons, sizeof(Sto_Cls_t *) * p->nVarsAlloc ); - p->pWatches = (Sto_Cls_t **)realloc( p->pWatches, sizeof(Sto_Cls_t *) * p->nVarsAlloc*2 ); + 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 + // clean the ABC_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(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 ); @@ -243,7 +243,7 @@ void Int_ManResize( Int_Man_t * p ) while ( p->nClosAlloc < p->pCnf->nClauses ) p->nClosAlloc *= 2; // resize the arrays - p->pProofNums = (int *) realloc( p->pProofNums, sizeof(int) * p->nClosAlloc ); + p->pProofNums = ABC_REALLOC(int, p->pProofNums, p->nClosAlloc ); } memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses ); @@ -251,7 +251,7 @@ void Int_ManResize( Int_Man_t * p ) if ( p->nIntersAlloc < p->nWords * p->pCnf->nClauses ) { p->nIntersAlloc = p->nWords * p->pCnf->nClauses; - p->pInters = (unsigned *) realloc( p->pInters, sizeof(unsigned) * p->nIntersAlloc ); + p->pInters = ABC_REALLOC(unsigned, p->pInters, p->nIntersAlloc ); } // memset( p->pInters, 0, sizeof(unsigned) * p->nWords * p->pCnf->nClauses ); } @@ -271,20 +271,20 @@ void Int_ManFree( Int_Man_t * p ) { /* printf( "Runtime stats:\n" ); -PRT( "BCP ", p->timeBcp ); -PRT( "Trace ", p->timeTrace ); -PRT( "TOTAL ", p->timeTotal ); +ABC_PRT( "BCP ", p->timeBcp ); +ABC_PRT( "Trace ", p->timeTrace ); +ABC_PRT( "TOTAL ", p->timeTotal ); */ - free( p->pInters ); - free( p->pProofNums ); - free( p->pTrail ); - free( p->pAssigns ); - free( p->pSeens ); - free( p->pVarTypes ); - free( p->pReasons ); - free( p->pWatches ); - free( p->pResLits ); - free( p ); + 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 ); } diff --git a/src/sat/bsat/satInterA.c b/src/sat/bsat/satInterA.c index 5edc5b67..5dcc7f0b 100644 --- a/src/sat/bsat/satInterA.c +++ b/src/sat/bsat/satInterA.c @@ -106,11 +106,11 @@ Inta_Man_t * Inta_ManAlloc() { Inta_Man_t * p; // allocate the manager - p = (Inta_Man_t *)malloc( sizeof(Inta_Man_t) ); + 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 = malloc( sizeof(lit) * p->nResLitsAlloc ); + p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc ); // parameters p->fProofWrite = 0; p->fProofVerif = 1; @@ -195,15 +195,15 @@ void Inta_ManResize( Inta_Man_t * p ) while ( p->nVarsAlloc < p->pCnf->nVars ) p->nVarsAlloc *= 2; // resize the arrays - p->pTrail = (lit *) realloc( p->pTrail, sizeof(lit) * p->nVarsAlloc ); - p->pAssigns = (lit *) realloc( p->pAssigns, sizeof(lit) * p->nVarsAlloc ); - p->pSeens = (char *) realloc( p->pSeens, sizeof(char) * p->nVarsAlloc ); - p->pVarTypes = (int *) realloc( p->pVarTypes, sizeof(int) * p->nVarsAlloc ); - p->pReasons = (Sto_Cls_t **)realloc( p->pReasons, sizeof(Sto_Cls_t *) * p->nVarsAlloc ); - p->pWatches = (Sto_Cls_t **)realloc( p->pWatches, sizeof(Sto_Cls_t *) * p->nVarsAlloc*2 ); + 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 + // clean the ABC_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 ); @@ -222,7 +222,7 @@ void Inta_ManResize( Inta_Man_t * p ) while ( p->nClosAlloc < p->pCnf->nClauses ) p->nClosAlloc *= 2; // resize the arrays - p->pProofNums = (int *) realloc( p->pProofNums, sizeof(int) * p->nClosAlloc ); + p->pProofNums = ABC_REALLOC( int, p->pProofNums, p->nClosAlloc ); } memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses ); @@ -230,7 +230,7 @@ void Inta_ManResize( Inta_Man_t * p ) if ( p->nIntersAlloc < p->pCnf->nClauses ) { p->nIntersAlloc = p->pCnf->nClauses; - p->pInters = (Aig_Obj_t **) realloc( p->pInters, sizeof(Aig_Obj_t *) * p->nIntersAlloc ); + p->pInters = ABC_REALLOC( Aig_Obj_t *, p->pInters, p->nIntersAlloc ); } memset( p->pInters, 0, sizeof(Aig_Obj_t *) * p->pCnf->nClauses ); } @@ -250,20 +250,20 @@ void Inta_ManFree( Inta_Man_t * p ) { /* printf( "Runtime stats:\n" ); -PRT( "BCP ", p->timeBcp ); -PRT( "Trace ", p->timeTrace ); -PRT( "TOTAL ", p->timeTotal ); +ABC_PRT( "BCP ", p->timeBcp ); +ABC_PRT( "Trace ", p->timeTrace ); +ABC_PRT( "TOTAL ", p->timeTotal ); */ - free( p->pInters ); - free( p->pProofNums ); - free( p->pTrail ); - free( p->pAssigns ); - free( p->pSeens ); - free( p->pVarTypes ); - free( p->pReasons ); - free( p->pWatches ); - free( p->pResLits ); - free( p ); + 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 ); } @@ -1004,7 +1004,7 @@ void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, in if ( fVerbose ) { -// PRT( "Interpo", clock() - clkTotal ); +// 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), diff --git a/src/sat/bsat/satInterB.c b/src/sat/bsat/satInterB.c index e0f4328d..cb7f7828 100644 --- a/src/sat/bsat/satInterB.c +++ b/src/sat/bsat/satInterB.c @@ -108,11 +108,11 @@ Intb_Man_t * Intb_ManAlloc() { Intb_Man_t * p; // allocate the manager - p = (Intb_Man_t *)malloc( sizeof(Intb_Man_t) ); + 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 = malloc( sizeof(lit) * p->nResLitsAlloc ); + p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc ); // parameters p->fProofWrite = 0; p->fProofVerif = 1; @@ -197,15 +197,15 @@ void Intb_ManResize( Intb_Man_t * p ) while ( p->nVarsAlloc < p->pCnf->nVars ) p->nVarsAlloc *= 2; // resize the arrays - p->pTrail = (lit *) realloc( p->pTrail, sizeof(lit) * p->nVarsAlloc ); - p->pAssigns = (lit *) realloc( p->pAssigns, sizeof(lit) * p->nVarsAlloc ); - p->pSeens = (char *) realloc( p->pSeens, sizeof(char) * p->nVarsAlloc ); - p->pVarTypes = (int *) realloc( p->pVarTypes, sizeof(int) * p->nVarsAlloc ); - p->pReasons = (Sto_Cls_t **)realloc( p->pReasons, sizeof(Sto_Cls_t *) * p->nVarsAlloc ); - p->pWatches = (Sto_Cls_t **)realloc( p->pWatches, sizeof(Sto_Cls_t *) * p->nVarsAlloc*2 ); + 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 + // clean the ABC_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 ); @@ -224,7 +224,7 @@ void Intb_ManResize( Intb_Man_t * p ) while ( p->nClosAlloc < p->pCnf->nClauses ) p->nClosAlloc *= 2; // resize the arrays - p->pProofNums = (int *) realloc( p->pProofNums, sizeof(int) * p->nClosAlloc ); + p->pProofNums = ABC_REALLOC( int, p->pProofNums, p->nClosAlloc ); } memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses ); @@ -232,7 +232,7 @@ void Intb_ManResize( Intb_Man_t * p ) if ( p->nIntersAlloc < p->pCnf->nClauses ) { p->nIntersAlloc = p->pCnf->nClauses; - p->pInters = (Aig_Obj_t **) realloc( p->pInters, sizeof(Aig_Obj_t *) * p->nIntersAlloc ); + p->pInters = ABC_REALLOC(Aig_Obj_t *, p->pInters, p->nIntersAlloc ); } memset( p->pInters, 0, sizeof(Aig_Obj_t *) * p->pCnf->nClauses ); } @@ -252,20 +252,20 @@ void Intb_ManFree( Intb_Man_t * p ) { /* printf( "Runtime stats:\n" ); -PRT( "BCP ", p->timeBcp ); -PRT( "Trace ", p->timeTrace ); -PRT( "TOTAL ", p->timeTotal ); +ABC_PRT( "BCP ", p->timeBcp ); +ABC_PRT( "Trace ", p->timeTrace ); +ABC_PRT( "TOTAL ", p->timeTotal ); */ - free( p->pInters ); - free( p->pProofNums ); - free( p->pTrail ); - free( p->pAssigns ); - free( p->pSeens ); - free( p->pVarTypes ); - free( p->pReasons ); - free( p->pWatches ); - free( p->pResLits ); - free( p ); + 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 ); } @@ -987,7 +987,7 @@ void * Intb_ManInterpolate( Intb_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, in if ( fVerbose ) { -// PRT( "Interpo", clock() - clkTotal ); +// 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), diff --git a/src/sat/bsat/satInterP.c b/src/sat/bsat/satInterP.c index c944c36d..57fb79d2 100644 --- a/src/sat/bsat/satInterP.c +++ b/src/sat/bsat/satInterP.c @@ -23,6 +23,7 @@ #include #include #include + #include "satStore.h" #include "vec.h" @@ -92,11 +93,11 @@ Intp_Man_t * Intp_ManAlloc() { Intp_Man_t * p; // allocate the manager - p = (Intp_Man_t *)malloc( sizeof(Intp_Man_t) ); + p = (Intp_Man_t *)ABC_ALLOC( char, sizeof(Intp_Man_t) ); memset( p, 0, sizeof(Intp_Man_t) ); // verification p->nResLitsAlloc = (1<<16); - p->pResLits = malloc( sizeof(lit) * p->nResLitsAlloc ); + p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc ); // proof recording p->vAnties = Vec_IntAlloc( 1000 ); p->vBreaks = Vec_IntAlloc( 1000 ); @@ -128,15 +129,15 @@ void Intp_ManResize( Intp_Man_t * p ) while ( p->nVarsAlloc < p->pCnf->nVars ) p->nVarsAlloc *= 2; // resize the arrays - p->pTrail = (lit *) realloc( p->pTrail, sizeof(lit) * p->nVarsAlloc ); - p->pAssigns = (lit *) realloc( p->pAssigns, sizeof(lit) * p->nVarsAlloc ); - p->pSeens = (char *) realloc( p->pSeens, sizeof(char) * p->nVarsAlloc ); -// p->pVarTypes = (int *) realloc( p->pVarTypes, sizeof(int) * p->nVarsAlloc ); - p->pReasons = (Sto_Cls_t **)realloc( p->pReasons, sizeof(Sto_Cls_t *) * p->nVarsAlloc ); - p->pWatches = (Sto_Cls_t **)realloc( p->pWatches, sizeof(Sto_Cls_t *) * p->nVarsAlloc*2 ); + 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 + // clean the ABC_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 ); @@ -152,7 +153,7 @@ void Intp_ManResize( Intp_Man_t * p ) while ( p->nClosAlloc < p->pCnf->nClauses ) p->nClosAlloc *= 2; // resize the arrays - p->pProofNums = (int *) realloc( p->pProofNums, sizeof(int) * p->nClosAlloc ); + p->pProofNums = ABC_REALLOC( int, p->pProofNums, p->nClosAlloc ); } memset( p->pProofNums, 0, sizeof(int) * p->pCnf->nClauses ); } @@ -172,22 +173,22 @@ void Intp_ManFree( Intp_Man_t * p ) { /* printf( "Runtime stats:\n" ); -PRT( "BCP ", p->timeBcp ); -PRT( "Trace ", p->timeTrace ); -PRT( "TOTAL ", p->timeTotal ); +ABC_PRT( "BCP ", p->timeBcp ); +ABC_PRT( "Trace ", p->timeTrace ); +ABC_PRT( "TOTAL ", p->timeTotal ); */ Vec_IntFree( p->vAnties ); Vec_IntFree( p->vBreaks ); -// free( p->pInters ); - free( p->pProofNums ); - free( p->pTrail ); - free( p->pAssigns ); - free( p->pSeens ); -// free( p->pVarTypes ); - free( p->pReasons ); - free( p->pWatches ); - free( p->pResLits ); - free( p ); +// 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 ); } @@ -864,7 +865,7 @@ void Intp_ManUnsatCoreVerify( Sto_Man_t * pCnf, Vec_Int_t * vCore ) } Vec_PtrFree( vClauses ); // solve the problem - RetValue = sat_solver_solve( pSat, NULL, NULL, (sint64)nConfMax, (sint64)0, (sint64)0, (sint64)0 ); + RetValue = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 ); sat_solver_delete( pSat ); if ( fVerbose ) { @@ -874,7 +875,7 @@ void Intp_ManUnsatCoreVerify( Sto_Man_t * pCnf, Vec_Int_t * vCore ) printf( "UNSAT core verification FAILED. " ); else printf( "UNSAT core verification succeeded. " ); - PRT( "Time", clock() - clk ); + ABC_PRT( "Time", clock() - clk ); } else { @@ -989,7 +990,7 @@ void * Intp_ManUnsatCore( Intp_Man_t * p, Sto_Man_t * pCnf, int fVerbose ) if ( fVerbose ) { - PRT( "Core", clock() - clkTotal ); + ABC_PRT( "Core", 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), diff --git a/src/sat/bsat/satMem.c b/src/sat/bsat/satMem.c index 1dacb854..f789f927 100644 --- a/src/sat/bsat/satMem.c +++ b/src/sat/bsat/satMem.c @@ -16,8 +16,13 @@ ***********************************************************************/ +#include +#include +#include +#include + +#include "abc_global.h" #include "satMem.h" -#include "vec.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -30,7 +35,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 free entries + char * pEntriesFree; // the linked list of ABC_FREE entries // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -47,8 +52,8 @@ struct Sat_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 + char * pCurrent; // the current pointer to ABC_FREE memory + char * pEnd; // the first entry outside the ABC_FREE memory // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -93,7 +98,7 @@ Sat_MmFixed_t * Sat_MmFixedStart( int nEntrySize ) { Sat_MmFixed_t * p; - p = ALLOC( Sat_MmFixed_t, 1 ); + p = ABC_ALLOC( Sat_MmFixed_t, 1 ); memset( p, 0, sizeof(Sat_MmFixed_t) ); p->nEntrySize = nEntrySize; @@ -110,7 +115,7 @@ Sat_MmFixed_t * Sat_MmFixedStart( int nEntrySize ) p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -141,9 +146,9 @@ void Sat_MmFixedStop( Sat_MmFixed_t * p, int fVerbose ) p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -162,16 +167,16 @@ char * Sat_MmFixedEntryFetch( Sat_MmFixed_t * p ) char * pTemp; int i; - // check if there are still free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize ); + 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; @@ -191,7 +196,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 free entry list + // return the first entry in the ABC_FREE entry list pTemp = p->pEntriesFree; p->pEntriesFree = *((char **)pTemp); return pTemp; @@ -212,7 +217,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 free entries + // add the entry to the linked list of ABC_FREE entries *((char **)pEntry) = p->pEntriesFree; p->pEntriesFree = pEntry; } @@ -235,7 +240,7 @@ void Sat_MmFixedRestart( Sat_MmFixed_t * p ) // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; // transform these entries into a linked list pTemp = p->pChunks[0]; @@ -246,7 +251,7 @@ void Sat_MmFixedRestart( Sat_MmFixed_t * p ) } // set the last link *((char **)pTemp) = NULL; - // set the free entry list + // set the ABC_FREE entry list p->pEntriesFree = p->pChunks[0]; // set the correct statistics p->nMemoryAlloc = p->nEntrySize * p->nChunkSize; @@ -288,7 +293,7 @@ Sat_MmFlex_t * Sat_MmFlexStart() { Sat_MmFlex_t * p; - p = ALLOC( Sat_MmFlex_t, 1 ); + p = ABC_ALLOC( Sat_MmFlex_t, 1 ); memset( p, 0, sizeof(Sat_MmFlex_t) ); p->nEntriesUsed = 0; @@ -298,7 +303,7 @@ Sat_MmFlex_t * Sat_MmFlexStart() p->nChunkSize = (1 << 16); p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -329,9 +334,9 @@ void Sat_MmFlexStop( Sat_MmFlex_t * p, int fVerbose ) p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -348,13 +353,13 @@ 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 free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } if ( nBytes > p->nChunkSize ) { @@ -362,7 +367,7 @@ char * Sat_MmFlexEntryFetch( Sat_MmFlex_t * p, int nBytes ) // (ideally, this should never happen) p->nChunkSize = 2 * nBytes; } - p->pCurrent = ALLOC( char, p->nChunkSize ); + p->pCurrent = ABC_ALLOC( char, p->nChunkSize ); p->pEnd = p->pCurrent + p->nChunkSize; p->nMemoryAlloc += p->nChunkSize; // add the chunk to the chunk storage @@ -412,7 +417,7 @@ int Sat_MmFlexReadMemUsage( Sat_MmFlex_t * p ) 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 free()ed.] + entries are handed over to malloc() and then ABC_FREE()ed.] SideEffects [] @@ -423,15 +428,15 @@ Sat_MmStep_t * Sat_MmStepStart( int nSteps ) { Sat_MmStep_t * p; int i, k; - p = ALLOC( Sat_MmStep_t, 1 ); + p = ABC_ALLOC( Sat_MmStep_t, 1 ); p->nMems = nSteps; // start the fixed memory managers - p->pMems = ALLOC( Sat_MmFixed_t *, p->nMems ); + p->pMems = ABC_ALLOC( Sat_MmFixed_t *, p->nMems ); for ( i = 0; i < p->nMems; i++ ) p->pMems[i] = Sat_MmFixedStart( (8<nMapSize = (4<nMems); - p->pMap = ALLOC( Sat_MmFixed_t *, p->nMapSize+1 ); + p->pMap = ABC_ALLOC( Sat_MmFixed_t *, p->nMapSize+1 ); p->pMap[0] = NULL; for ( k = 1; k <= 4; k++ ) p->pMap[k] = p->pMems[0]; @@ -442,7 +447,7 @@ Sat_MmStep_t * Sat_MmStepStart( int nSteps ) //printf( "%10d: size = %10d\n", i, p->pMap[i]->nEntrySize ); p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); return p; } @@ -463,14 +468,14 @@ void Sat_MmStepStop( Sat_MmStep_t * p, int fVerbose ) if ( p->nChunksAlloc ) { for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); } for ( i = 0; i < p->nMems; i++ ) Sat_MmFixedStop( p->pMems[i], fVerbose ); - free( p->pMems ); - free( p->pMap ); - free( p ); + ABC_FREE( p->pMems ); + ABC_FREE( p->pMap ); + ABC_FREE( p ); } /**Function************************************************************* @@ -493,9 +498,9 @@ char * Sat_MmStepEntryFetch( Sat_MmStep_t * p, int nBytes ) if ( p->nChunks == p->nChunksAlloc ) { p->nChunksAlloc *= 2; - p->pChunks = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pChunks[ p->nChunks++ ] = ALLOC( char, nBytes ); + p->pChunks[ p->nChunks++ ] = ABC_ALLOC( char, nBytes ); return p->pChunks[p->nChunks-1]; } return Sat_MmFixedEntryFetch( p->pMap[nBytes] ); @@ -519,7 +524,7 @@ void Sat_MmStepEntryRecycle( Sat_MmStep_t * p, char * pEntry, int nBytes ) return; if ( nBytes > p->nMapSize ) { -// free( pEntry ); +// ABC_FREE( pEntry ); return; } Sat_MmFixedEntryRecycle( p->pMap[nBytes], pEntry ); diff --git a/src/sat/bsat/satMem.h b/src/sat/bsat/satMem.h index f60d7fdd..b6d93807 100644 --- a/src/sat/bsat/satMem.h +++ b/src/sat/bsat/satMem.h @@ -23,11 +23,6 @@ /// INCLUDES /// //////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include - //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/sat/bsat/satSolver.c b/src/sat/bsat/satSolver.c index 833ea394..d2ebf552 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, free of charge, to any person obtaining a copy of this software and +Permission is hereby granted, ABC_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,6 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA #include #include "satSolver.h" -#include "port_type.h" //#define SAT_USE_SYSTEM_MEMORY_MANAGEMENT @@ -91,9 +90,9 @@ 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*)((PORT_PTRUINT_T)l + (PORT_PTRUINT_T)l + 1); } -static inline bool clause_is_lit (clause* c) { return ((PORT_PTRUINT_T)c & 1); } -static inline lit clause_read_lit (clause* c) { return (lit)((PORT_PTRUINT_T)c >> 1); } +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 lit clause_read_lit (clause* c) { return (lit)((ABC_PTRUINT_T)c >> 1); } //================================================================================================= // Simple helpers: @@ -288,15 +287,15 @@ static clause* clause_new(sat_solver* s, lit* begin, lit* end, int learnt) assert(end - begin > 1); assert(learnt >= 0 && learnt < 2); size = end - begin; -// c = (clause*)malloc(sizeof(clause) + sizeof(lit) * size + learnt * sizeof(float)); +// c = (clause*)ABC_ALLOC( char, sizeof(clause) + sizeof(lit) * size + learnt * sizeof(float)); #ifdef SAT_USE_SYSTEM_MEMORY_MANAGEMENT - c = (clause*)malloc(sizeof(clause) + sizeof(lit) * size + learnt * sizeof(float)); + c = (clause*)ABC_ALLOC( char, sizeof(clause) + sizeof(lit) * size + learnt * sizeof(float)); #else c = (clause*)Sat_MmStepEntryFetch( s->pMem, sizeof(clause) + sizeof(lit) * size + learnt * sizeof(float) ); #endif c->size_learnt = (size << 1) | learnt; - assert(((PORT_PTRUINT_T)c & 1) == 0); + assert(((ABC_PTRUINT_T)c & 1) == 0); for (i = 0; i < size; i++) c->lits[i] = begin[i]; @@ -344,7 +343,7 @@ static void clause_remove(sat_solver* s, clause* c) } #ifdef SAT_USE_SYSTEM_MEMORY_MANAGEMENT - free(c); + ABC_FREE(c); #else Sat_MmStepEntryRecycle( s->pMem, (char *)c, sizeof(clause) + sizeof(lit) * clause_size(c) + clause_learnt(c) * sizeof(float) ); #endif @@ -378,15 +377,15 @@ void sat_solver_setnvars(sat_solver* s,int n) while (s->cap < n) s->cap = s->cap*2+1; - s->wlists = (vecp*) realloc(s->wlists, sizeof(vecp)*s->cap*2); - s->activity = (double*) realloc(s->activity, sizeof(double)*s->cap); - s->factors = (double*) realloc(s->factors, sizeof(double)*s->cap); - s->assigns = (lbool*) realloc(s->assigns, sizeof(lbool)*s->cap); - s->orderpos = (int*) realloc(s->orderpos, sizeof(int)*s->cap); - s->reasons = (clause**)realloc(s->reasons, sizeof(clause*)*s->cap); - s->levels = (int*) realloc(s->levels, sizeof(int)*s->cap); - s->tags = (lbool*) realloc(s->tags, sizeof(lbool)*s->cap); - s->trail = (lit*) realloc(s->trail, sizeof(lit)*s->cap); + s->wlists = ABC_REALLOC(vecp, s->wlists, s->cap*2); + s->activity = ABC_REALLOC(double, s->activity, s->cap); + s->factors = ABC_REALLOC(double, s->factors, s->cap); + s->assigns = ABC_REALLOC(lbool, s->assigns, s->cap); + s->orderpos = ABC_REALLOC(int, s->orderpos, s->cap); + s->reasons = ABC_REALLOC(clause*,s->reasons, s->cap); + 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); } for (var = s->size; var < n; var++){ @@ -830,14 +829,14 @@ void sat_solver_reducedb(sat_solver* s) vecp_resize(&s->learnts,j); } -static lbool sat_solver_search(sat_solver* s, sint64 nof_conflicts, sint64 nof_learnts) +static lbool sat_solver_search(sat_solver* s, ABC_INT64_T nof_conflicts, ABC_INT64_T nof_learnts) { int* levels = s->levels; double var_decay = 0.95; double clause_decay = 0.999; double random_var_freq = 0.02; - sint64 conflictC = 0; + ABC_INT64_T conflictC = 0; veci learnt_clause; int i; @@ -950,7 +949,7 @@ static lbool sat_solver_search(sat_solver* s, sint64 nof_conflicts, sint64 nof_l sat_solver* sat_solver_new(void) { - sat_solver* s = (sat_solver*)malloc(sizeof(sat_solver)); + sat_solver* s = (sat_solver*)ABC_ALLOC( char, sizeof(sat_solver)); memset( s, 0, sizeof(sat_solver) ); // initialize vectors @@ -990,7 +989,7 @@ sat_solver* sat_solver_new(void) s->simpdb_props = 0; s->random_seed = 91648253; s->progress_estimate = 0; - s->binary = (clause*)malloc(sizeof(clause) + sizeof(lit)*2); + s->binary = (clause*)ABC_ALLOC( char, sizeof(clause) + sizeof(lit)*2); s->binary->size_learnt = (2 << 1); s->verbosity = 0; @@ -1021,9 +1020,9 @@ void sat_solver_delete(sat_solver* s) #ifdef SAT_USE_SYSTEM_MEMORY_MANAGEMENT int i; for (i = 0; i < vecp_size(&s->clauses); i++) - free(vecp_begin(&s->clauses)[i]); + ABC_FREE(vecp_begin(&s->clauses)[i]); for (i = 0; i < vecp_size(&s->learnts); i++) - free(vecp_begin(&s->learnts)[i]); + ABC_FREE(vecp_begin(&s->learnts)[i]); #else Sat_MmStepStop( s->pMem, 0 ); #endif @@ -1038,7 +1037,7 @@ void sat_solver_delete(sat_solver* s) veci_delete(&s->model); veci_delete(&s->act_vars); veci_delete(&s->temp_clause); - free(s->binary); + ABC_FREE(s->binary); // delete arrays if (s->wlists != 0){ @@ -1047,19 +1046,19 @@ void sat_solver_delete(sat_solver* s) vecp_delete(&s->wlists[i]); // if one is different from null, all are - free(s->wlists ); - free(s->activity ); - free(s->factors ); - free(s->assigns ); - free(s->orderpos ); - free(s->reasons ); - free(s->levels ); - free(s->trail ); - free(s->tags ); + ABC_FREE(s->wlists ); + ABC_FREE(s->activity ); + ABC_FREE(s->factors ); + ABC_FREE(s->assigns ); + ABC_FREE(s->orderpos ); + ABC_FREE(s->reasons ); + ABC_FREE(s->levels ); + ABC_FREE(s->trail ); + ABC_FREE(s->tags ); } sat_solver_store_free(s); - free(s); + ABC_FREE(s); } @@ -1172,10 +1171,10 @@ bool sat_solver_simplify(sat_solver* s) } -int sat_solver_solve(sat_solver* s, lit* begin, lit* end, sint64 nConfLimit, sint64 nInsLimit, sint64 nConfLimitGlobal, sint64 nInsLimitGlobal) +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) { - sint64 nof_conflicts = 100; - sint64 nof_learnts = sat_solver_nclauses(s) / 3; + ABC_INT64_T nof_conflicts = 100; + ABC_INT64_T nof_learnts = sat_solver_nclauses(s) / 3; lbool status = l_Undef; lbool* values = s->assigns; lit* i; @@ -1398,6 +1397,9 @@ static void sortrnd(void** array, int size, int(*comp)(const void *, const void void sat_solver_sort(void** array, int size, int(*comp)(const void *, const void *)) { +// int i; double seed = 91648253; sortrnd(array,size,comp,&seed); +// for ( i = 1; i < size; i++ ) +// assert(comp(array[i-1], array[i])<0); } diff --git a/src/sat/bsat/satSolver.h b/src/sat/bsat/satSolver.h index 7bb4bd6c..f37c1738 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, free of charge, to any person obtaining a copy of this software and +Permission is hereby granted, ABC_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,10 +22,12 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA #ifndef satSolver_h #define satSolver_h -#ifdef _WIN32 -#define inline __inline // compatible with MS VS 6.0 -#endif +#include +#include +#include +#include +#include "abc_global.h" #include "satVec.h" #include "satMem.h" @@ -46,17 +48,6 @@ static const bool false = 0; typedef int lit; typedef char lbool; -#ifndef SINT64 -#define SINT64 - -#ifdef _WIN32 -typedef signed __int64 sint64; // compatible with MS VS 6.0 -#else -typedef long long sint64; -#endif - -#endif - static const int var_Undef = -1; static const lit lit_Undef = -2; @@ -85,7 +76,7 @@ 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_solve(sat_solver* s, lit* begin, lit* end, sint64 nConfLimit, sint64 nInsLimit, sint64 nConfLimitGlobal, sint64 nInsLimitGlobal); +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); extern int sat_solver_nclauses(sat_solver* s); @@ -95,8 +86,8 @@ extern void sat_solver_setnvars(sat_solver* s,int n); struct stats_t { - sint64 starts, decisions, propagations, inspects, conflicts; - sint64 clauses, clauses_literals, learnts, learnts_literals, max_literals, tot_literals; + 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; @@ -167,8 +158,8 @@ struct sat_solver_t stats stats; - sint64 nConfLimit; // external limit on the number of conflicts - sint64 nInsLimit; // external limit on the number of implications + ABC_INT64_T nConfLimit; // external limit on the number of conflicts + ABC_INT64_T nInsLimit; // external limit on the number of implications veci act_vars; // variables whose activity has changed double* factors; // the activity factors diff --git a/src/sat/bsat/satStore.c b/src/sat/bsat/satStore.c index 31fe92ca..fff8a836 100644 --- a/src/sat/bsat/satStore.c +++ b/src/sat/bsat/satStore.c @@ -23,6 +23,7 @@ #include #include #include + #include "satStore.h" //////////////////////////////////////////////////////////////////////// @@ -49,7 +50,7 @@ char * Sto_ManMemoryFetch( Sto_Man_t * p, int nBytes ) char * pMem; if ( p->pChunkLast == NULL || nBytes > p->nChunkSize - p->nChunkUsed ) { - pMem = (char *)malloc( p->nChunkSize ); + pMem = (char *)ABC_ALLOC( char, p->nChunkSize ); *(char **)pMem = p->pChunkLast; p->pChunkLast = pMem; p->nChunkUsed = sizeof(char *); @@ -76,8 +77,8 @@ void Sto_ManMemoryStop( Sto_Man_t * p ) if ( p->pChunkLast == NULL ) return; for ( pMem = p->pChunkLast; (pNext = *(char **)pMem); pMem = pNext ) - free( pMem ); - free( pMem ); + ABC_FREE( pMem ); + ABC_FREE( pMem ); } /**Function************************************************************* @@ -119,7 +120,7 @@ Sto_Man_t * Sto_ManAlloc() { Sto_Man_t * p; // allocate the manager - p = (Sto_Man_t *)malloc( sizeof(Sto_Man_t) ); + p = (Sto_Man_t *)ABC_ALLOC( char, sizeof(Sto_Man_t) ); memset( p, 0, sizeof(Sto_Man_t) ); // memory management p->nChunkSize = (1<<16); // use 64K chunks @@ -140,7 +141,7 @@ Sto_Man_t * Sto_ManAlloc() void Sto_ManFree( Sto_Man_t * p ) { Sto_ManMemoryStop( p ); - free( p ); + ABC_FREE( p ); } /**Function************************************************************* @@ -398,7 +399,7 @@ Sto_Man_t * Sto_ManLoadClauses( char * pFileName ) // alloc the array of literals nLitsAlloc = 1024; - pLits = (lit *)malloc( sizeof(lit) * nLitsAlloc ); + pLits = (lit *)ABC_ALLOC( char, sizeof(lit) * nLitsAlloc ); // read file header p->nVars = p->nClauses = p->nRoots = p->nClausesA = 0; @@ -429,7 +430,7 @@ Sto_Man_t * Sto_ManLoadClauses( char * pFileName ) if ( nLits == nLitsAlloc ) { nLitsAlloc *= 2; - pLits = (lit *)realloc( pLits, sizeof(lit) * nLitsAlloc ); + pLits = ABC_REALLOC( lit, pLits, nLitsAlloc ); } pLits[ nLits++ ] = lit_read(Number); } @@ -449,7 +450,7 @@ Sto_Man_t * Sto_ManLoadClauses( char * pFileName ) return NULL; } - free( pLits ); + ABC_FREE( pLits ); fclose( pFile ); return p; } diff --git a/src/sat/bsat/satStore.h b/src/sat/bsat/satStore.h index f63703d3..ea11f46a 100644 --- a/src/sat/bsat/satStore.h +++ b/src/sat/bsat/satStore.h @@ -21,8 +21,6 @@ #ifndef __SAT_STORE_H__ #define __SAT_STORE_H__ -#include "satSolver.h" - /* The trace of SAT solving contains the original clauses of the problem along with the learned clauses derived during SAT solving. @@ -30,6 +28,16 @@ c */ +//////////////////////////////////////////////////////////////////////// +/// INCLUDES /// +//////////////////////////////////////////////////////////////////////// + +#include "satSolver.h" + +//////////////////////////////////////////////////////////////////////// +/// PARAMETERS /// +//////////////////////////////////////////////////////////////////////// + #ifdef __cplusplus extern "C" { #endif @@ -38,20 +46,8 @@ extern "C" { #define inline __inline // compatible with MS VS 6.0 #endif -#ifndef PRT -#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)) -#endif - #define STO_MAX(a,b) ((a) > (b) ? (a) : (b)) -//////////////////////////////////////////////////////////////////////// -/// INCLUDES /// -//////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////// -/// PARAMETERS /// -//////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// diff --git a/src/sat/bsat/satTrace.c b/src/sat/bsat/satTrace.c index 111e8dfb..08cfadf6 100644 --- a/src/sat/bsat/satTrace.c +++ b/src/sat/bsat/satTrace.c @@ -18,8 +18,6 @@ ***********************************************************************/ -#include -#include #include "satSolver.h" /* diff --git a/src/sat/bsat/satUtil.c b/src/sat/bsat/satUtil.c index ff8f9fd6..5f8008bb 100644 --- a/src/sat/bsat/satUtil.c +++ b/src/sat/bsat/satUtil.c @@ -21,7 +21,6 @@ #include #include #include "satSolver.h" -#include "vec.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -170,7 +169,7 @@ int * Sat_SolverGetModel( sat_solver * p, int * pVars, int nVars ) { int * pModel; int i; - pModel = ALLOC( int, nVars+1 ); + pModel = ABC_ALLOC( int, nVars+1 ); for ( i = 0; i < nVars; i++ ) { assert( pVars[i] >= 0 && pVars[i] < p->size ); diff --git a/src/sat/bsat/satVec.h b/src/sat/bsat/satVec.h index d7fce5c0..f017c90b 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, free of charge, to any person obtaining a copy of this software and +Permission is hereby granted, ABC_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,8 +22,6 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA #ifndef satVec_h #define satVec_h -#include - // vector of 32-bit intergers (added for 64-bit portability) struct veci_t { int size; @@ -35,10 +33,10 @@ typedef struct veci_t veci; static inline void veci_new (veci* v) { v->size = 0; v->cap = 4; - v->ptr = (int*)malloc(sizeof(int)*v->cap); + v->ptr = (int*)ABC_ALLOC( char, sizeof(int)*v->cap); } -static inline void veci_delete (veci* v) { free(v->ptr); } +static inline void veci_delete (veci* v) { ABC_FREE(v->ptr); } static inline int* veci_begin (veci* v) { return v->ptr; } static inline int veci_size (veci* v) { return v->size; } static inline void veci_resize (veci* v, int k) { v->size = k; } // only safe to shrink !! @@ -46,7 +44,7 @@ static inline void veci_push (veci* v, int e) { if (v->size == v->cap) { int newsize = v->cap * 2;//+1; - v->ptr = (int*)realloc(v->ptr,sizeof(int)*newsize); + v->ptr = ABC_REALLOC( int, v->ptr, newsize ); v->cap = newsize; } v->ptr[v->size++] = e; } @@ -63,10 +61,10 @@ typedef struct vecp_t vecp; static inline void vecp_new (vecp* v) { v->size = 0; v->cap = 4; - v->ptr = (void**)malloc(sizeof(void*)*v->cap); + v->ptr = (void**)ABC_ALLOC( char, sizeof(void*)*v->cap); } -static inline void vecp_delete (vecp* v) { free(v->ptr); } +static inline void vecp_delete (vecp* v) { ABC_FREE(v->ptr); } static inline void** vecp_begin (vecp* v) { return v->ptr; } static inline int vecp_size (vecp* v) { return v->size; } static inline void vecp_resize (vecp* v, int k) { v->size = k; } // only safe to shrink !! @@ -74,7 +72,7 @@ static inline void vecp_push (vecp* v, void* e) { if (v->size == v->cap) { int newsize = v->cap * 2;//+1; - v->ptr = (void**)realloc(v->ptr,sizeof(void*)*newsize); + v->ptr = ABC_REALLOC( void*, v->ptr, newsize ); v->cap = newsize; } v->ptr[v->size++] = e; } diff --git a/src/sat/csat/csat_apis.c b/src/sat/csat/csat_apis.c index e755d8d4..79c0655b 100644 --- a/src/sat/csat/csat_apis.c +++ b/src/sat/csat/csat_apis.c @@ -77,7 +77,7 @@ ABC_Manager ABC_InitManager() { ABC_Manager_t * mng; Abc_Start(); - mng = ALLOC( ABC_Manager_t, 1 ); + mng = ABC_ALLOC( ABC_Manager_t, 1 ); memset( mng, 0, sizeof(ABC_Manager_t) ); mng->pNtk = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 ); mng->pNtk->pName = Extra_UtilStrsav("csat_network"); @@ -116,8 +116,8 @@ void ABC_ReleaseManager( ABC_Manager mng ) if ( mng->pTarget ) Abc_NtkDelete( mng->pTarget ); if ( mng->vNodes ) Vec_PtrFree( mng->vNodes ); if ( mng->vValues ) Vec_IntFree( mng->vValues ); - FREE( mng->pDumpFileName ); - free( mng ); + ABC_FREE( mng->pDumpFileName ); + ABC_FREE( mng ); Abc_Stop(); } @@ -442,7 +442,7 @@ void ABC_SetSolveImplicationLimit( ABC_Manager mng, int num ) SeeAlso [] ***********************************************************************/ -void ABC_SetTotalBacktrackLimit( ABC_Manager mng, uint64 num ) +void ABC_SetTotalBacktrackLimit( ABC_Manager mng, ABC_UINT64_T num ) { mng->Params.nTotalBacktrackLimit = num; } @@ -458,7 +458,7 @@ void ABC_SetTotalBacktrackLimit( ABC_Manager mng, uint64 num ) SeeAlso [] ***********************************************************************/ -void ABC_SetTotalInspectLimit( ABC_Manager mng, uint64 num ) +void ABC_SetTotalInspectLimit( ABC_Manager mng, ABC_UINT64_T num ) { mng->Params.nTotalInspectLimit = num; } @@ -473,7 +473,7 @@ void ABC_SetTotalInspectLimit( ABC_Manager mng, uint64 num ) SeeAlso [] ***********************************************************************/ -uint64 ABC_GetTotalBacktracksMade( ABC_Manager mng ) +ABC_UINT64_T ABC_GetTotalBacktracksMade( ABC_Manager mng ) { return mng->Params.nTotalBacktracksMade; } @@ -489,7 +489,7 @@ uint64 ABC_GetTotalBacktracksMade( ABC_Manager mng ) SeeAlso [] ***********************************************************************/ -uint64 ABC_GetTotalInspectsMade( ABC_Manager mng ) +ABC_UINT64_T ABC_GetTotalInspectsMade( ABC_Manager mng ) { return mng->Params.nTotalInspectsMade; } @@ -507,7 +507,7 @@ uint64 ABC_GetTotalInspectsMade( ABC_Manager mng ) ***********************************************************************/ void ABC_EnableDump( ABC_Manager mng, char * dump_file ) { - FREE( mng->pDumpFileName ); + ABC_FREE( mng->pDumpFileName ); mng->pDumpFileName = Extra_UtilStrsav( dump_file ); } @@ -569,7 +569,7 @@ void ABC_SolveInit( ABC_Manager mng ) if ( mng->nog == 0 ) { printf( "ABC_SolveInit: Target is not specified by ABC_AddTarget().\n" ); return; } - // free the previous target network if present + // ABC_FREE the previous target network if present if ( mng->pTarget ) Abc_NtkDelete( mng->pTarget ); // set the new target network @@ -614,7 +614,7 @@ enum CSAT_StatusT ABC_Solve( ABC_Manager mng ) // try to prove the miter using a number of techniques if ( mng->mode ) - RetValue = Abc_NtkMiterSat( mng->pTarget, (sint64)pParams->nMiteringLimitLast, (sint64)0, 0, NULL, NULL ); + RetValue = Abc_NtkMiterSat( mng->pTarget, (ABC_INT64_T)pParams->nMiteringLimitLast, (ABC_INT64_T)0, 0, NULL, NULL ); else // RetValue = Abc_NtkMiterProve( &mng->pTarget, pParams ); // old CEC engine RetValue = Abc_NtkIvyProve( &mng->pTarget, pParams ); // new CEC engine @@ -634,7 +634,7 @@ enum CSAT_StatusT ABC_Solve( ABC_Manager mng ) mng->pResult->names[i] = Extra_UtilStrsav( ABC_GetNodeName(mng, Abc_NtkCi(mng->pNtk, i)) ); mng->pResult->values[i] = mng->pTarget->pModel[i]; } - FREE( mng->pTarget->pModel ); + ABC_FREE( mng->pTarget->pModel ); } else assert( 0 ); @@ -704,11 +704,11 @@ void ABC_Dump_Bench_File( ABC_Manager mng ) CSAT_Target_ResultT * ABC_TargetResAlloc( int nVars ) { CSAT_Target_ResultT * p; - p = ALLOC( CSAT_Target_ResultT, 1 ); + p = ABC_ALLOC( CSAT_Target_ResultT, 1 ); memset( p, 0, sizeof(CSAT_Target_ResultT) ); p->no_sig = nVars; - p->names = ALLOC( char *, nVars ); - p->values = ALLOC( int, nVars ); + p->names = ABC_ALLOC( char *, nVars ); + p->values = ABC_ALLOC( int, nVars ); memset( p->names, 0, sizeof(char *) * nVars ); memset( p->values, 0, sizeof(int) * nVars ); return p; @@ -734,12 +734,12 @@ void ABC_TargetResFree( CSAT_Target_ResultT * p ) int i = 0; for ( i = 0; i < p->no_sig; i++ ) { - FREE(p->names[i]); + ABC_FREE(p->names[i]); } } - FREE( p->names ); - FREE( p->values ); - free( p ); + ABC_FREE( p->names ); + ABC_FREE( p->values ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/sat/csat/csat_apis.h b/src/sat/csat/csat_apis.h index b80eddbf..337056a3 100644 --- a/src/sat/csat/csat_apis.h +++ b/src/sat/csat/csat_apis.h @@ -19,10 +19,6 @@ #ifndef __ABC_APIS_H__ #define __ABC_APIS_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -31,6 +27,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -182,10 +182,10 @@ extern void ABC_SetSolveBacktrackLimit(ABC_Manager mng, int num extern void ABC_SetLearnBacktrackLimit(ABC_Manager mng, int num); extern void ABC_EnableDump(ABC_Manager mng, char* dump_file); -extern void ABC_SetTotalBacktrackLimit( ABC_Manager mng, uint64 num ); -extern void ABC_SetTotalInspectLimit( ABC_Manager mng, uint64 num ); -extern uint64 ABC_GetTotalBacktracksMade( ABC_Manager mng ); -extern uint64 ABC_GetTotalInspectsMade( ABC_Manager mng ); +extern void ABC_SetTotalBacktrackLimit( ABC_Manager mng, ABC_UINT64_T num ); +extern void ABC_SetTotalInspectLimit( ABC_Manager mng, ABC_UINT64_T num ); +extern ABC_UINT64_T ABC_GetTotalBacktracksMade( ABC_Manager mng ); +extern ABC_UINT64_T ABC_GetTotalInspectsMade( ABC_Manager mng ); // the meaning of the parameters are: // nog: number of gates that are in the targets diff --git a/src/sat/fraig/fraig.h b/src/sat/fraig/fraig.h index c08e7e3a..ce686cef 100644 --- a/src/sat/fraig/fraig.h +++ b/src/sat/fraig/fraig.h @@ -19,29 +19,18 @@ #ifndef __FRAIG_H__ #define __FRAIG_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// -#ifndef SINT64 -#define SINT64 - -#ifdef _WIN32 -typedef signed __int64 sint64; // compatible with MS VS 6.0 -#else -typedef long long sint64; -#endif - -#endif - //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -70,7 +59,7 @@ struct Fraig_ParamsStruct_t_ int fVerboseP; // the verbosiness flag (for proof reporting) int fInternal; // is set to 1 for internal fraig calls int nConfLimit; // the limit on the number of conflicts - sint64 nInspLimit; // the limit on the number of inspections + ABC_INT64_T nInspLimit; // the limit on the number of inspections }; struct Prove_ParamsStruct_t_ @@ -97,11 +86,11 @@ struct Prove_ParamsStruct_t_ // last-gasp mitering int nMiteringLimitLast; // final mitering limit // global SAT solver limits - sint64 nTotalBacktrackLimit; // global limit on the number of backtracks - sint64 nTotalInspectLimit; // global limit on the number of clause inspects + ABC_INT64_T nTotalBacktrackLimit; // global limit on the number of backtracks + ABC_INT64_T nTotalInspectLimit; // global limit on the number of clause inspects // global resources applied - sint64 nTotalBacktracksMade; // the total number of backtracks made - sint64 nTotalInspectsMade; // the total number of inspects made + ABC_INT64_T nTotalBacktracksMade; // the total number of backtracks made + ABC_INT64_T nTotalInspectsMade; // the total number of inspects made }; //////////////////////////////////////////////////////////////////////// @@ -113,10 +102,10 @@ struct Prove_ParamsStruct_t_ //////////////////////////////////////////////////////////////////////// // macros working with complemented attributes of the nodes -#define Fraig_IsComplement(p) (((int)((PORT_PTRUINT_T) (p) & 01))) -#define Fraig_Regular(p) ((Fraig_Node_t *)((PORT_PTRUINT_T)(p) & ~01)) -#define Fraig_Not(p) ((Fraig_Node_t *)((PORT_PTRUINT_T)(p) ^ 01)) -#define Fraig_NotCond(p,c) ((Fraig_Node_t *)((PORT_PTRUINT_T)(p) ^ (c))) +#define Fraig_IsComplement(p) (((int)((ABC_PTRUINT_T) (p) & 01))) +#define Fraig_Regular(p) ((Fraig_Node_t *)((ABC_PTRUINT_T)(p) & ~01)) +#define Fraig_Not(p) ((Fraig_Node_t *)((ABC_PTRUINT_T)(p) ^ 01)) +#define Fraig_NotCond(p,c) ((Fraig_Node_t *)((ABC_PTRUINT_T)(p) ^ (c))) // these are currently not used #define Fraig_Ref(p) diff --git a/src/sat/fraig/fraigFeed.c b/src/sat/fraig/fraigFeed.c index e1e8d12c..7d99d146 100644 --- a/src/sat/fraig/fraigFeed.c +++ b/src/sat/fraig/fraigFeed.c @@ -391,7 +391,7 @@ void Fraig_FeedBackCovering( Fraig_Man_t * p, Msat_IntVec_t * vPats ) vColumns = Fraig_FeedBackCoveringStart( p ); // collect the number of 1s in each simulation vector nOnesTotal = 0; - pHits = ALLOC( int, vColumns->nSize ); + pHits = ABC_ALLOC( int, vColumns->nSize ); for ( i = 0; i < vColumns->nSize; i++ ) { pSims = (unsigned *)vColumns->pArray[i]; @@ -412,7 +412,7 @@ void Fraig_FeedBackCovering( Fraig_Man_t * p, Msat_IntVec_t * vPats ) Msat_IntVecPush( vPats, iPat ); } - // free the set of columns + // ABC_FREE the set of columns for ( i = 0; i < vColumns->nSize; i++ ) Fraig_MemFixedEntryRecycle( p->mmSims, (char *)vColumns->pArray[i] ); @@ -427,7 +427,7 @@ void Fraig_FeedBackCovering( Fraig_Man_t * p, Msat_IntVec_t * vPats ) printf( "\n" ); } Fraig_NodeVecFree( vColumns ); - free( pHits ); + ABC_FREE( pHits ); } @@ -736,7 +736,7 @@ void Fraig_ReallocateSimulationInfo( Fraig_Man_t * p ) // signatures remain without changes } - // replace the manager to free up some memory + // replace the manager to ABC_FREE up some memory Fraig_MemFixedStop( p->mmSims, 0 ); p->mmSims = mmSimsNew; @@ -783,7 +783,7 @@ void Fraig_ReallocateSimulationInfo( Fraig_Man_t * p ) int * Fraig_ManAllocCounterExample( Fraig_Man_t * p ) { int * pModel; - pModel = ALLOC( int, p->vInputs->nSize ); + pModel = ABC_ALLOC( int, p->vInputs->nSize ); memset( pModel, 0, sizeof(int) * p->vInputs->nSize ); return pModel; } @@ -896,7 +896,7 @@ printf( "\n" ); assert( Fraig_ManSimulateBitNode( p, pNode, pModel ) ); return pModel; } - FREE( pModel ); + ABC_FREE( pModel ); return NULL; } diff --git a/src/sat/fraig/fraigInt.h b/src/sat/fraig/fraigInt.h index 0e8b1e31..3bea5e42 100644 --- a/src/sat/fraig/fraigInt.h +++ b/src/sat/fraig/fraigInt.h @@ -29,9 +29,9 @@ #include #include +#include "abc_global.h" #include "fraig.h" #include "msat.h" -#include "port_type.h" //////////////////////////////////////////////////////////////////////// /// PARAMETERS /// @@ -57,9 +57,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 free storage in the dynamic simulation +// it will be extended when the ABC_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 free storage for dynamic simulation info +// this is done because if the ABC_FREE storage for dynamic simulation info // is not sufficient, computation becomes inefficient #define FRAIG_WORDS_STORE 5 @@ -86,35 +86,14 @@ #define Fraig_NodeSetVarStr(p,i) Fraig_BitStringSetBit(Fraig_Regular(p)->pSuppStr,i) #define Fraig_NodeHasVarStr(p,i) Fraig_BitStringHasBit(Fraig_Regular(p)->pSuppStr,i) -// copied from "util.h" for standaloneness -#ifndef ALLOC -# define ALLOC(type, num) \ - ((type *) malloc(sizeof(type) * (num))) -#endif - -#ifndef REALLOC -# define REALLOC(type, obj, num) \ - (obj) ? ((type *) realloc((char *) obj, sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num))) -#endif - -#ifndef FREE -# define FREE(obj) \ - ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) -#endif - // copied from "extra.h" for stand-aloneness #define Fraig_PrintTime(a,t) printf( "%s = ", (a) ); printf( "%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC) ) -#define Fraig_HashKey2(a,b,TSIZE) (((PORT_PTRUINT_T)(a) + (PORT_PTRUINT_T)(b) * 12582917) % TSIZE) +#define Fraig_HashKey2(a,b,TSIZE) (((ABC_PTRUINT_T)(a) + (ABC_PTRUINT_T)(b) * 12582917) % TSIZE) //#define Fraig_HashKey2(a,b,TSIZE) (( ((unsigned)(a)->Num * 19) ^ ((unsigned)(b)->Num * 1999) ) % TSIZE) //#define Fraig_HashKey2(a,b,TSIZE) ( ((unsigned)((a)->Num + (b)->Num) * ((a)->Num + (b)->Num + 1) / 2) % TSIZE) // the other two hash functions give bad distribution of hash chain lengths (not clear why) -#ifndef PRT -#define PRT(a,t) printf( "%s = ", (a) ); printf( "%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC) ) -#endif - //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -152,7 +131,7 @@ struct Fraig_ManStruct_t_ int fTryProve; // tries to solve the final miter int fVerbose; // the verbosiness flag int fVerboseP; // the verbosiness flag - sint64 nInspLimit; // the inspection limit + ABC_INT64_T nInspLimit; // the inspection limit int nTravIds; // the traversal counter int nTravIds2; // the traversal counter diff --git a/src/sat/fraig/fraigMan.c b/src/sat/fraig/fraigMan.c index cbeef4c6..b71262d8 100644 --- a/src/sat/fraig/fraigMan.c +++ b/src/sat/fraig/fraigMan.c @@ -204,7 +204,7 @@ Fraig_Man_t * Fraig_ManCreate( Fraig_Params_t * pParams ) pParams->nPatsRand = pParams->nPatsDyna = 128; // start the manager - p = ALLOC( Fraig_Man_t, 1 ); + p = ABC_ALLOC( Fraig_Man_t, 1 ); memset( p, 0, sizeof(Fraig_Man_t) ); // set the default parameters @@ -286,25 +286,25 @@ void Fraig_ManFree( Fraig_Man_t * p ) if ( p->vProj ) Msat_IntVecFree( p->vProj ); if ( p->vCones ) Fraig_NodeVecFree( p->vCones ); if ( p->vPatsReal ) Msat_IntVecFree( p->vPatsReal ); - if ( p->pModel ) free( p->pModel ); + if ( p->pModel ) ABC_FREE( p->pModel ); Fraig_MemFixedStop( p->mmNodes, 0 ); Fraig_MemFixedStop( p->mmSims, 0 ); if ( p->pSuppS ) { - FREE( p->pSuppS[0] ); - FREE( p->pSuppS ); + ABC_FREE( p->pSuppS[0] ); + ABC_FREE( p->pSuppS ); } if ( p->pSuppF ) { - FREE( p->pSuppF[0] ); - FREE( p->pSuppF ); + ABC_FREE( p->pSuppF[0] ); + ABC_FREE( p->pSuppF ); } - FREE( p->ppOutputNames ); - FREE( p->ppInputNames ); - FREE( p ); + ABC_FREE( p->ppOutputNames ); + ABC_FREE( p->ppInputNames ); + ABC_FREE( p ); } /**Function************************************************************* @@ -366,8 +366,8 @@ void Fraig_ManPrintStats( Fraig_Man_t * p ) if ( p->time2 > 0 ) { Fraig_PrintTime( "time2", p->time2 ); } if ( p->time3 > 0 ) { Fraig_PrintTime( "time3", p->time3 ); } if ( p->time4 > 0 ) { Fraig_PrintTime( "time4", p->time4 ); } -// PRT( "Selection ", timeSelect ); -// PRT( "Assignment", timeAssign ); +// ABC_PRT( "Selection ", timeSelect ); +// ABC_PRT( "Assignment", timeAssign ); fflush( stdout ); } @@ -389,7 +389,7 @@ Fraig_NodeVec_t * Fraig_UtilInfoAlloc( int nSize, int nWords, bool fClean ) int i; assert( nSize > 0 && nWords > 0 ); vInfo = Fraig_NodeVecAlloc( nSize ); - pUnsigned = ALLOC( unsigned, nSize * nWords ); + pUnsigned = ABC_ALLOC( unsigned, nSize * nWords ); vInfo->pArray[0] = (Fraig_Node_t *)pUnsigned; if ( fClean ) memset( pUnsigned, 0, sizeof(unsigned) * nSize * nWords ); diff --git a/src/sat/fraig/fraigMem.c b/src/sat/fraig/fraigMem.c index 500431c6..1cc99790 100644 --- a/src/sat/fraig/fraigMem.c +++ b/src/sat/fraig/fraigMem.c @@ -29,7 +29,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 free entries + char * pEntriesFree; // the linked list of ABC_FREE entries // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -61,7 +61,7 @@ Fraig_MemFixed_t * Fraig_MemFixedStart( int nEntrySize ) { Fraig_MemFixed_t * p; - p = ALLOC( Fraig_MemFixed_t, 1 ); + p = ABC_ALLOC( Fraig_MemFixed_t, 1 ); memset( p, 0, sizeof(Fraig_MemFixed_t) ); p->nEntrySize = nEntrySize; @@ -78,7 +78,7 @@ Fraig_MemFixed_t * Fraig_MemFixedStart( int nEntrySize ) p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -109,9 +109,9 @@ void Fraig_MemFixedStop( Fraig_MemFixed_t * p, int fVerbose ) p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -130,16 +130,16 @@ char * Fraig_MemFixedEntryFetch( Fraig_MemFixed_t * p ) char * pTemp; int i; - // check if there are still free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize ); + 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; @@ -159,7 +159,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 free entry list + // return the first entry in the ABC_FREE entry list pTemp = p->pEntriesFree; p->pEntriesFree = *((char **)pTemp); return pTemp; @@ -180,7 +180,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 free entries + // add the entry to the linked list of ABC_FREE entries *((char **)pEntry) = p->pEntriesFree; p->pEntriesFree = pEntry; } @@ -203,7 +203,7 @@ void Fraig_MemFixedRestart( Fraig_MemFixed_t * p ) // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; // transform these entries into a linked list pTemp = p->pChunks[0]; @@ -214,7 +214,7 @@ void Fraig_MemFixedRestart( Fraig_MemFixed_t * p ) } // set the last link *((char **)pTemp) = NULL; - // set the free entry list + // set the ABC_FREE entry list p->pEntriesFree = p->pChunks[0]; // set the correct statistics p->nMemoryAlloc = p->nEntrySize * p->nChunkSize; diff --git a/src/sat/fraig/fraigSat.c b/src/sat/fraig/fraigSat.c index 53057fc3..66698600 100644 --- a/src/sat/fraig/fraigSat.c +++ b/src/sat/fraig/fraigSat.c @@ -109,7 +109,7 @@ void Fraig_ManProveMiter( Fraig_Man_t * p ) } if ( p->fVerboseP ) { -// PRT( "Final miter proof time", clock() - clk ); +// ABC_PRT( "Final miter proof time", clock() - clk ); } } @@ -128,7 +128,7 @@ int Fraig_ManCheckMiter( Fraig_Man_t * p ) { Fraig_Node_t * pNode; int i; - FREE( p->pModel ); + ABC_FREE( p->pModel ); for ( i = 0; i < p->vOutputs->nSize; i++ ) { // get the output node (it can be complemented!) @@ -352,7 +352,7 @@ clk = clock(); p->timeTrav += clock() - clk; // printf( "The number of MUXes detected = %d (%5.2f %% of logic). ", nMuxes, 300.0*nMuxes/(p->vNodes->nSize - p->vInputs->nSize) ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); if ( fVerbose ) printf( "%d(%d) - ", Fraig_CountPis(p,p->vVarsInt), Msat_IntVecReadSize(p->vVarsInt) ); @@ -391,8 +391,8 @@ p->timeSat += clock() - clk; if ( fVerbose ) { - printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // add the clause @@ -409,8 +409,8 @@ PRT( "time", clock() - clk ); if ( fVerbose ) { - printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // record the counter example @@ -468,8 +468,8 @@ p->timeSat += clock() - clk; if ( fVerbose ) { - printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // add the clause @@ -486,8 +486,8 @@ PRT( "time", clock() - clk ); if ( fVerbose ) { - printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // record the counter example @@ -599,8 +599,8 @@ p->timeSat += clock() - clk; if ( fVerbose ) { - printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // add the clause @@ -618,8 +618,8 @@ PRT( "time", clock() - clk ); if ( fVerbose ) { - printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // record the counter example Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pOld, pNew ); @@ -690,8 +690,8 @@ p->timeSat += clock() - clk; if ( fVerbose ) { - printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "unsat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // add the clause @@ -709,8 +709,8 @@ PRT( "time", clock() - clk ); if ( fVerbose ) { - printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); -PRT( "time", clock() - clk ); +// printf( "sat %d ", Msat_SolverReadBackTracks(p->pSat) ); +//ABC_PRT( "time", clock() - clk ); } // record the counter example // Fraig_FeedBack( p, Msat_SolverReadModelArray(p->pSat), p->vVarsInt, pNode1R, pNode2R ); @@ -907,7 +907,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-free cone (experiment only) + // detecting a fanout-ABC_FREE cone (experiment only) // Fraig_DetectFanoutFreeCone( pMan, pNode ); if ( fUseMuxes && Fraig_NodeIsMuxType(pNode) ) diff --git a/src/sat/fraig/fraigTable.c b/src/sat/fraig/fraigTable.c index b68bbe0e..55d92b4a 100644 --- a/src/sat/fraig/fraigTable.c +++ b/src/sat/fraig/fraigTable.c @@ -44,11 +44,11 @@ Fraig_HashTable_t * Fraig_HashTableCreate( int nSize ) { Fraig_HashTable_t * p; // allocate the table - p = ALLOC( Fraig_HashTable_t, 1 ); + p = ABC_ALLOC( Fraig_HashTable_t, 1 ); memset( p, 0, sizeof(Fraig_HashTable_t) ); // allocate and clean the bins p->nBins = Cudd_PrimeFraig(nSize); - p->pBins = ALLOC( Fraig_Node_t *, p->nBins ); + p->pBins = ABC_ALLOC( Fraig_Node_t *, p->nBins ); memset( p->pBins, 0, sizeof(Fraig_Node_t *) * p->nBins ); return p; } @@ -66,8 +66,8 @@ Fraig_HashTable_t * Fraig_HashTableCreate( int nSize ) ***********************************************************************/ void Fraig_HashTableFree( Fraig_HashTable_t * p ) { - FREE( p->pBins ); - FREE( p ); + ABC_FREE( p->pBins ); + ABC_FREE( p ); } /**Function************************************************************* @@ -264,7 +264,7 @@ clk = clock(); // get the new table size nBinsNew = Cudd_PrimeFraig(2 * p->nBins); // allocate a new array - pBinsNew = ALLOC( Fraig_Node_t *, nBinsNew ); + pBinsNew = ABC_ALLOC( Fraig_Node_t *, nBinsNew ); memset( pBinsNew, 0, sizeof(Fraig_Node_t *) * nBinsNew ); // rehash the entries from the old table Counter = 0; @@ -278,9 +278,9 @@ clk = clock(); } assert( Counter == p->nEntries ); // printf( "Increasing the structural table size from %6d to %6d. ", p->nBins, nBinsNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( p->pBins ); + ABC_FREE( p->pBins ); p->pBins = pBinsNew; p->nBins = nBinsNew; } @@ -307,7 +307,7 @@ clk = clock(); // get the new table size nBinsNew = Cudd_PrimeFraig(2 * p->nBins); // allocate a new array - pBinsNew = ALLOC( Fraig_Node_t *, nBinsNew ); + pBinsNew = ABC_ALLOC( Fraig_Node_t *, nBinsNew ); memset( pBinsNew, 0, sizeof(Fraig_Node_t *) * nBinsNew ); // rehash the entries from the old table Counter = 0; @@ -324,9 +324,9 @@ clk = clock(); } assert( Counter == p->nEntries ); // printf( "Increasing the functional table size from %6d to %6d. ", p->nBins, nBinsNew ); -// PRT( "Time", clock() - clk ); +// ABC_PRT( "Time", clock() - clk ); // replace the table and the parameters - free( p->pBins ); + ABC_FREE( p->pBins ); p->pBins = pBinsNew; p->nBins = nBinsNew; } @@ -605,7 +605,7 @@ int Fraig_TableRehashF0( Fraig_Man_t * pMan, int fLinkEquiv ) unsigned Key; // allocate a new array of bins - pBinsNew = ALLOC( Fraig_Node_t *, pT->nBins ); + pBinsNew = ABC_ALLOC( Fraig_Node_t *, pT->nBins ); memset( pBinsNew, 0, sizeof(Fraig_Node_t *) * pT->nBins ); // rehash the entries in the table @@ -645,7 +645,7 @@ int Fraig_TableRehashF0( Fraig_Man_t * pMan, int fLinkEquiv ) } assert( Counter == pT->nEntries ); // replace the table and the parameters - free( pT->pBins ); + ABC_FREE( pT->pBins ); pT->pBins = pBinsNew; return ReturnValue; } diff --git a/src/sat/fraig/fraigUtil.c b/src/sat/fraig/fraigUtil.c index 342a7111..ea52d363 100644 --- a/src/sat/fraig/fraigUtil.c +++ b/src/sat/fraig/fraigUtil.c @@ -237,7 +237,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-free cones of AND-nodes, which is helpful for rebalancing + fanout-ABC_FREE cones of AND-nodes, which is helpful for rebalancing the AIG (see procedure Fraig_ManRebalance, or something like that).] SideEffects [] @@ -881,7 +881,7 @@ clk = clock(); } } printf( "Number of candidate pairs = %d. Proved = %d.\n", Counter, nProved ); -PRT( "Time", clock() - clk ); +//ABC_PRT( "Time", clock() - clk ); return 0; } diff --git a/src/sat/fraig/fraigVec.c b/src/sat/fraig/fraigVec.c index ba3feecd..b47c6a2f 100644 --- a/src/sat/fraig/fraigVec.c +++ b/src/sat/fraig/fraigVec.c @@ -40,12 +40,12 @@ Fraig_NodeVec_t * Fraig_NodeVecAlloc( int nCap ) { Fraig_NodeVec_t * p; - p = ALLOC( Fraig_NodeVec_t, 1 ); + p = ABC_ALLOC( Fraig_NodeVec_t, 1 ); if ( nCap > 0 && nCap < 8 ) nCap = 8; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( Fraig_Node_t *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( Fraig_Node_t *, p->nCap ) : NULL; return p; } @@ -62,8 +62,8 @@ Fraig_NodeVec_t * Fraig_NodeVecAlloc( int nCap ) ***********************************************************************/ void Fraig_NodeVecFree( Fraig_NodeVec_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -80,10 +80,10 @@ void Fraig_NodeVecFree( Fraig_NodeVec_t * p ) Fraig_NodeVec_t * Fraig_NodeVecDup( Fraig_NodeVec_t * pVec ) { Fraig_NodeVec_t * p; - p = ALLOC( Fraig_NodeVec_t, 1 ); + p = ABC_ALLOC( Fraig_NodeVec_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; - p->pArray = p->nCap? ALLOC( Fraig_Node_t *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( Fraig_Node_t *, p->nCap ) : NULL; memcpy( p->pArray, pVec->pArray, sizeof(Fraig_Node_t *) * pVec->nSize ); return p; } @@ -135,7 +135,7 @@ void Fraig_NodeVecGrow( Fraig_NodeVec_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( Fraig_Node_t *, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( Fraig_Node_t *, p->pArray, nCapMin ); p->nCap = nCapMin; } diff --git a/src/sat/lsat/solver.h b/src/sat/lsat/solver.h index a15e42d6..8d198cb2 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, free of charge, to any person obtaining a copy of this software and +Permission is hereby granted, ABC_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 diff --git a/src/sat/msat/module.make b/src/sat/msat/module.make index 0dadfbe1..33133963 100644 --- a/src/sat/msat/module.make +++ b/src/sat/msat/module.make @@ -2,7 +2,7 @@ SRC += src/sat/msat/msatActivity.c \ src/sat/msat/msatClause.c \ src/sat/msat/msatClauseVec.c \ src/sat/msat/msatMem.c \ - src/sat/msat/msatOrderJ.c \ + src/sat/msat/msatOrderH.c \ src/sat/msat/msatQueue.c \ src/sat/msat/msatRead.c \ src/sat/msat/msatSolverApi.c \ diff --git a/src/sat/msat/msat.h b/src/sat/msat/msat.h index 53353ba6..2b28700c 100644 --- a/src/sat/msat/msat.h +++ b/src/sat/msat/msat.h @@ -21,10 +21,6 @@ #ifndef __MSAT_H__ #define __MSAT_H__ -#ifdef __cplusplus -extern "C" { -#endif - //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -33,6 +29,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// diff --git a/src/sat/msat/msatClause.c b/src/sat/msat/msatClause.c index 2ba8cd32..ca698866 100644 --- a/src/sat/msat/msatClause.c +++ b/src/sat/msat/msatClause.c @@ -152,7 +152,7 @@ bool Msat_ClauseCreate( Msat_Solver_t * p, Msat_IntVec_t * vLits, bool fLearned, // nBytes = sizeof(unsigned)*(nLits + 1 + (int)fLearned); nBytes = sizeof(unsigned)*(nLits + 2 + (int)fLearned); #ifdef USE_SYSTEM_MEMORY_MANAGEMENT - pC = (Msat_Clause_t *)ALLOC( char, nBytes ); + pC = (Msat_Clause_t *)ABC_ALLOC( char, nBytes ); #else pC = (Msat_Clause_t *)Msat_MmStepEntryFetch( Msat_SolverReadMem(p), nBytes ); #endif @@ -231,7 +231,7 @@ void Msat_ClauseFree( Msat_Solver_t * p, Msat_Clause_t * pC, bool fRemoveWatched } #ifdef USE_SYSTEM_MEMORY_MANAGEMENT - free( pC ); + ABC_FREE( pC ); #else Msat_MmStepEntryRecycle( Msat_SolverReadMem(p), (char *)pC, pC->nSizeAlloc ); #endif diff --git a/src/sat/msat/msatClauseVec.c b/src/sat/msat/msatClauseVec.c index 04691cf2..f29de389 100644 --- a/src/sat/msat/msatClauseVec.c +++ b/src/sat/msat/msatClauseVec.c @@ -42,12 +42,12 @@ Msat_ClauseVec_t * Msat_ClauseVecAlloc( int nCap ) { Msat_ClauseVec_t * p; - p = ALLOC( Msat_ClauseVec_t, 1 ); + p = ABC_ALLOC( Msat_ClauseVec_t, 1 ); if ( nCap > 0 && nCap < 16 ) nCap = 16; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( Msat_Clause_t *, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( Msat_Clause_t *, p->nCap ) : NULL; return p; } @@ -64,8 +64,8 @@ Msat_ClauseVec_t * Msat_ClauseVecAlloc( int nCap ) ***********************************************************************/ void Msat_ClauseVecFree( Msat_ClauseVec_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -115,7 +115,7 @@ void Msat_ClauseVecGrow( Msat_ClauseVec_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( Msat_Clause_t *, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( Msat_Clause_t *, p->pArray, nCapMin ); p->nCap = nCapMin; } diff --git a/src/sat/msat/msatInt.h b/src/sat/msat/msatInt.h index 2ff0e695..b6759a0f 100644 --- a/src/sat/msat/msatInt.h +++ b/src/sat/msat/msatInt.h @@ -31,6 +31,7 @@ #include #include #include +#include "abc_global.h" #include "msat.h" //////////////////////////////////////////////////////////////////////// @@ -41,25 +42,6 @@ /// STRUCTURE DEFINITIONS /// //////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -typedef __int64 int64; -#else -typedef long long int64; -#endif - -// outputs the runtime in seconds -#define PRT(a,t) \ - printf( "%s = ", (a) ); printf( "%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC) ) - -// memory management macros -#define ALLOC(type, num) \ - ((type *) malloc(sizeof(type) * (num))) -#define REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) -#define FREE(obj) \ - ((obj) ? (free((char *)(obj)), (obj) = 0) : 0) - // By default, custom memory management is used // which guarantees constant time allocation/deallocation // for SAT clauses and other frequently modified objects. @@ -92,12 +74,12 @@ typedef int Msat_Var_t; typedef struct Msat_SolverStats_t_ Msat_SolverStats_t; struct Msat_SolverStats_t_ { - int64 nStarts; // the number of restarts - int64 nDecisions; // the number of decisions - int64 nPropagations; // the number of implications - int64 nInspects; // the number of times clauses are vising while watching them - int64 nConflicts; // the number of conflicts - int64 nSuccesses; // the number of sat assignments found + ABC_INT64_T nStarts; // the number of restarts + ABC_INT64_T nDecisions; // the number of decisions + ABC_INT64_T nPropagations; // the number of implications + ABC_INT64_T nInspects; // the number of times clauses are vising while watching them + ABC_INT64_T nConflicts; // the number of conflicts + ABC_INT64_T nSuccesses; // the number of sat assignments found }; typedef struct Msat_SearchParams_t_ Msat_SearchParams_t; diff --git a/src/sat/msat/msatMem.c b/src/sat/msat/msatMem.c index 30bf4a96..439661f4 100644 --- a/src/sat/msat/msatMem.c +++ b/src/sat/msat/msatMem.c @@ -31,7 +31,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 free entries + char * pEntriesFree; // the linked list of ABC_FREE entries // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -48,8 +48,8 @@ struct Msat_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 + char * pCurrent; // the current pointer to ABC_FREE memory + char * pEnd; // the first entry outside the ABC_FREE memory // this is where the memory is stored int nChunkSize; // the size of one chunk @@ -91,7 +91,7 @@ Msat_MmFixed_t * Msat_MmFixedStart( int nEntrySize ) { Msat_MmFixed_t * p; - p = ALLOC( Msat_MmFixed_t, 1 ); + p = ABC_ALLOC( Msat_MmFixed_t, 1 ); memset( p, 0, sizeof(Msat_MmFixed_t) ); p->nEntrySize = nEntrySize; @@ -108,7 +108,7 @@ Msat_MmFixed_t * Msat_MmFixedStart( int nEntrySize ) p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -139,9 +139,9 @@ void Msat_MmFixedStop( Msat_MmFixed_t * p, int fVerbose ) p->nEntriesUsed, p->nEntriesMax, p->nEntrySize * p->nEntriesUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -160,16 +160,16 @@ char * Msat_MmFixedEntryFetch( Msat_MmFixed_t * p ) char * pTemp; int i; - // check if there are still free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } - p->pEntriesFree = ALLOC( char, p->nEntrySize * p->nChunkSize ); + 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; @@ -189,7 +189,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 free entry list + // return the first entry in the ABC_FREE entry list pTemp = p->pEntriesFree; p->pEntriesFree = *((char **)pTemp); return pTemp; @@ -210,7 +210,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 free entries + // add the entry to the linked list of ABC_FREE entries *((char **)pEntry) = p->pEntriesFree; p->pEntriesFree = pEntry; } @@ -233,7 +233,7 @@ void Msat_MmFixedRestart( Msat_MmFixed_t * p ) // deallocate all chunks except the first one for ( i = 1; i < p->nChunks; i++ ) - free( p->pChunks[i] ); + ABC_FREE( p->pChunks[i] ); p->nChunks = 1; // transform these entries into a linked list pTemp = p->pChunks[0]; @@ -244,7 +244,7 @@ void Msat_MmFixedRestart( Msat_MmFixed_t * p ) } // set the last link *((char **)pTemp) = NULL; - // set the free entry list + // set the ABC_FREE entry list p->pEntriesFree = p->pChunks[0]; // set the correct statistics p->nMemoryAlloc = p->nEntrySize * p->nChunkSize; @@ -286,7 +286,7 @@ Msat_MmFlex_t * Msat_MmFlexStart() { Msat_MmFlex_t * p; - p = ALLOC( Msat_MmFlex_t, 1 ); + p = ABC_ALLOC( Msat_MmFlex_t, 1 ); memset( p, 0, sizeof(Msat_MmFlex_t) ); p->nEntriesUsed = 0; @@ -296,7 +296,7 @@ Msat_MmFlex_t * Msat_MmFlexStart() p->nChunkSize = (1 << 12); p->nChunksAlloc = 64; p->nChunks = 0; - p->pChunks = ALLOC( char *, p->nChunksAlloc ); + p->pChunks = ABC_ALLOC( char *, p->nChunksAlloc ); p->nMemoryUsed = 0; p->nMemoryAlloc = 0; @@ -327,9 +327,9 @@ void Msat_MmFlexStop( Msat_MmFlex_t * p, int fVerbose ) p->nEntriesUsed, p->nMemoryUsed, p->nMemoryAlloc ); } for ( i = 0; i < p->nChunks; i++ ) - free( p->pChunks[i] ); - free( p->pChunks ); - free( p ); + ABC_FREE( p->pChunks[i] ); + ABC_FREE( p->pChunks ); + ABC_FREE( p ); } /**Function************************************************************* @@ -346,13 +346,13 @@ 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 free entries + // check if there are still ABC_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 = REALLOC( char *, p->pChunks, p->nChunksAlloc ); + p->pChunks = ABC_REALLOC( char *, p->pChunks, p->nChunksAlloc ); } if ( nBytes > p->nChunkSize ) { @@ -360,7 +360,7 @@ char * Msat_MmFlexEntryFetch( Msat_MmFlex_t * p, int nBytes ) // (ideally, this should never happen) p->nChunkSize = 2 * nBytes; } - p->pCurrent = ALLOC( char, p->nChunkSize ); + p->pCurrent = ABC_ALLOC( char, p->nChunkSize ); p->pEnd = p->pCurrent + p->nChunkSize; p->nMemoryAlloc += p->nChunkSize; // add the chunk to the chunk storage @@ -410,7 +410,7 @@ int Msat_MmFlexReadMemUsage( Msat_MmFlex_t * p ) 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 free()ed.] + entries are handed over to malloc() and then ABC_FREE()ed.] SideEffects [] @@ -421,15 +421,15 @@ Msat_MmStep_t * Msat_MmStepStart( int nSteps ) { Msat_MmStep_t * p; int i, k; - p = ALLOC( Msat_MmStep_t, 1 ); + p = ABC_ALLOC( Msat_MmStep_t, 1 ); p->nMems = nSteps; // start the fixed memory managers - p->pMems = ALLOC( Msat_MmFixed_t *, p->nMems ); + p->pMems = ABC_ALLOC( Msat_MmFixed_t *, p->nMems ); for ( i = 0; i < p->nMems; i++ ) p->pMems[i] = Msat_MmFixedStart( (8<nMapSize = (4<nMems); - p->pMap = ALLOC( Msat_MmFixed_t *, p->nMapSize+1 ); + p->pMap = ABC_ALLOC( Msat_MmFixed_t *, p->nMapSize+1 ); p->pMap[0] = NULL; for ( k = 1; k <= 4; k++ ) p->pMap[k] = p->pMems[0]; @@ -457,9 +457,9 @@ void Msat_MmStepStop( Msat_MmStep_t * p, int fVerbose ) int i; for ( i = 0; i < p->nMems; i++ ) Msat_MmFixedStop( p->pMems[i], fVerbose ); - free( p->pMems ); - free( p->pMap ); - free( p ); + ABC_FREE( p->pMems ); + ABC_FREE( p->pMap ); + ABC_FREE( p ); } /**Function************************************************************* @@ -480,7 +480,7 @@ char * Msat_MmStepEntryFetch( Msat_MmStep_t * p, int nBytes ) if ( nBytes > p->nMapSize ) { // printf( "Allocating %d bytes.\n", nBytes ); - return ALLOC( char, nBytes ); + return ABC_ALLOC( char, nBytes ); } return Msat_MmFixedEntryFetch( p->pMap[nBytes] ); } @@ -503,7 +503,7 @@ void Msat_MmStepEntryRecycle( Msat_MmStep_t * p, char * pEntry, int nBytes ) return; if ( nBytes > p->nMapSize ) { - free( pEntry ); + ABC_FREE( pEntry ); return; } Msat_MmFixedEntryRecycle( p->pMap[nBytes], pEntry ); diff --git a/src/sat/msat/msatOrderH.c b/src/sat/msat/msatOrderH.c index 956e7fc6..7d8484d5 100644 --- a/src/sat/msat/msatOrderH.c +++ b/src/sat/msat/msatOrderH.c @@ -75,7 +75,7 @@ extern int timeSelect; Msat_Order_t * Msat_OrderAlloc( Msat_Solver_t * pSat ) { Msat_Order_t * p; - p = ALLOC( Msat_Order_t, 1 ); + p = ABC_ALLOC( Msat_Order_t, 1 ); memset( p, 0, sizeof(Msat_Order_t) ); p->pSat = pSat; p->vIndex = Msat_IntVecAlloc( 0 ); @@ -161,7 +161,7 @@ void Msat_OrderFree( Msat_Order_t * p ) { Msat_IntVecFree( p->vHeap ); Msat_IntVecFree( p->vIndex ); - free( p ); + ABC_FREE( p ); } diff --git a/src/sat/msat/msatQueue.c b/src/sat/msat/msatQueue.c index 5938e042..0bcaf6b2 100644 --- a/src/sat/msat/msatQueue.c +++ b/src/sat/msat/msatQueue.c @@ -50,10 +50,10 @@ struct Msat_Queue_t_ Msat_Queue_t * Msat_QueueAlloc( int nVars ) { Msat_Queue_t * p; - p = ALLOC( Msat_Queue_t, 1 ); + p = ABC_ALLOC( Msat_Queue_t, 1 ); memset( p, 0, sizeof(Msat_Queue_t) ); p->nVars = nVars; - p->pVars = ALLOC( int, nVars ); + p->pVars = ABC_ALLOC( int, nVars ); return p; } @@ -70,8 +70,8 @@ Msat_Queue_t * Msat_QueueAlloc( int nVars ) ***********************************************************************/ void Msat_QueueFree( Msat_Queue_t * p ) { - free( p->pVars ); - free( p ); + ABC_FREE( p->pVars ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/sat/msat/msatRead.c b/src/sat/msat/msatRead.c index 20453fed..ba33278c 100644 --- a/src/sat/msat/msatRead.c +++ b/src/sat/msat/msatRead.c @@ -51,7 +51,7 @@ char * Msat_FileRead( FILE * pFile ) // move the file current reading position to the beginning rewind( pFile ); // load the contents of the file into memory - pBuffer = ALLOC( char, nFileSize + 3 ); + pBuffer = ABC_ALLOC( char, nFileSize + 3 ); fread( pBuffer, nFileSize, 1, pFile ); // terminate the string with '\0' pBuffer[ nFileSize + 0] = '\n'; @@ -257,7 +257,7 @@ bool Msat_SolverParseDimacs( FILE * pFile, Msat_Solver_t ** p, int fVerbose ) bool Value; pText = Msat_FileRead( pFile ); Value = Msat_ReadDimacs( pText, p, fVerbose ); - free( pText ); + ABC_FREE( pText ); return Value; } diff --git a/src/sat/msat/msatSolverApi.c b/src/sat/msat/msatSolverApi.c index ee3507a6..dece390c 100644 --- a/src/sat/msat/msatSolverApi.c +++ b/src/sat/msat/msatSolverApi.c @@ -159,7 +159,7 @@ Msat_Solver_t * Msat_SolverAlloc( int nVarsAlloc, assert(sizeof(Msat_Lit_t) == sizeof(unsigned)); assert(sizeof(float) == sizeof(unsigned)); - p = ALLOC( Msat_Solver_t, 1 ); + p = ABC_ALLOC( Msat_Solver_t, 1 ); memset( p, 0, sizeof(Msat_Solver_t) ); p->nVarsAlloc = nVarsAlloc; @@ -174,31 +174,31 @@ Msat_Solver_t * Msat_SolverAlloc( int nVarsAlloc, p->dVarInc = dVarInc; p->dVarDecay = dVarDecay; - p->pdActivity = ALLOC( double, p->nVarsAlloc ); - p->pFactors = ALLOC( float, p->nVarsAlloc ); + p->pdActivity = ABC_ALLOC( double, p->nVarsAlloc ); + p->pFactors = ABC_ALLOC( float, p->nVarsAlloc ); for ( i = 0; i < p->nVarsAlloc; i++ ) { p->pdActivity[i] = 0.0; p->pFactors[i] = 1.0; } - p->pAssigns = ALLOC( int, p->nVarsAlloc ); - p->pModel = ALLOC( int, p->nVarsAlloc ); + p->pAssigns = ABC_ALLOC( int, p->nVarsAlloc ); + p->pModel = ABC_ALLOC( int, p->nVarsAlloc ); for ( i = 0; i < p->nVarsAlloc; i++ ) p->pAssigns[i] = MSAT_VAR_UNASSIGNED; // p->pOrder = Msat_OrderAlloc( p->pAssigns, p->pdActivity, p->nVarsAlloc ); p->pOrder = Msat_OrderAlloc( p ); - p->pvWatched = ALLOC( Msat_ClauseVec_t *, 2 * p->nVarsAlloc ); + p->pvWatched = ABC_ALLOC( Msat_ClauseVec_t *, 2 * p->nVarsAlloc ); for ( i = 0; i < 2 * p->nVarsAlloc; i++ ) p->pvWatched[i] = Msat_ClauseVecAlloc( 16 ); p->pQueue = Msat_QueueAlloc( p->nVarsAlloc ); p->vTrail = Msat_IntVecAlloc( p->nVarsAlloc ); p->vTrailLim = Msat_IntVecAlloc( p->nVarsAlloc ); - p->pReasons = ALLOC( Msat_Clause_t *, p->nVarsAlloc ); + p->pReasons = ABC_ALLOC( Msat_Clause_t *, p->nVarsAlloc ); memset( p->pReasons, 0, sizeof(Msat_Clause_t *) * p->nVarsAlloc ); - p->pLevel = ALLOC( int, p->nVarsAlloc ); + p->pLevel = ABC_ALLOC( int, p->nVarsAlloc ); for ( i = 0; i < p->nVarsAlloc; i++ ) p->pLevel[i] = -1; p->dRandSeed = 91648253; @@ -215,7 +215,7 @@ Msat_Solver_t * Msat_SolverAlloc( int nVarsAlloc, Msat_IntVecFill( p->vVarsUsed, p->nVarsAlloc, 1 ); - p->pSeen = ALLOC( int, p->nVarsAlloc ); + p->pSeen = ABC_ALLOC( int, p->nVarsAlloc ); memset( p->pSeen, 0, sizeof(int) * p->nVarsAlloc ); p->nSeenId = 1; p->vReason = Msat_IntVecAlloc( p->nVarsAlloc ); @@ -243,38 +243,38 @@ void Msat_SolverResize( Msat_Solver_t * p, int nVarsAlloc ) nVarsAllocOld = p->nVarsAlloc; p->nVarsAlloc = nVarsAlloc; - p->pdActivity = REALLOC( double, p->pdActivity, p->nVarsAlloc ); - p->pFactors = REALLOC( float, p->pFactors, p->nVarsAlloc ); + p->pdActivity = ABC_REALLOC( double, p->pdActivity, p->nVarsAlloc ); + p->pFactors = ABC_REALLOC( float, p->pFactors, p->nVarsAlloc ); for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ ) { p->pdActivity[i] = 0.0; p->pFactors[i] = 1.0; } - p->pAssigns = REALLOC( int, p->pAssigns, p->nVarsAlloc ); - p->pModel = REALLOC( int, p->pModel, p->nVarsAlloc ); + p->pAssigns = ABC_REALLOC( int, p->pAssigns, p->nVarsAlloc ); + p->pModel = ABC_REALLOC( int, p->pModel, p->nVarsAlloc ); for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ ) p->pAssigns[i] = MSAT_VAR_UNASSIGNED; // Msat_OrderRealloc( p->pOrder, p->pAssigns, p->pdActivity, p->nVarsAlloc ); Msat_OrderSetBounds( p->pOrder, p->nVarsAlloc ); - p->pvWatched = REALLOC( Msat_ClauseVec_t *, p->pvWatched, 2 * p->nVarsAlloc ); + p->pvWatched = ABC_REALLOC( Msat_ClauseVec_t *, p->pvWatched, 2 * p->nVarsAlloc ); for ( i = 2 * nVarsAllocOld; i < 2 * p->nVarsAlloc; i++ ) p->pvWatched[i] = Msat_ClauseVecAlloc( 16 ); Msat_QueueFree( p->pQueue ); p->pQueue = Msat_QueueAlloc( p->nVarsAlloc ); - p->pReasons = REALLOC( Msat_Clause_t *, p->pReasons, p->nVarsAlloc ); - p->pLevel = REALLOC( int, p->pLevel, p->nVarsAlloc ); + p->pReasons = ABC_REALLOC( Msat_Clause_t *, p->pReasons, p->nVarsAlloc ); + p->pLevel = ABC_REALLOC( int, p->pLevel, p->nVarsAlloc ); for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ ) { p->pReasons[i] = NULL; p->pLevel[i] = -1; } - p->pSeen = REALLOC( int, p->pSeen, p->nVarsAlloc ); + p->pSeen = ABC_REALLOC( int, p->pSeen, p->nVarsAlloc ); for ( i = nVarsAllocOld; i < p->nVarsAlloc; i++ ) p->pSeen[i] = 0; @@ -304,7 +304,7 @@ void Msat_SolverResize( Msat_Solver_t * p, int nVarsAlloc ) void Msat_SolverClean( Msat_Solver_t * p, int nVars ) { int i; - // free the clauses + // ABC_FREE the clauses int nClauses; Msat_Clause_t ** pClauses; @@ -326,7 +326,7 @@ void Msat_SolverClean( Msat_Solver_t * p, int nVars ) // Msat_ClauseVecFree( p->vLearned ); Msat_ClauseVecClear( p->vLearned ); -// FREE( p->pdActivity ); +// ABC_FREE( p->pdActivity ); for ( i = 0; i < p->nVars; i++ ) p->pdActivity[i] = 0; @@ -337,20 +337,20 @@ void Msat_SolverClean( Msat_Solver_t * p, int nVars ) for ( i = 0; i < 2 * p->nVars; i++ ) // Msat_ClauseVecFree( p->pvWatched[i] ); Msat_ClauseVecClear( p->pvWatched[i] ); -// FREE( p->pvWatched ); +// ABC_FREE( p->pvWatched ); // Msat_QueueFree( p->pQueue ); Msat_QueueClear( p->pQueue ); -// FREE( p->pAssigns ); +// ABC_FREE( p->pAssigns ); for ( i = 0; i < p->nVars; i++ ) p->pAssigns[i] = MSAT_VAR_UNASSIGNED; // Msat_IntVecFree( p->vTrail ); Msat_IntVecClear( p->vTrail ); // Msat_IntVecFree( p->vTrailLim ); Msat_IntVecClear( p->vTrailLim ); -// FREE( p->pReasons ); +// ABC_FREE( p->pReasons ); memset( p->pReasons, 0, sizeof(Msat_Clause_t *) * p->nVars ); -// FREE( p->pLevel ); +// ABC_FREE( p->pLevel ); for ( i = 0; i < p->nVars; i++ ) p->pLevel[i] = -1; // Msat_IntVecFree( p->pModel ); @@ -358,7 +358,7 @@ void Msat_SolverClean( Msat_Solver_t * p, int nVars ) p->dRandSeed = 91648253; p->dProgress = 0.0; -// FREE( p->pSeen ); +// ABC_FREE( p->pSeen ); memset( p->pSeen, 0, sizeof(int) * p->nVars ); p->nSeenId = 1; // Msat_IntVecFree( p->vReason ); @@ -366,7 +366,7 @@ void Msat_SolverClean( Msat_Solver_t * p, int nVars ) // Msat_IntVecFree( p->vTemp ); Msat_IntVecClear( p->vTemp ); // printf(" The number of clauses remaining = %d (%d).\n", p->nClausesAlloc, p->nClausesAllocL ); -// FREE( p ); +// ABC_FREE( p ); } /**Function************************************************************* @@ -384,7 +384,7 @@ void Msat_SolverFree( Msat_Solver_t * p ) { int i; - // free the clauses + // ABC_FREE the clauses int nClauses; Msat_Clause_t ** pClauses; //printf( "clauses = %d. learned = %d.\n", Msat_ClauseVecReadSize( p->vClauses ), @@ -402,21 +402,21 @@ void Msat_SolverFree( Msat_Solver_t * p ) Msat_ClauseFree( p, pClauses[i], 0 ); Msat_ClauseVecFree( p->vLearned ); - FREE( p->pdActivity ); - FREE( p->pFactors ); + ABC_FREE( p->pdActivity ); + ABC_FREE( p->pFactors ); Msat_OrderFree( p->pOrder ); for ( i = 0; i < 2 * p->nVarsAlloc; i++ ) Msat_ClauseVecFree( p->pvWatched[i] ); - FREE( p->pvWatched ); + ABC_FREE( p->pvWatched ); Msat_QueueFree( p->pQueue ); - FREE( p->pAssigns ); - FREE( p->pModel ); + ABC_FREE( p->pAssigns ); + ABC_FREE( p->pModel ); Msat_IntVecFree( p->vTrail ); Msat_IntVecFree( p->vTrailLim ); - FREE( p->pReasons ); - FREE( p->pLevel ); + ABC_FREE( p->pReasons ); + ABC_FREE( p->pLevel ); Msat_MmStepStop( p->pMem, 0 ); @@ -428,10 +428,10 @@ void Msat_SolverFree( Msat_Solver_t * p ) Msat_IntVecFree( p->vConeVars ); Msat_IntVecFree( p->vVarsUsed ); - FREE( p->pSeen ); + ABC_FREE( p->pSeen ); Msat_IntVecFree( p->vReason ); Msat_IntVecFree( p->vTemp ); - FREE( p ); + ABC_FREE( p ); } /**Function************************************************************* diff --git a/src/sat/msat/msatSolverCore.c b/src/sat/msat/msatSolverCore.c index e86ab511..0462f11b 100644 --- a/src/sat/msat/msatSolverCore.c +++ b/src/sat/msat/msatSolverCore.c @@ -139,7 +139,7 @@ bool Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTra Msat_Type_t Status; int timeStart = clock(); -// p->pFreq = ALLOC( int, p->nVarsAlloc ); +// p->pFreq = ABC_ALLOC( int, p->nVarsAlloc ); // memset( p->pFreq, 0, sizeof(int) * p->nVarsAlloc ); if ( vAssumps ) @@ -184,7 +184,7 @@ bool Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTra Msat_SolverCancelUntil( p, 0 ); p->nBackTracks = (int)p->Stats.nConflicts - p->nBackTracks; /* - PRT( "True solver runtime", clock() - timeStart ); + ABC_PRT( "True solver runtime", clock() - timeStart ); // print the statistics { int i, Counter = 0; @@ -197,7 +197,7 @@ bool Msat_SolverSolve( Msat_Solver_t * p, Msat_IntVec_t * vAssumps, int nBackTra if ( Counter ) printf( "\n" ); printf( "Total = %d. Used = %d. Decisions = %d. Imps = %d. Conflicts = %d. ", p->nVars, Counter, (int)p->Stats.nDecisions, (int)p->Stats.nPropagations, (int)p->Stats.nConflicts ); - PRT( "Time", clock() - timeStart ); + ABC_PRT( "Time", clock() - timeStart ); } */ return Status; diff --git a/src/sat/msat/msatVec.c b/src/sat/msat/msatVec.c index 36ad55ba..3716dbf7 100644 --- a/src/sat/msat/msatVec.c +++ b/src/sat/msat/msatVec.c @@ -45,12 +45,12 @@ static int Msat_IntVecSortCompare2( int * pp1, int * pp2 ); Msat_IntVec_t * Msat_IntVecAlloc( int nCap ) { Msat_IntVec_t * p; - p = ALLOC( Msat_IntVec_t, 1 ); + p = ABC_ALLOC( Msat_IntVec_t, 1 ); if ( nCap > 0 && nCap < 16 ) nCap = 16; p->nSize = 0; p->nCap = nCap; - p->pArray = p->nCap? ALLOC( int, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL; return p; } @@ -68,7 +68,7 @@ Msat_IntVec_t * Msat_IntVecAlloc( int nCap ) Msat_IntVec_t * Msat_IntVecAllocArray( int * pArray, int nSize ) { Msat_IntVec_t * p; - p = ALLOC( Msat_IntVec_t, 1 ); + p = ABC_ALLOC( Msat_IntVec_t, 1 ); p->nSize = nSize; p->nCap = nSize; p->pArray = pArray; @@ -89,10 +89,10 @@ Msat_IntVec_t * Msat_IntVecAllocArray( int * pArray, int nSize ) Msat_IntVec_t * Msat_IntVecAllocArrayCopy( int * pArray, int nSize ) { Msat_IntVec_t * p; - p = ALLOC( Msat_IntVec_t, 1 ); + p = ABC_ALLOC( Msat_IntVec_t, 1 ); p->nSize = nSize; p->nCap = nSize; - p->pArray = ALLOC( int, nSize ); + p->pArray = ABC_ALLOC( int, nSize ); memcpy( p->pArray, pArray, sizeof(int) * nSize ); return p; } @@ -111,10 +111,10 @@ Msat_IntVec_t * Msat_IntVecAllocArrayCopy( int * pArray, int nSize ) Msat_IntVec_t * Msat_IntVecDup( Msat_IntVec_t * pVec ) { Msat_IntVec_t * p; - p = ALLOC( Msat_IntVec_t, 1 ); + p = ABC_ALLOC( Msat_IntVec_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; - p->pArray = p->nCap? ALLOC( int, p->nCap ) : NULL; + p->pArray = p->nCap? ABC_ALLOC( int, p->nCap ) : NULL; memcpy( p->pArray, pVec->pArray, sizeof(int) * pVec->nSize ); return p; } @@ -133,7 +133,7 @@ Msat_IntVec_t * Msat_IntVecDup( Msat_IntVec_t * pVec ) Msat_IntVec_t * Msat_IntVecDupArray( Msat_IntVec_t * pVec ) { Msat_IntVec_t * p; - p = ALLOC( Msat_IntVec_t, 1 ); + p = ABC_ALLOC( Msat_IntVec_t, 1 ); p->nSize = pVec->nSize; p->nCap = pVec->nCap; p->pArray = pVec->pArray; @@ -156,8 +156,8 @@ Msat_IntVec_t * Msat_IntVecDupArray( Msat_IntVec_t * pVec ) ***********************************************************************/ void Msat_IntVecFree( Msat_IntVec_t * p ) { - FREE( p->pArray ); - FREE( p ); + ABC_FREE( p->pArray ); + ABC_FREE( p ); } /**Function************************************************************* @@ -297,7 +297,7 @@ void Msat_IntVecGrow( Msat_IntVec_t * p, int nCapMin ) { if ( p->nCap >= nCapMin ) return; - p->pArray = REALLOC( int, p->pArray, nCapMin ); + p->pArray = ABC_REALLOC( int, p->pArray, nCapMin ); p->nCap = nCapMin; } diff --git a/src/sat/proof/pr.c b/src/sat/proof/pr.c index 2d1ab2d1..a951071a 100644 --- a/src/sat/proof/pr.c +++ b/src/sat/proof/pr.c @@ -24,6 +24,7 @@ #include #include //#include "vec.h" +#include "abc_global.h" #include "pr.h" //////////////////////////////////////////////////////////////////////// @@ -91,10 +92,6 @@ struct Pr_Man_t_ int timeTotal; }; -#ifndef PRT -#define PRT(a,t) printf("%s = ", (a)); printf("%6.2f sec\n", (float)(t)/(float)(CLOCKS_PER_SEC)) -#endif - // variable assignments static const lit LIT_UNDEF = 0xffffffff; @@ -143,7 +140,7 @@ Pr_Man_t * Pr_ManAlloc( int nVarsAlloc ) { Pr_Man_t * p; // allocate the manager - p = (Pr_Man_t *)malloc( sizeof(Pr_Man_t) ); + p = (Pr_Man_t *)ABC_ALLOC( char, sizeof(Pr_Man_t) ); memset( p, 0, sizeof(Pr_Man_t) ); // allocate internal arrays Pr_ManResize( p, nVarsAlloc? nVarsAlloc : 256 ); @@ -153,7 +150,7 @@ Pr_Man_t * Pr_ManAlloc( int nVarsAlloc ) p->nChunkSize = (1<<16); // use 64K chunks // verification p->nResLitsAlloc = (1<<16); - p->pResLits = malloc( sizeof(lit) * p->nResLitsAlloc ); + p->pResLits = ABC_ALLOC( lit, p->nResLitsAlloc ); // parameters p->fProofWrite = 0; p->fProofVerif = 0; @@ -183,13 +180,13 @@ void Pr_ManResize( Pr_Man_t * p, int nVarsNew ) while ( p->nVarsAlloc < nVarsNew ) p->nVarsAlloc *= 2; // resize the arrays - p->pTrail = (lit *) realloc( p->pTrail, sizeof(lit) * p->nVarsAlloc ); - p->pAssigns = (lit *) realloc( p->pAssigns, sizeof(lit) * p->nVarsAlloc ); - p->pSeens = (char *) realloc( p->pSeens, sizeof(char) * p->nVarsAlloc ); - p->pVarTypes = (char *) realloc( p->pVarTypes, sizeof(char) * p->nVarsAlloc ); - p->pReasons = (Pr_Cls_t **)realloc( p->pReasons, sizeof(Pr_Cls_t *) * p->nVarsAlloc ); - p->pWatches = (Pr_Cls_t **)realloc( p->pWatches, sizeof(Pr_Cls_t *) * p->nVarsAlloc*2 ); - // clean the free space + 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(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 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) ); @@ -215,20 +212,20 @@ void Pr_ManResize( Pr_Man_t * p, int nVarsNew ) void Pr_ManFree( Pr_Man_t * p ) { printf( "Runtime stats:\n" ); -PRT( "Reading ", p->timeRead ); -PRT( "BCP ", p->timeBcp ); -PRT( "Trace ", p->timeTrace ); -PRT( "TOTAL ", p->timeTotal ); +ABC_PRT( "Reading ", p->timeRead ); +ABC_PRT( "BCP ", p->timeBcp ); +ABC_PRT( "Trace ", p->timeTrace ); +ABC_PRT( "TOTAL ", p->timeTotal ); Pr_ManMemoryStop( p ); - free( p->pTrail ); - free( p->pAssigns ); - free( p->pSeens ); - free( p->pVarTypes ); - free( p->pReasons ); - free( p->pWatches ); - free( p->pResLits ); - free( p ); + 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************************************************************* @@ -348,7 +345,7 @@ char * Pr_ManMemoryFetch( Pr_Man_t * p, int nBytes ) char * pMem; if ( p->pChunkLast == NULL || nBytes > p->nChunkSize - p->nChunkUsed ) { - pMem = (char *)malloc( p->nChunkSize ); + pMem = (char *)ABC_ALLOC( char, p->nChunkSize ); *(char **)pMem = p->pChunkLast; p->pChunkLast = pMem; p->nChunkUsed = sizeof(char *); @@ -375,8 +372,8 @@ void Pr_ManMemoryStop( Pr_Man_t * p ) if ( p->pChunkLast == NULL ) return; for ( pMem = p->pChunkLast; pNext = *(char **)pMem; pMem = pNext ) - free( pMem ); - free( pMem ); + ABC_FREE( pMem ); + ABC_FREE( pMem ); } /**Function************************************************************* @@ -1124,7 +1121,7 @@ Pr_Man_t * Pr_ManProofRead( char * pFileName ) } // read the file - pBuffer = (char *)malloc( (1<<16) ); + pBuffer = (char *)ABC_ALLOC( char, (1<<16) ); for ( Counter = 0; fgets( pBuffer, (1<<16), pFile ); ) { if ( pBuffer[0] == 'c' ) @@ -1139,7 +1136,7 @@ Pr_Man_t * Pr_ManProofRead( char * pFileName ) printf( "Wrong input file format.\n" ); } p = Pr_ManAlloc( nVars ); - pArray = (int *)malloc( sizeof(int) * (nVars + 10) ); + pArray = (int *)ABC_ALLOC( char, sizeof(int) * (nVars + 10) ); continue; } // skip empty lines @@ -1178,8 +1175,8 @@ Pr_Man_t * Pr_ManProofRead( char * pFileName ) printf( "Expected %d clauses but read %d.\n", nClauses, Counter ); // finish - if ( pArray ) free( pArray ); - if ( pBuffer ) free( pBuffer ); + if ( pArray ) ABC_FREE( pArray ); + if ( pBuffer ) ABC_FREE( pBuffer ); fclose( pFile ); return p; } diff --git a/src/sat/proof/pr.h b/src/sat/proof/pr.h index 1e71a2d3..bc55e016 100644 --- a/src/sat/proof/pr.h +++ b/src/sat/proof/pr.h @@ -21,10 +21,6 @@ #ifndef __PR_H__ #define __PR_H__ -#ifdef __cplusplus -extern "C" { -#endif - #ifdef _WIN32 #define inline __inline // compatible with MS VS 6.0 #endif @@ -37,6 +33,10 @@ extern "C" { /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +extern "C" { +#endif + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3