DIRECTORY Convert, Rope, SC, SCInstUtil, SCInitialPlace, SCPlaceUtil, SCPrivate, SCRowUtil, TerminalIO; SCInitialPlaceImpl: CEDAR PROGRAM IMPORTS Convert, Rope, SC, SCInstUtil, SCPlaceUtil, SCRowUtil, TerminalIO EXPORTS SCInitialPlace SHARES SC = { PosInitBp: PROCEDURE[handle: SC.Handle, side: SC.Side] = { PreAssign: SCRowUtil.EachInstProc = { Check: SCRowUtil.EachInstProc = { otherPos: SCPrivate.ZMaxPosSr _ instance.fnlPos; IF curPos = otherPos THEN { TerminalIO.PutRope[Rope.Cat[" Two instances have same position: ", firstInst.name, " and ", instance.name]]; TerminalIO.PutRope[Rope.Cat["\n pos = ", Convert.RopeFromInt[firstPos], "\n"]]}}; firstInst: SCPrivate.Instance _ instance; firstPos: SCPrivate.ZMaxPosSr _ pos; curPos: SCPrivate.ZMaxPosSr _ firstInst.fnlPos; IF curPos > 0 THEN [] _ SCRowUtil.EnumerateInstsOnSide[handle, side, firstPos +1, bpRow.nBpsOnSide, Check]}; Sort: SCRowUtil.EachInstProc = { InnerSort: SCRowUtil.EachInstProc = { IF instance.fnlPos < firstInst.fnlPos THEN { bpRow.bpsOnSide[firstPos] _ instance; bpRow.bpsOnSide[pos] _ firstInst}}; firstInst: SCPrivate.Instance _ instance; firstPos: SCPrivate.ZMaxPosSr _ pos; [] _ SCRowUtil.EnumerateInstsOnSide[handle, side, firstPos +1, bpRow.nBpsOnSide, InnerSort]}; FixUp: SCRowUtil.EachInstProc = { instance _ bpRow.bpsOnSide[pos]; instance.curPos _ pos}; layoutData: SCPrivate.LayoutData _ NARROW[handle.layoutData]; bpRow: SCPrivate.BpRow _ layoutData.bpRows[side]; IF bpRow.fnlBpFxd OR bpRow.initBpFxd THEN { [] _ SCRowUtil.EnumerateAllInstsOnSide[handle, side, PreAssign]; [] _ SCRowUtil.EnumerateAllInstsOnSide[handle, side, Sort]; [] _ SCRowUtil.EnumerateAllInstsOnSide[handle, side, FixUp]} ELSE {-- positions on side were not specified assign positions [] _ SCRowUtil.EnumerateAllInstsOnSide[handle, side, FixUp]}; SCInstUtil.BpOffsets[handle, side, 0, SCPrivate.maxPos]}; PosInitLg: PROCEDURE[handle: SC.Handle, row: SCPrivate.MaxRowSr] = { PreAssign: SCRowUtil.EachInstProc = { Check: SCRowUtil.EachInstProc = { otherPos: SCPrivate.ZMaxPosSr _ instance.fnlPos; IF curPos = otherPos THEN { TerminalIO.PutRope[Rope.Cat[" Two instances have same position: ", firstInst.name, " and ", instance.name]]; TerminalIO.PutRope[Rope.Cat["\n pos = ", Convert.RopeFromInt[curPos], "\n"]]}}; firstInst: SCPrivate.Instance _ instance; firstPos: SCPrivate.ZMaxPosSr _ pos; curPos: SCPrivate.ZMaxPosSr _ firstInst.fnlPos; IF curPos > 0 THEN [] _ SCRowUtil.EnumerateInstsOnRow[handle, row, firstPos +1, lgRow.nLgsOnRow, Check]}; Sort: SCRowUtil.EachInstProc = { InnerSort: SCRowUtil.EachInstProc = { IF instance.fnlPos < firstInst.fnlPos THEN { lgRow.lgsOnRow[firstPos] _ instance; lgRow.lgsOnRow[pos] _ firstInst}}; firstInst: SCPrivate.Instance _ instance; firstPos: SCPrivate.ZMaxPosSr _ pos; [] _ SCRowUtil.EnumerateInstsOnRow[handle, row, firstPos +1, lgRow.nLgsOnRow, InnerSort]}; FixUp: SCRowUtil.EachInstProc = { instance _ lgRow.lgsOnRow[pos]; instance.curPos _ pos}; layoutData: SCPrivate.LayoutData _ NARROW[handle.layoutData]; lgRow: SCPrivate.LgRow _ layoutData.lgRows.rows[row]; IF lgRow.fnlLgFxd OR lgRow.initLgFxd THEN { [] _ SCRowUtil.EnumerateAllInstsOnRow[handle, row, PreAssign]; [] _ SCRowUtil.EnumerateAllInstsOnRow[handle, row, Sort]; [] _ SCRowUtil.EnumerateAllInstsOnRow[handle, row, FixUp]} ELSE { -- positions on row were not specified assign positions [] _ SCRowUtil.EnumerateAllInstsOnRow[handle, row, FixUp]}; SCInstUtil.LgOffsets[handle, row, 0, SCPrivate.maxPos]}; PosInit: PUBLIC PROCEDURE [handle: SC.Handle] = { DoRow: SCRowUtil.EachRowProc = { PosInitLg[handle, row]}; [] _ SCRowUtil.EnumerateRows[handle, DoRow]; PosInitBp[handle, bottom]; PosInitBp[handle, top]}; RowInit: PUBLIC PROCEDURE [handle: SC.Handle] = { NextUnplaced: PROCEDURE [handle: SC.Handle] RETURNS [inst: SCPrivate.Instance _ NIL] = { EachInstance: SCInstUtil.EachInstanceProc = { SELECT instance.whichClass FROM logic => IF instance.curRow = 0 THEN inst _ instance; io => IF instance.curSide = none THEN inst _ instance; ENDCASE; quit _ inst = instance}; [] _ SCInstUtil.EnumerateAllInstances[handle, EachInstance]}; RowPlacInit: PROCEDURE [handle: SC.Handle, instance: SCPrivate.Instance] = { PutRow: SCRowUtil.EachRowProc = { IF lgRow.size.p <= minRowLength THEN IF ~lgRow.fnlLgFxd THEN {minRow _ row; minRowLength _ lgRow.size.p; useRow _ row}}; minRow, useRow: SCPrivate.ZMaxRowSr _ 0; minRowLength: SC.Number _ LAST[INT]; [] _ SCRowUtil.EnumerateRows[handle, PutRow]; IF useRow = 0 THEN {SC.Signal[callingError, Rope.Cat["no valid row to place instance: ", instance.name, "\n"]]; useRow _ 1}; SCPlaceUtil.PutLgRow[handle, instance, useRow]}; SidePlacInit: PROCEDURE [handle: SC.Handle, instance: SCPrivate.Instance] = { PutSide: SCRowUtil.EachSideProc = { IF bpRow.nBpsOnSide <= minSideLength THEN IF ~bpRow.fnlBpFxd AND bpRow.nBpsOnSide < bpRow.maxBpsOnSide THEN {minSide _ side; minSideLength _ bpRow.nBpsOnSide; useSide _ side}}; minSide, useSide: SC.SideOrNone _ none; minSideLength: SC.Number _ LAST[INT]; [] _ SCRowUtil.EnumerateSides[handle, PutSide]; IF useSide = none THEN {SC.Signal[callingError, Rope.Cat["no valid side to place instance: ", instance.name, "\n"]]; useSide _ left}; SCPlaceUtil.PutBpSide[handle, instance, useSide]}; FOR instance: SCPrivate.Instance _ NextUnplaced[handle], NextUnplaced[handle] WHILE instance # NIL DO IF instance.whichClass = logic THEN RowPlacInit[handle, instance] ELSE IF instance.whichClass = io THEN SidePlacInit[handle, instance]; ENDLOOP; PosInitBp[handle, left]; PosInitBp[handle, right]}; }. Xfile: SCInitialPlaceImpl.mesa Last Edited by: Preas, December 21, 1986 3:46:20 pm PST position instances on specified side see if positions have been pre assigned check if pre-assignments are valid now sort based on fnlPos now fix up curbppos, they might not be sequential this should be replaced with a more sophisticated version position instances on specified row see if positions have been pre assigned check if pre-assignments are valid now sort based on fnllgpos now fix up curlgpos, they might not be sequential this should be replaced with a more sophisticated version assign the logic row positions now the top and bottom bp sides the left and right side bp positions were assigned in rowinit RowInit place instances that were not preplaced preplace the left and right sides, the top and bottom sides are placed in PosInit ʸ˜šœ™J™7J™—šÏk ˜ JšœœL˜]J˜—šœœ˜!Jšœœ0˜IJšœ˜Jšœœ˜ J˜Jšœ%™%šÏn œ œ œœ ˜:J˜šœ%˜%šœ!˜!Jšœ0˜0šœœ˜Jšœm˜mJšœQ˜Q—J˜—Jšœ)˜)Jšœ$˜$Jšœ/˜/šœ œ˜JšœY˜Y—J˜—šœ ˜ šœ%˜%šœ$œ˜,Jšœ%˜%Jšœ#˜#—J˜—Jšœ)˜)Jšœ$˜$Jšœ]˜]J˜—šœ!˜!Jšœ ˜ Jšœ˜J˜—Jšœ#œ˜=J˜1J˜Jšœ(™(šœœœ˜+Jšœ#™#Jšœ@˜@J™Jšœ™Jšœ;˜;J˜Jšœ2™2Jšœ<˜<—J˜šœÏc9˜?J™Jšœ9™9Jšœ=˜=—J˜Jšœ9˜9—J˜Jšœ$™$šž œ œ œ%˜DJ˜šœ%˜%šœ!˜!Jšœ0˜0šœœ˜Jšœm˜mJšœO˜O—J˜—Jšœ)˜)Jšœ$˜$Jšœ/˜/šœ œ˜JšœV˜V—J˜—šœ ˜ šœ%˜%šœ$œ˜,Jšœ$˜$Jšœ"˜"——J˜Jšœ)˜)Jšœ$˜$JšœZ˜ZJ˜—šœ!˜!Jšœ˜Jšœ˜J˜—Jšœ#œ˜=Jšœ5˜5J˜Jšœ(™(Jšœœœ˜+˜Jšœ#™#Jšœ>˜>J˜Jšœ™Jšœ9˜9J™Jšœ2™2Jšœ:˜:—J˜šœŸ7˜>J™Jšœ9™9Jšœ;˜;—J˜Jšœ8˜8—J˜šžœœ œ œ ˜1J˜Jšœ™šœ ˜ Jšœ˜J˜—Jšœ,˜,J˜Jšœ™Jšœ>™>Jšœ˜Jšœ˜—J˜šžœœ œ œ ˜2J˜J˜š ž œ œ œ œœ˜X˜-codešœ˜Kšœ œœ˜5Kšœœœ˜6Kšœ˜—K˜—Jšœ=˜=J˜—J˜šž œ œ œ*˜LJ˜˜!šœ˜$šœ˜Jšœ+˜+Jšœ˜——J˜—Jšœ(˜(Jšœœ œœ˜$J˜Jšœ-˜-J˜šœ ˜Jšœ\˜\Jšœ ˜ —Jšœ0˜0—J˜šž œ œ œ*˜MJ˜˜#šœ#˜)šœœ'˜AJšœ2˜2Jšœ˜——J˜—Jšœœ˜'Jšœœ œœ˜%J˜Jšœ/˜/J˜šœ˜šœF˜FJšœ˜—Jšœ˜—šœ2˜2J˜——Jšœ™Jšœ'™'šœKœ œ˜eJšœœ˜AJšœœœ ˜EJš˜—J˜JšœQ™QJ˜Jšœ˜—Jšœ˜J˜——…—Òâ