DIRECTORY OrderedRefArray, IPCoTab, IPTop, IPTopOps, IPPlaceKit, IPPlaceProcs; IPPlaceProcsImpl: CEDAR PROGRAM IMPORTS OrderedRefArray, IPCoTab, IPTop, IPTopOps, IPPlaceKit EXPORTS IPPlaceProcs = BEGIN OPEN IPPlaceProcs; PlaceInit: PUBLIC PROC [ top: IPTop.Ref, orderingFn: IPPlaceKit.OrderingFn, trialsGen: IPPlaceKit.PlaceCompTGen, placeEval: IPPlaceKit.PlaceEvaluator, results: OrderedRefArray.Ref] ={ comps: IPPlaceKit.Components; depthAndBreadthList: LIST OF IPPlaceKit.DepthBreadthRec; placeRecursively: PROC[comps: IPPlaceKit.Components, dbList: LIST OF IPPlaceKit.DepthBreadthRec, prevStkSize: NAT] ={ dAndb: IPPlaceKit.DepthBreadthRec _ dbList.first; compsHd: IPPlaceKit.Components; IF placeEval[top, comps, OrderedRefArray.GetPruneValue[results]].prune THEN RETURN; [compsHd, comps] _ IPPlaceKit.CopyCompsHead[comps, dAndb.depth]; dbList _ dbList.rest; IF comps = NIL OR dbList.first.depth = 0 THEN PlaceComps[top, compsHd, trialsGen, placeEval, results, 0] ELSE { trials: OrderedRefArray.Ref _ OrderedRefArray.Create[dAndb.breadth]; eachTrialAction: OrderedRefArray.EachItemAction ={ IPTopOps.Redo[top, NARROW[item]]; placeRecursively[comps, dbList, IPTopOps.StackSize[top]]; [] _ IPTopOps.Undo[top, IPTopOps.StackSize[top] - prevStkSize]; --undo Redo }; --eachTrialAction PlaceComps[top, compsHd, trialsGen, placeEval, trials, prevStkSize]; OrderedRefArray.Enumerate[trials, eachTrialAction]; }; }; --placeRecursively [comps, depthAndBreadthList] _ orderingFn[top]; IF IPTop.NoTopology[top] THEN { IF IPCoTab.CountComponents[top.coTab].active = 0 THEN [] _ IPTopOps.SetComponent[top, comps.first, TRUE, [0,0], TRUE]; [] _ IPTop.ReDefineChs[top]; IPTop.Geometrize[top]; comps _ comps.rest; depthAndBreadthList.first.depth _ depthAndBreadthList.first.depth.PRED }; placeRecursively[comps, depthAndBreadthList, IPTopOps.StackSize[top]]; }; --PlaceInit PlaceImprove: PUBLIC PROC[ top: IPTop.Ref, remove, numbOfTrials: NAT, removeTGen: IPPlaceKit.RemoveCompTGen, removeEval: IPPlaceKit.RemoveEvaluator, placeTGen: IPPlaceKit.PlaceCompTGen, placeEval: IPPlaceKit.PlaceEvaluator, results: OrderedRefArray.Ref ] = { startStkSize: NAT _ IPTopOps.StackSize[top]; removalTrials: OrderedRefArray.Ref _ OrderedRefArray.Create[numbOfTrials]; eachRemoveTrialAction: OrderedRefArray.EachItemAction ={ track: LIST OF REF _ NARROW[item]; comps: IPPlaceKit.Components _ IPPlaceKit.GetComponents[track]; IPTopOps.Redo[top, track]; IF placeEval[top, comps, OrderedRefArray.GetPruneValue[results]].prune THEN NULL ELSE PlaceComps[top, comps, placeTGen, placeEval, results, 0]; [] _ IPTopOps.Undo[top, IPTopOps.StackSize[top] - startStkSize]; }; --eachRemoveTrialAction RemoveComps[top, remove, removeTGen, removeEval, removalTrials, startStkSize]; OrderedRefArray.Enumerate[removalTrials, eachRemoveTrialAction]; }; --PlaceImprove PlaceComps: PUBLIC PROC[top: IPTop.Ref, comps: LIST OF IPCoTab.Component, trialsGen: IPPlaceKit.PlaceCompTGen, placeEval: IPPlaceKit.PlaceEvaluator, results: OrderedRefArray.Ref, resultsAfter: NAT] = { startStkSize: NAT _ IPTopOps.StackSize[top]; trials: OrderedRefArray.Ref _ trialsGen[top, comps]; eachTrialAction: OrderedRefArray.EachItemAction ={ IPPlaceKit.Execute[top, item]; IF comps = NIL THEN OrderedRefArray.Insert[results, IPTopOps.GetTrack[top, resultsAfter], placeEval[top, NIL].value] ELSE IF placeEval[top, comps, OrderedRefArray.GetPruneValue[results]].prune THEN NULL --not fruitful ELSE PlaceComps[top, comps, trialsGen, placeEval, results, resultsAfter]; [] _ IPTopOps.Undo[top, IPTopOps.StackSize[top] - startStkSize]; }; --eachTrialAction comps _ comps.rest; OrderedRefArray.Enumerate[trials, eachTrialAction] }; --PlaceComps RemoveComps: PUBLIC PROC[ top: IPTop.Ref, numb: NAT, trialsGen: IPPlaceKit.RemoveCompTGen, removeEval: IPPlaceKit.RemoveEvaluator, results: OrderedRefArray.Ref, resultsAfter: NAT _ 0 ] ={ startStkSize: NAT _ IPTopOps.StackSize[top]; trials: OrderedRefArray.Ref _ trialsGen[top, numb]; eachTrialAction: OrderedRefArray.EachItemAction ={ IPPlaceKit.Execute[top, item]; IF numb = 0 THEN OrderedRefArray.Insert[results, IPTopOps.GetTrack[top, resultsAfter], removeEval[top, 0].value] ELSE IF removeEval[top, numb, OrderedRefArray.GetPruneValue[results]].prune THEN NULL ELSE RemoveComps[top, numb, trialsGen, removeEval, results, resultsAfter]; [] _ IPTopOps.Undo[top, IPTopOps.StackSize[top] - startStkSize]; }; --eachTrialAction numb _ numb.PRED; OrderedRefArray.Enumerate[trials, eachTrialAction] }; --RemoveComps END. `--File: IPPlaceProcsImpl.mesa Last Edited by: CSChow, January 25, 1985 12:34:38 pm PST --(1) Order the nonActive components in placement order --(2) If assembly has no channels define channels, insert a component if necessary --(3) Do placement recursively --(1) Remove the needed number of components --(2) Try PlaceComps on each remove trial Κ’˜Jšœ™J™8J™codešΟk ˜ Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ K˜ Kšœ ˜ —K˜šœœœ˜ Kšœ7˜>Kšœœœ˜/K˜šΟn œœœ˜Kšœ˜Kšœ#˜#Kšœ%˜%Kšœ&˜&Kšœ ˜ K˜Kšœ˜Kšœœœ˜8š œœ'œœ*œ˜uKšœ1˜1Kšœ˜KšœEœœ˜SKšœ@˜@Kšœ˜šœ œœ˜(Kšœ;˜?šœ˜KšœD˜Dšœ2˜2Kšœœ˜!Kšœ9˜9Kšœ@Οc ˜KKšœŸ˜—KšœD˜DKšœ3˜3Kšœ˜——KšœŸ˜—K˜K™7Kšœ/˜/K˜K™Sšœœ˜šœ/˜1Kšœ.œ œ˜E—Kšœ˜K˜K˜KšœB˜FKšœ˜—K˜K™KšœF˜FKšœŸ ˜—K˜šž œœœ˜Kšœ˜Kšœ˜Kšœœ˜Kšœ&˜&Kšœ'˜'Kšœžœ˜$Kšœ%˜%Kšœ˜Kšœ˜K˜Kšœœ˜,KšœJ˜Jšœ8˜8Kš œœœœœ˜"Kšœ?˜?K˜Kšœ˜šœE˜GKšœ˜ Kšœ:˜>—Kšœ@˜@KšœŸ˜—K˜K™,KšœN˜NK˜Kšœ ž œ™)Kšœ@˜@KšœŸ˜—K˜š ž œœœœœ‹œ˜ΙKšœœ˜,Kšœ4˜4šœ2˜2Kšœ˜šœ œ˜KšœVœ˜ešœ˜šœD˜FKšœœŸ˜KšœE˜I———Kšœ@˜@KšœŸ˜—K˜Kšœ2˜2KšœŸ ˜—K˜K˜šž œ œ˜Kšœ˜Kšœœ˜ Kšœ%˜%Kšœ'˜'Kšœ˜Kšœœ˜Kšœ˜K˜Kšœœ˜,Kšœ3˜3šœ2˜2Kšœ˜šœ ˜ Kšœ`˜dšœ˜šœD˜FKšœ˜ KšœF˜J———Kšœ@˜@KšœŸ˜—Kšœ œ˜Kšœ2˜2KšœŸ ˜—K˜Kšœ˜—J˜—…—¨š