DIRECTORY AbSets, BiRelBasics, BiRels, Convert, FS, IntStuff, IO, LichenDataOps, LichenDataStructure, Rope, SetBasics; LichenImplNaming: CEDAR PROGRAM IMPORTS AbSets, BiRelBasics, BiRels, Convert, IntStuff, LichenDataOps, LichenDataStructure, Rope, SetBasics EXPORTS LichenDataOps = BEGIN OPEN IS:IntStuff, Sets:AbSets, LichenDataStructure, LichenDataOps; Break: SIGNAL ~ CODE; PrefixifyDesign: PUBLIC PROC [design: Design] ~ { design.cellTypes.EnumA[PrefixifyCellType]; RETURN}; CleanupDesignNames: PUBLIC PROC [d: Design] ~ { CleanupPerType: PROC [ctv: Sets.Value] RETURNS [BOOL] ~ { ct: CellType ~ NARROW[ctv.VA]; CleanupCT[ct, p]; IF ct.asu#NIL THEN CleanupCT[ct, w]; RETURN [FALSE]}; IF d.cellTypes.Scan[CleanupPerType].found THEN ERROR; RETURN}; CollapseDesign: PROC [d: Design] ~ { CollapsePerType: PROC [ctv: Sets.Value] RETURNS [BOOL] ~ { ct: CellType ~ NARROW[ctv.VA]; CollapseCT[ct, p]; IF ct.asu#NIL THEN CollapseCT[ct, w]; RETURN [FALSE]}; IF d.cellTypes.Scan[CollapsePerType].found THEN ERROR; RETURN}; noIntPart: INT ~ -1; fixSet: Set--{noIntPart, 1}-- ~ Sets.CreateList[vals: LIST[IV[noIntPart], IV[1]], space: SetBasics.ints, mutability: constant, order: Sets.fwd]; noIntSet: Set ~ Sets.CreateSingleI[noIntPart, SetBasics.ints]; ref0: REF INT ~ NEW [INT _ 0]; name0: SteppyName ~ OSn[ref0]; breakICT: CellType _ NIL; breakPortName: SteppyName _ noName; PrefixifyCellType: PROC [cta: REF ANY] ~ { ct: CellType ~ NARROW[cta]; PrefixifyCellTypesClass[ct, p]; IF ct.asu#NIL THEN PrefixifyCellTypesClass[ct, w]; RETURN}; PrefixifyCellTypesClass: PROC [ct: CellType, class: PWClass] ~ { d: Design ~ ct.d; parsed: BiRel--Steppy X INT-- ~ BiRels.GenCreate[spaces: [steppyNameSpace, SetBasics.ints], mappable: [TRUE, FALSE], hints: [[fn: [$Hash], set: [$Vector]], []]]; dotted: Fn--Steppy _ {$T, $F}-- ~ BiRels.CreateHashTable[[steppyNameSpace, SetBasics.refs]]; sfxposes: Fn--Steppy _ INT-- ~ BiRels.CreateHashTable[[steppyNameSpace, SetBasics.ints]]; FixIt: PROC [it: PW, prefix: SteppyName] ~ { subscripts: Set--of INT-- ~ parsed.Mapping[SnV[prefix]]; old: SteppyName ~ prefix; new: SteppyName ~ old.SNCat[name0]; IF NOT subscripts.Equal[fixSet] THEN ERROR; ReplaceDescendantsName[ct, it, old, new]; RETURN}; <> NoteNaming: PROC [pair: BiRels.Pair] RETURNS [BOOL] ~ { sn: SteppyName ~ VSn[pair[right]]; IF sn.grade.gend THEN RETURN [FALSE]; {snx: SteppyNameSplit ~ SplitSteppy[sn]; name: ROPE ~ snx.lastRope; namelen: INT ~ name.Length[]; sepPos: INT ~ name.SkipTo[skip: "!_"]; dotPos: INT _ name.FindBackward["."]; endPos: INT _ dotPos+1; hasDot: BOOL _ FALSE; IF dotPos>0 THEN endPos _ name.SkipOver[dotPos+1, "0123456789"]; IF endPos>dotPos+1 THEN hasDot _ TRUE ELSE { dotPos _ SkipOverBackwardDigits[name, sepPos-1]; endPos _ sepPos}; { sfxPos: INT ~ dotPos + (IF hasDot THEN 0 ELSE 1); IF sfxPos < endPos THEN { ohne: ROPE ~ name.Replace[start: sfxPos, len: endPos-sfxPos, with: NIL]; intPart: INT ~ Convert.IntFromRope[name.Substr[dotPos+1, endPos-dotPos-1]]; IF intPart<0 THEN ERROR; IF ohne.Length[]=0 THEN ERROR; {squzd: SteppyName ~ UnsplitSteppy[[snx.pre, ohne, snx.post]]; IF dotted.AddPair[[SnV[squzd], AV[IF hasDot THEN $T ELSE $F]]].had[leftToRight] = different THEN ERROR; IF sfxposes.AddPair[[SnV[squzd], IV[sfxPos]]].had[leftToRight]=different THEN ERROR; [] _ parsed.AddPair[[SnV[squzd], IV[intPart]]]; RETURN [FALSE]}} ELSE { [] _ parsed.AddPair[[SnV[sn], IV[noIntPart]]]; RETURN [FALSE]}; }}}; Recon: PROC [prefv: Sets.Value] RETURNS [BOOL] ~ { sn: SteppyName ~ VSn[prefv]; snx: SteppyNameSplit ~ SplitSteppy[sn]; prefix: ROPE ~ snx.lastRope; sufixs: Set ~ parsed.Mapping[prefv]; IF sufixs.Equal[noIntSet] THEN RETURN [FALSE]; {sfxPos: INT ~ sfxposes.Apply[prefv].MI; hasDot: BOOL ~ SELECT dotted.Apply[prefv].MA FROM $F => FALSE, $T => TRUE, ENDCASE => ERROR; dot: ROPE ~ IF hasDot THEN "." ELSE NIL; PerSuffix: PROC [sufv: Sets.Value] RETURNS [BOOL] ~ { intPart: INT ~ sufv.VI; IF intPart=noIntPart THEN { x: PW ~ FetchPW[ct, class, sn]; IF x=NIL THEN ERROR; FixIt[x, sn]; RETURN [FALSE]} ELSE { newsn: SteppyName ~ sn.SNCat[OSn[NewInt[intPart]]]; oldsn: SteppyName _ noName; x: PW _ NIL; FOR intRope: ROPE _ Convert.RopeFromInt[intPart], Rope.Concat["0", intRope] WHILE x=NIL AND intRope.Length[]<5 DO oldr: ROPE ~ prefix.Replace[start: sfxPos, len: 0, with: dot.Concat[intRope]]; oldsn _ UnsplitSteppy[[snx.pre, oldr, snx.post]]; x _ FetchPW[ct, class, oldsn]; ENDLOOP; IF x=NIL THEN ERROR; ReplaceDescendantsName[ct, x, oldsn, newsn]; RETURN [FALSE]}; }; IF (NOT hasDot) AND sufixs.Size.EN> IF ct.fullName[class].Scan[NoteNaming].found THEN ERROR; IF parsed.SetOn[left].Scan[Recon].found THEN ERROR; RETURN}; thresh: NAT _ 6; FetchPW: PROC [ct: CellType, class: PWClass, fullName: SteppyName] RETURNS [PW] ~ INLINE {RETURN [NARROW[ct.fullName[class].InvApply[SnV[fullName]].MDA]]}; SkipOverBackwardDigits: PROC [s: ROPE, pos: INT] RETURNS [INT] ~ { FOR pos _ pos, pos-1 WHILE pos>=0 AND s.InlineFetch[pos] IN ['0..'9] DO NULL ENDLOOP; RETURN [pos]}; SteppyNameSplit: TYPE ~ RECORD [pre: SteppyName, lastRope: ROPE, post: SteppyName]; SplitSteppy: PROC [sn: SteppyName] RETURNS [snx: SteppyNameSplit] ~ { IF sn.grade.nonsubs<1 THEN ERROR; snx _ [noName, NIL, sn]; DO WITH snx.post.steps.first SELECT FROM x: ROPE => IF snx.post.grade.nonsubs=1 THEN EXIT ELSE snx.post.grade.nonsubs _ snx.post.grade.nonsubs-1; x: REF INT => snx.post.grade.subs _ snx.post.grade.subs-1; ENDCASE => ERROR; snx.post.steps _ snx.post.steps.rest; ENDLOOP; snx.lastRope _ NARROW[snx.post.steps.first]; snx.pre _ LSn[CopyTill[sn.steps, snx.post.steps].head]; snx.post _ snx.post.SNTail; RETURN}; UnsplitSteppy: PROC [snx: SteppyNameSplit] RETURNS [SteppyName] ~ {RETURN snx.pre.SNCat[OSn[snx.lastRope].SNCat[snx.post]]}; refEmpty: REF ANY ~ BiRels.CreateEmptyBiRel[ALL[steppyNameSpace]].Refify[]; InheritNames: PUBLIC PROC [design: Design, cleanup, collapse: BOOL, renames: Fn--CellType _ Fn(old steppy _ new)--] ~ { Subject: TYPE ~ REF ANY --actuall, UNION [Vertex, Port, CellType]--; inherited: Set--of CellType-- ~ Sets.CreateHashSet[design.eSpace]; WorkToCT: PROC [cta: REF ANY] ~ {Ensure[NARROW[cta]]; RETURN}; Ensure: PROC [ct: CellType] ~ { rns: Fn--old steppy _ new-- ~ BiRels.DeRef[renames.ApplyA[ct].MDA[refEmpty]]; rnDom: Set ~ rns.SetOn[left]; InheritFromCI: PROC [civ: Sets.Value] ~ { ci: CellInstance ~ NARROW[civ.VA]; ict: CellType ~ design.CiT[ci]; ciNames: Set--of SteppyName-- ~ ct.INames[ci]; dumed: Set _ ciNames.Intersection[rnDom]; InheritAlongConnection: PROC [porta, wirea: REF ANY] ~ { port: Port ~ NARROW[porta]; wire: Wire ~ NARROW[wirea]; portNames: Set ~ ict.PNames[port]; IF ict=breakICT AND portNames.HasMember[SnV[breakPortName]] THEN Break[]; KnowVertexNames[ct, wire, ActualNames[design.labelCellTypes.HasMemA[ict], ciNames, portNames], TRUE]; RETURN}; IF ict.asTrans#NIL THEN RETURN; Ensure[ict]; IF dumed.NonEmpty THEN { new: Set ~ rns.Image[dumed _ dumed.CreateHashCopy[]].CreateHashCopy[]; ForgetPartNames[ct, i, ci, dumed]; KnowPartNames[ct, i, ci, new, TRUE]; ct _ ct}; ci.conns.EnumAA[InheritAlongConnection]; RETURN}; UnorganizedInheritToPort: PROC [portv: Sets.Value] ~ { port: Port ~ NARROW[portv.VA]; wire: Wire ~ ConndWire[ct, port]; IF wire#NIL THEN KnowPortNames[ct, port, ct.WNames[wire], TRUE]; RETURN}; IF NOT inherited.AddA[ct] THEN RETURN; IF ct.asu#NIL THEN { wrens: LIST OF RECORD [w: Wire, old, new: SteppyName] _ NIL; FindRen: PROC [pair: BiRels.Pair] RETURNS [BOOL] ~ { w: Wire ~ NARROW[pair[left].VA]; old: SteppyName ~ VSn[pair[right]]; new: SteppyName ~ VSn[rns.Apply[pair[right]].Val]; wrens _ CONS[[w, old, new], wrens]; RETURN [FALSE]}; design.cct[i].EnumerateMapping[AV[ct], InheritFromCI, rightToLeft]; IF ct.fullName[w].ScanHalfRestriction[rnDom, FindRen, right].found THEN ERROR; WHILE wrens # NIL DO ReplaceDescendantsName[ct, wrens.first.w, wrens.first.old, wrens.first.new]; wrens _ wrens.rest; ENDLOOP; IF cleanup THEN CleanupCT[ct, w]; IF collapse THEN CollapseCT[ct, w]; design.cct[p].EnumerateMapping[AV[ct], UnorganizedInheritToPort, rightToLeft]; IF cleanup THEN CleanupCT[ct, p]; IF collapse THEN CollapseCT[ct, p]; RETURN} ELSE IF ct.asArray#NIL THEN { a: Array ~ ct.asArray; ect: CellType ~ ct.EltType[]; ArrayInheritToPort: PROC [pair: BiRels.Pair] ~ { ap: Port ~ NARROW[pair[left].VA]; dw: DumbWire ~ NARROW[pair[right].VA]; aloc: BiRels.MaybePair ~ dw.eps.First[[[SetBasics.alleq, SetBasics.fwd], right]]; IF NOT aloc.found THEN RETURN; {ep: Port ~ NARROW[aloc.it[left].VA]; ai: Int2 ~ DecomposeAI[a, aloc.it[right].VI]; names: Set ~ ActualNames[FALSE, OneSteppy[AIName[a, ai]], ect.PNames[ep]]; IF design.labelCellTypes.HasMemA[ect] THEN ERROR; KnowPortNames[ct, ap, names, TRUE]; RETURN}}; Ensure[ect]; a.dumrep.apToWire.Enumerate[ArrayInheritToPort]; IF cleanup THEN CleanupCT[ct, p]; IF collapse THEN CollapseCT[ct, p]; RETURN}; RETURN}; IF design.inheritNames THEN ERROR; design.inheritNames _ TRUE; design.cellTypes.EnumA[WorkToCT]; RETURN}; CleanupCT: PROC [ct: CellType, class: PWClass] ~ { CleanupPart: PROC [part: Part] ~ { names: Set--of SteppyName-- ~ ct.PartNames[class, part]; IF names.Empty THEN RETURN; {best: SteppyName ~ VSn[names.First[].Val]; Remit: PROC [v: Sets.Value] RETURNS [BOOL] ~ { sn: SteppyName ~ VSn[v]; IF GrossSteppyNameGradeCompare[best.grade, sn.grade] < equal THEN [] _ names.RemElt[v]; RETURN [FALSE]}; IF best.grade.gend THEN RETURN; IF names.Scan[Remit].found THEN ERROR}}; ct.EnumCTParts[class, TRUE, TRUE, CleanupPart]; RETURN}; CollapseCT: PROC [ct: CellType, class: PWClass] ~ { bogon: CellInstance ~ NEW [VertexPrivate[i]]; tails: BiRel--part X tail-- ~ BiRels.GenCreate[ spaces: [ct.d.eSpace, steppyNameSpace], hints: [ leftToRight: [[$Hash], [$Hash]], rightToLeft: [[$BalancedTree], [$Hash]] ]]; AddTail: PROC [pair: BiRels.Pair] RETURNS [BOOL] ~ { part: Part ~ pair[left].VA; name: SteppyName _ VSn[pair[right]]; WHILE name.grade.nonsubs > 1 DO name _ name.SNTail; [] _ tails.AddPair[[AV[part], SnV[name]]]; ENDLOOP; RETURN [FALSE]}; AdoptTail: PROC [tv: Sets.Value] RETURNS [BOOL] ~ { nParts: LNAT ~ tails.MappingSize[tv, rightToLeft, IS.two].EN; IF nParts>1 THEN RETURN [FALSE]; IF nParts<1 THEN ERROR; {part: Part ~ tails.Apply[tv, rightToLeft].MA; fpart: Part ~ NARROW[ct.fullName[class].InvApply[tv].MDA]; IF fpart#NIL AND fpart#part THEN RETURN [FALSE]; {tail: SteppyName ~ VSn[tv]; names: Set ~ ct.fullName[class].MappingA[part]; pretails: Set ~ PreTails[tail]; IF NOT names.RemFilter[pretails].hadSome THEN ERROR; KnowPartName[ct, class, part, tail, FALSE]; RETURN [FALSE]}}}; IF ct.fullName[class].Scan[AddTail].found THEN ERROR; IF tails.SetOn[right].Scan[AdoptTail, Sets.bwd].found THEN ERROR; RETURN}; GlobalizeCT: PROC [ct: CellType] ~ { GlobalizeClass[ct, p]; IF ct.fullName[w] # nilBiRel THEN GlobalizeClass[ct, w]; RETURN}; GlobalizeClass: PROC [ct: CellType, class: PWClass] ~ { d: Design ~ ct.d; fn: BiRel ~ ct.fullName[class]; GlobalizePair: PROC [pair: BiRels.Pair] RETURNS [BOOL] ~ { sn: SteppyName _ VSn[pair[right]]; IF sn.grade.global THEN RETURN [FALSE]; sn.grade.global _ TRUE; [] _ fn.RemPair[pair]; [] _ fn.AddPair[[pair[left], SnV[sn]]]; RETURN [FALSE]}; IF fn.Scan[GlobalizePair].found THEN ERROR; RETURN}; END. \LichenImplNaming.Mesa Last tweaked by Mike Spreitzer on April 12, 1989 1:50:13 am PDT Κb– "cedar" style˜code™Kšœ?™?—K˜KšΟk œ'œ œ6˜vK˜šΟnœœ˜Kšœd˜kKšœ˜K˜—K˜Kšœœœ žœ,˜HK˜Kšžœœœ˜K˜šžœœœ˜1Kšœ*˜*Kšœ˜—K˜šžœœœ˜/šžœœœœ˜9Kšœœœ˜Kšœ˜Kšœœœ˜$Kšœœ˜—Kšœ(œœ˜5Kšœ˜—K˜šžœœ˜$šžœœœœ˜:Kšœœœ˜Kšœ˜Kšœœœ˜%Kšœœ˜—Kšœ)œœ˜6Kšœ˜—K˜Kšœ œ˜Kš œ Οcœœœ œD˜Kšœ>˜>Kš œœœœœ˜Kšœ˜K˜Kšœœ˜Kšœ#˜#K˜šžœœœœ˜*Kšœœ˜Kšœ˜Kšœœœ ˜2Kšœ˜—K˜šžœœœ˜@Kšœ˜Kš œ Ÿ ΠcmŸœJœœ/˜‘Kšœ Ÿ  Ÿ œ=˜\Kšœ Ÿ  Ÿœ=˜Yšžœœœ˜,KšœŸ œ˜8K˜Kšœ#˜#Kšœœœœ˜+Kšœ)˜)Kšœ˜—šžœœœœ˜5K˜"Kšœœœ˜$Kšœ œ˜Kšœœœœ˜ Kšœœœœ˜%Kšœœ˜"šœœ˜Kšœ œ*œ˜IK˜&K˜A—Kšœœž˜—šž œœœœ˜7K˜"Kšœœœœ˜%Kšœ(˜(Kšœœ˜Kšœ œ˜Kšœœ˜&Kšœœ˜%Kšœœ ˜Kšœœœ˜Kšœ œ0˜@šœœ œœ˜,Kšœ0˜0Kšœ˜—Kšœ˜Kš œœ œœœ˜1šœœ˜Kšœœ9œ˜HKšœ œ?˜KKšœ œœ˜Kšœœœ˜K˜>Kšœœœœœ$œœ˜gKšœœ&œœ˜TKšœ!œ ˜/Kšœœ˜—šœ˜Kšœœ˜.Kšœœ˜—Kšœ˜—šžœœœœ˜2Kšœ˜Kšœ'˜'Kšœœ˜Kšœ$˜$Kšœœœœ˜.Kšœ œœ˜(šœœœœ˜1Kšœœ˜ Kšœœ˜ Kšœœ˜—Kš œœœœœœ˜(šž œœœœ˜5Kšœ œœ˜šœœ˜Kšœœ˜Kšœœœœ˜Kšœ ˜ Kšœœ˜—šœ˜Kšœ3˜3Kšœ˜Kšœœ˜ š œ œ;œœœ˜qKšœœD˜NKšœ1˜1Kšœ˜Kšœ˜—Kšœœœœ˜Kšœ,˜,Kšœœ˜—Kšœ˜—Kšœœ œ œœœœ˜>Kšœœœ˜+Kšœœ˜—Kšœ'œœ˜8Kšœ+œœ˜8Kšœ&œœ˜3Kšœ˜Kšœœ˜—K˜šžœœ6œœ˜OKš œœœœ,œ˜K—K˜š žœœœœœœ˜BKšœœœœ œœœ˜UKšœ˜—K˜Kšœœœœ˜SK˜šž œœœ˜EKšœœœ˜!Kšœœ˜š˜šœœ˜%Kš œœœœœœ3˜hKšœœœ0˜:Kšœœ˜—K˜%Kšœ˜—Kšœœ˜,Kšœ7˜7K˜Kšœ˜—K˜šž œœœ˜AKšœœ3˜:—K˜Kšœ œœœ˜KK˜šž œœœ%œ Ÿ  Ÿ Ÿœ˜wKš œ œœœŸ+œ˜DKšœŸœ%˜BKš žœœœœ œœ˜>šžœœ˜KšœŸ  Ÿœ#œ ˜MK˜šž œœ˜)Kšœœœ˜"Kšœ˜Kšœ Ÿœ˜.K˜)šžœœœœ˜8Kšœ œ˜Kšœ œ˜K˜"Kšœœ)œ ˜IKšœ_œ˜eKšœ˜—Kšœ œœœ˜Kšœ ˜ šœœ˜KšœF˜FKšœ"˜"Kšœœ˜$Kšœ ˜ —K˜(Kšœ˜—šžœœ˜6Kšœ œœ˜Kšœ!˜!Kšœœœ*œ˜@Kšœ˜—Kšœœœœ˜&šœœœ˜Kš œœœœ#œ˜<šžœœœœ˜4Kšœ œ œ˜ K˜#K˜2Kšœœ˜#Kšœœ˜—Kšœœ"˜CKšœAœœ˜Nšœ œ˜KšœL˜LK˜Kšœ˜—Kšœ œ˜!Kšœ œ˜#Kšœœ-˜NKšœ œ˜!Kšœ œ˜#Kšœ˜—šœœ œœ˜K˜Kšœ˜šžœœ˜0Kšœ œ œ˜!Kšœœ œ˜&K˜QKšœœ œœ˜Kšœ œœ˜%Kšœ)œ˜-Kšœœ,˜JKšœ$œœ˜1Kšœœ˜#Kšœ˜ —Kšœ ˜ Kšœ0˜0Kšœ œ˜!Kšœ œ˜#Kšœ˜—Kšœ˜—Kšœœœ˜"Kšœœ˜Kšœ!˜!Kšœ˜—K˜K˜šž œœ#˜2šž œœ˜"Kšœ Ÿœ˜8Kšœ œœ˜K˜+šžœœœœ˜.K˜Kšœ;œ˜WKšœœ˜—Kšœœœ˜Kšœœœ˜(—Kšœœœ˜/Kšœ˜—K˜šž œœ#˜3Kšœœ˜-šœ Ÿ Ÿœ˜/Kšœ'˜'˜K˜ K˜+——šžœœœœ˜4Kšœœ˜K˜$šœ˜K˜Kšœœ˜*Kšœ˜—Kšœœ˜—šž œœœœ˜3Kšœœ&œœ˜=Kšœ œœœ˜ Kšœ œœ˜Kšœ+œ˜.Kšœœ!œ˜:Kš œœœ œœœ˜0Kšœ˜K˜/K˜Kšœœ#œœ˜4Kšœ$œ˜+Kšœœ˜—Kšœ(œœ˜5Kšœ4œœ˜AKšœ˜—K˜šž œœ˜$K˜Kšœœ˜8Kšœ˜—K˜šžœœ#˜7K˜K˜šž œœœœ˜:K˜"Kšœœœœ˜'Kšœœ˜K˜K˜'Kšœœ˜—Kšœœœ˜+Kšœ˜—K˜Kšœ˜—…—.>=ό