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]; IF ct.asu#NIL THEN { d: Design ~ ct.d; parsed: BiRel--ROPE X INT-- ~ BiRels.GenCreate[spaces: [SetBasics.ropes[TRUE], SetBasics.ints], mappable: [TRUE, FALSE], hints: [[fn: [$Hash], set: [$Vector]], []]]; dotted: Fn--ROPE _ {$T, $F}-- ~ BiRels.CreateHashTable[[SetBasics.ropes[TRUE], SetBasics.refs]]; FixWire: PROC [w: Wire, prefix: ROPE] ~ { subscripts: Set--of INT-- ~ parsed.MappingA[prefix]; old: SteppyName ~ OSn[prefix]; new: SteppyName ~ old.SNCat[name0]; IF NOT subscripts.Equal[fixSet] THEN ERROR; ReplaceDescendantsName[ct, w, old, new]; RETURN}; <> NoteNaming: PROC [pair: BiRels.Pair] RETURNS [BOOL] ~ { w: Wire ~ NARROW[pair[left].VA]; sn: SteppyName ~ VSn[pair[right]]; name: ROPE ~ NARROW[sn.steps.first]; namelen: INT ~ name.Length[]; IF sn.steps.rest#NIL THEN ERROR; IF sn.grade.gend THEN RETURN [FALSE]; {sepPos: INT ~ name.Index[s2: "_"]; dotPos: INT _ -1; hasDot: BOOL _ FALSE; IF sepPos=0 THEN ERROR; FOR idx: INT DECREASING IN [0 .. sepPos) DO SELECT name.InlineFetch[idx] FROM IN ['0 .. '9] => NULL; '. => {hasDot _ TRUE; dotPos _ idx; EXIT}; IN ['a..'z], IN ['A..'Z] => {hasDot _ FALSE; dotPos _ idx; EXIT}; ENDCASE => ERROR; ENDLOOP; IF dotPos<0 THEN ERROR; {dd: INTEGER ~ IF hasDot THEN 0 ELSE 1; sfxPos: INT ~ dotPos+dd; IF dotPos+1 < sepPos THEN { prefix: ROPE ~ name.Replace[start: sfxPos, len: sepPos-sfxPos, with: NIL]; intPart: INT ~ Convert.IntFromRope[name.Substr[dotPos+1, sepPos-dotPos-1]]; IF dotted.AddAA[prefix, IF hasDot THEN $T ELSE $F].had[leftToRight] = different THEN ERROR; IF intPart<0 THEN ERROR; IF prefix.Length[]=0 THEN ERROR; [] _ parsed.AddPair[[AV[prefix], IV[intPart]]]; RETURN [FALSE]} ELSE { [] _ parsed.AddPair[[AV[name], IV[noIntPart]]]; RETURN [FALSE]}; }}}; Recon: PROC [prefv: Sets.Value] RETURNS [BOOL] ~ { prefix: ROPE ~ NARROW[prefv.VA]; sufixs: Set ~ parsed.Mapping[prefv]; IF sufixs.Equal[noIntSet] THEN RETURN [FALSE]; {seppos: INT ~ prefix.Index[s2: "_"]; 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 { w: Wire ~ ct.FetchWire[OSn[prefix]]; FixWire[w, prefix]; RETURN [FALSE]} ELSE { oldsn: SteppyName ~ OSn[prefix.Replace[start: seppos, len: 0, with: dot.Concat[Convert.RopeFromInt[intPart]]]]; newsn: SteppyName ~ LSn[LIST[prefix, NewInt[intPart]]]; w: Wire ~ ct.FetchWire[oldsn]; ReplaceDescendantsName[ct, w, oldsn, newsn]; RETURN [FALSE]}; }; IF (NOT hasDot) AND sufixs.Size.EN> IF ct.fullName[w].Scan[NoteNaming].found THEN ERROR; IF parsed.SetOn[left].Scan[Recon].found THEN ERROR; RETURN}; RETURN}; thresh: NAT _ 6; 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 6, 1989 4:43:31 pm PDT Κ ά– "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š œ ŸΠcmŸœ-œœœ/˜₯Kšœ Ÿ Ÿ œ+œ˜`šžœœœ˜)KšœŸ œ˜4K˜Kšœ#˜#Kšœœœœ˜+Kšœ(˜(Kšœ˜—šžœœœœ˜5Kšœ œ œ˜ K˜"Kšœœœ˜$Kšœ œ˜Kšœœœœ˜ Kšœœœœ˜%Kšœœ˜"šœœ˜Kšœ œ*œ˜IK˜"K˜=—Kšœœž˜—šž œœœœ˜7Kšœ œ œ˜ K˜"Kšœœœ˜$Kšœ œ˜Kšœœœœ˜ Kšœœœœ˜%Kšœ œ˜#Kšœœ˜Kšœœœ˜Kšœ œœ˜š œœ œœ˜+šœ˜!Kšœœ˜Kšœœœ˜*Kšœ œœœ˜AKšœœ˜—Kšœ˜—Kšœ œœ˜Kš œœœœœ˜'Kšœœ ˜šœœ˜Kšœœ9œ˜JKšœ œ?˜KKš œœœœ"œœ˜[Kšœ œœ˜Kšœœœ˜ Kšœœ œ ˜/Kšœœ˜—šœ˜Kšœœœ˜/Kšœœ˜—Kšœ˜—šžœœœœ˜2Kšœœœœ˜ Kšœ$˜$Kšœœœœ˜.Kšœ œ˜%šœœœœ˜1Kšœœ˜ Kšœœ˜ Kšœœ˜—Kš œœœœœœ˜(šž œœœœ˜5Kšœ œœ˜šœœ˜Kšœ$˜$Kšœ˜Kšœœ˜—šœ˜Kšœo˜oKšœœ˜7Kšœ˜Kšœ,˜,Kšœœ˜—Kšœ˜—Kšœœ œ œœœœ˜>Kšœœœ˜+Kšœœ˜—Kšœ#œœ˜4Kšœ'œœ˜4Kšœ&œœ˜3Kšœ˜—Kšœ˜Kšœœ˜—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šœ˜—…—(6>