DIRECTORY AbSets, Basics, BasicTime, BiRels, IO, LichenArrayPrivate, LichenDataOps, LichenDataStructure, LichenIntBasics, Rope, SetBasics; LichenDataImplArrays1: CEDAR PROGRAM IMPORTS AbSets, BiRels, IO, LichenDataOps, LichenDataStructure, LichenIntBasics, Rope, SetBasics EXPORTS LichenArrayPrivate, LichenDataStructure, LichenDataOps = BEGIN OPEN IB:LichenIntBasics, IB, LichenDataStructure, LichenDataOps, LichenArrayPrivate, Sets:AbSets; CreateArray: PUBLIC PROC [d: Design, eltType: CellType, size, basePeriod: Int2, names: Set--of ROPE--] RETURNS [act: CellType] ~ { aName: ROPE ~ NARROW[names.AnElt[].MA]; act _ CreateCellType[d, array, names]; {svSpace: Sets.Space ~ NEW [SetBasics.SpacePrivate _ [ Contains: SVContains, Equal: SVEqual, AHash: SVHash, ACompare: SVCompare, Print: SVPrint, name: Rope.Cat["stat verts of ", aName], data: act]]; paiSpace: Sets.Space ~ NEW [SetBasics.SpacePrivate _ [ Contains: PAIContains, Equal: PAIEqual, AHash: PAIHash, ACompare: PAICompare, Print: PAIPrint, name: Rope.Cat["pais of ", aName], data: act]]; edgeSpace: Sets.Space ~ NEW [SetBasics.SpacePrivate _ [ Contains: SEContains, Equal: SEEqual, AHash: SEHash, ACompare: SECompare, Print: SEPrint, name: Rope.Cat["stat edges of ", aName], data: act]]; a: Array ~ NEW [ArrayPrivate _ [ size2: size, size: Area[size], basePeriod: basePeriod, statrep: NEW [StatRepPrivate _ [ edgeSpace: edgeSpace, paiSpace: paiSpace, svSpace: svSpace, edges: Sets.CreateHashSet[edgeSpace], portEdge: [ FALSE: BiRels.CreateHashReln[spaces: [d.eSpace, edgeSpace], functional: [FALSE, TRUE]], TRUE: BiRels.CreateHashReln[spaces: [d.eSpace, edgeSpace], functional: [FALSE, TRUE]] ], apToPAI: BiRels.CreateHashFn[[d.eSpace, paiSpace]] ]] ]]; act.asArray _ a; d.arrayElt.AddNewAA[act, eltType]; RETURN}}; SVContains: PUBLIC PROC [data: REF ANY, v: Sets.Value] RETURNS [BOOL] ~ { WITH v.ra SELECT FROM port: Port => RETURN [TRUE]; ENDCASE => RETURN [FALSE]}; SVHash: PROC [data: REF ANY, v: Sets.Value] RETURNS [CARDINAL] ~ { act: CellType ~ NARROW[data]; sv: StatVertex ~ VSv[v]; RETURN [act.d.eSpace.SHash[AV[sv.port]] + Int2Hash[sv.phase]]}; SVEqual: PROC [data: REF ANY, v1, v2: Sets.Value] RETURNS [BOOL] ~ { RETURN [SVCompare[data, v1, v2]=equal]}; SVCompare: PROC [data: REF ANY, v1, v2: Sets.Value] RETURNS [c: SetBasics.TotalComparison] ~ { act: CellType ~ NARROW[data]; sv1: StatVertex ~ VSv[v1]; sv2: StatVertex ~ VSv[v2]; IF (c _ act.d.eSpace.SCompare[AV[sv1.port], AV[sv2.port]]) # equal THEN RETURN; c _ Int2Compare[sv1.phase, sv2.phase]; RETURN}; SVPrint: PROC [data: REF ANY, v: Sets.Value, to: IO.STREAM, depth, length: INT, verbose: BOOL] ~ { act: CellType ~ NARROW[data]; sv: StatVertex ~ VSv[v]; act.d.eSpace.SPrint[AV[sv.port], to, depth, length, verbose]; PrintQual[to, "~", act.asArray.basePeriod, sv.phase]; RETURN}; PAIContains: PROC [data: REF ANY, v: Sets.Value] RETURNS [BOOL] ~ { WITH v.ra SELECT FROM port: Port => RETURN [TRUE]; ENDCASE => RETURN [FALSE]}; PAIHash: PROC [data: REF ANY, v: Sets.Value] RETURNS [CARDINAL] ~ { act: CellType ~ NARROW[data]; pai: PortAtIndex ~ VPai[v]; RETURN [act.d.eSpace.SHash[AV[pai.port]] + Int2Hash[pai.ai]]}; PAIEqual: PROC [data: REF ANY, v1, v2: Sets.Value] RETURNS [BOOL] ~ { RETURN [PAICompare[data, v1, v2]=equal]}; PAICompare: PROC [data: REF ANY, v1, v2: Sets.Value] RETURNS [c: SetBasics.TotalComparison] ~ { act: CellType ~ NARROW[data]; pai1: PortAtIndex ~ VPai[v1]; pai2: PortAtIndex ~ VPai[v2]; IF (c _ act.d.eSpace.SCompare[AV[pai1.port], AV[pai2.port]]) # equal THEN RETURN; c _ Int2Compare[pai1.ai, pai2.ai]; RETURN}; PAIPrint: PROC [data: REF ANY, v: Sets.Value, to: IO.STREAM, depth, length: INT, verbose: BOOL] ~ { act: CellType ~ NARROW[data]; pai: PortAtIndex ~ VPai[v]; act.d.eSpace.SPrint[AV[pai.port], to, depth, length, verbose]; PrintQual[to, "@", act.asArray.size2, pai.ai]; RETURN}; SEContains: PROC [data: REF ANY, v: Sets.Value] RETURNS [BOOL] ~ { IF v.i#0 THEN RETURN [FALSE]; WITH v.ra SELECT FROM se: StatEdge => RETURN [TRUE]; ENDCASE => RETURN [FALSE]}; SEHash: PROC [data: REF ANY, v: Sets.Value] RETURNS [CARDINAL] ~ { act: CellType ~ NARROW[data]; se: StatEdge ~ NARROW[v.VA]; RETURN [Int2Hash[se.d] + act.asArray.statrep.svSpace.SHash[SvV[se.vs[FALSE]]] + act.asArray.statrep.svSpace.SHash[SvV[se.vs[TRUE]]]*19]}; SEEqual: PROC [data: REF ANY, v1, v2: Sets.Value] RETURNS [BOOL] ~ { RETURN [SECompare[data, v1, v2]=equal]}; SECompare: PROC [data: REF ANY, v1, v2: Sets.Value] RETURNS [c: SetBasics.TotalComparison] ~ { act: CellType ~ NARROW[data]; se1: StatEdge ~ NARROW[v1.VA]; se2: StatEdge ~ NARROW[v2.VA]; IF (c _ act.asArray.statrep.svSpace.SCompare[SvV[se1.vs[FALSE]], SvV[se2.vs[FALSE]]]) # equal THEN RETURN; IF (c _ act.asArray.statrep.svSpace.SCompare[SvV[se1.vs[TRUE]], SvV[se2.vs[TRUE]]]) # equal THEN RETURN; c _ Int2Compare[se1.d, se2.d]; RETURN}; SEPrint: PROC [data: REF ANY, v: Sets.Value, to: IO.STREAM, depth, length: INT, verbose: BOOL] ~ { act: CellType ~ NARROW[data]; se: StatEdge ~ NARROW[v.VA]; act.asArray.statrep.svSpace.SPrint[SvV[se.vs[FALSE]], to, depth-1, length, verbose]; to.PutRope[" -> "]; act.asArray.statrep.svSpace.SPrint[SvV[se.vs[TRUE]], to, depth-1, length, verbose]; PrintQual[to, " by ", act.asArray.size2, se.d]; RETURN}; DWContains: PUBLIC PROC [data: REF ANY, v: Sets.Value] RETURNS [BOOL] ~ { IF v.i#0 THEN RETURN [FALSE]; WITH v.ra SELECT FROM dw: DumbWire => RETURN [TRUE]; ENDCASE => RETURN [FALSE]; }; DWPrint: PUBLIC PROC [data: REF ANY, v: Sets.Value, to: IO.STREAM, depth, length: INT, verbose: BOOL] ~ { act: CellType ~ NARROW[data]; dw: DumbWire ~ NARROW[v.VA]; pai: PortAtIndex ~ SomePAI[act, dw]; IF pai.port#NIL THEN { to.PutRope["{"]; act.d.eSpace.SPrint[AV[pai.port], to, depth, length, verbose]; PrintQual[to, "@", act.asArray.size2, pai.ai]; to.PutRope["}"]} ELSE to.PutF["%bB", [cardinal[LOOPHOLE[dw]]]]; RETURN}; SomePAI: PUBLIC PROC [act: CellType, dw: DumbWire] RETURNS [PortAtIndex] ~ { mpc: BiRels.MaybePair ~ dw.eps.APair[]; IF mpc.found THEN { ep: Port ~ NARROW[mpc.it[left].VA]; cai: CompositeArrayIndex ~ mpc.it[right].VI; ai: Int2 ~ act.asArray.DecomposeAI[cai]; RETURN [[ep, ai]]} ELSE RETURN [[NIL, [0, 0]]]}; PrintQual: PROC [to: IO.STREAM, intro: ROPE, size2, qual: Int2] ~ { IF size2[X]=1 THEN IF size2[Y]=1 THEN NULL ELSE to.PutF["%g%g", [rope[intro]], [integer[qual[Y]]]] ELSE IF size2[Y]=1 THEN to.PutF["%g%g", [rope[intro]], [integer[qual[X]]]] ELSE to.PutF["%g<%g,%g>", [rope[intro]], [integer[qual[X]]], [integer[qual[Y]]]]; }; END. ^LichenDataImplArrays1.Mesa Last tweaked by Mike Spreitzer on May 9, 1988 1:34:16 pm PDT Κœ– "cedar" style˜code™K™<—K˜KšΟk œ$œ[˜ŠK˜šΟnœœ˜$KšœœF˜`Kšœ7˜>K˜—K˜Kš œœœœ:žœ˜gK˜š ž œœœBΟc œœ˜‚Kšœœœœ˜'Kšœ&˜&šœœ˜6Kšžœ ˜Kšžœ ˜Kšžœ ˜Kšžœ ˜Kšžœ ˜K˜(K˜ —šœœ˜6Kšžœ˜Kšžœ ˜Kšžœ ˜Kšžœ ˜Kšžœ ˜K˜"K˜ —šœœ˜7Kšžœ ˜Kšžœ ˜Kšžœ ˜Kšžœ ˜Kšžœ ˜K˜(K˜ —šœ œ˜ K˜ K˜Kšœ˜šœ œ˜ Kšœ;˜;K˜%˜ KšœDœœ˜WKšœDœœ˜UK˜—Kšœ2˜2K˜—K˜—K˜Kšœ"˜"Kšœ˜ —K˜šž œœœœœœœ˜Išœœ˜Kšœœœ˜Kšœœœ˜——K˜š žœœœœœœ˜BKšœœ˜Kšœ˜Kšœœ"˜?—K˜š žœœœœœœ˜DKšœ"˜(—K˜š ž œœœœœ#˜^Kšœœ˜Kšœ˜Kšœ˜Kš œœ œœœ˜OKšœ&˜&Kšœ˜—K˜šžœœœœœœœ œ˜bKšœœ˜Kšœ˜Kšœœ'˜=Kšœ5˜5Kšœ˜—K˜š ž œœœœœœ˜Cšœœ˜Kšœœœ˜Kšœœœ˜——K˜š žœœœœœœ˜CKšœœ˜Kšœ˜Kšœœ!˜>—K˜š žœœœœœœ˜EKšœ#˜)—K˜š ž œœœœœ#˜_Kšœœ˜Kšœ˜Kšœ˜Kš œœ œœœ˜QKšœ"˜"Kšœ˜—K˜šžœœœœœœœ œ˜cKšœœ˜Kšœ˜Kšœœ(˜>Kšœ.˜.Kšœ˜—K˜š ž œœœœœœ˜BKšœœœœ˜šœœ˜Kšœœœ˜Kšœœœ˜——K˜š žœœœœœœ˜BKšœœ˜Kšœœœ˜KšœΟgœ0œ2œ ˜‰—K˜š žœœœœœœ˜DKšœ"˜(—K˜š ž œœœœœ#˜^Kšœœ˜Kšœœœ˜Kšœœœ˜Kš œ6œœ œœ˜jKš œ6œœ œœ˜hKšœ œ œ˜Kšœ˜—K˜šžœœœœœœœ œ˜bKšœœ˜Kšœœœ˜Kšœ-œ"˜TK˜Kšœ-œ"˜SKšœ, œ˜/Kšœ˜—K˜šž œœœœœœœ˜IKšœœœœ˜šœœ˜Kšœœœ˜Kšœœœ˜—K˜—K˜šžœœœœœœœœ œ˜iKšœœ˜Kšœœœ˜K˜$šœ œœ˜K˜Kšœœ(˜>Kšœ.˜.K˜—Kšœœ˜.Kšœ˜—K˜šžœœœœ˜LKšœ'˜'šœ œ˜Kšœ œœ˜#Kšœ)œ˜,Kšœ(˜(Kšœ ˜—Kšœœœ ˜—K˜š ž œœœœ œ˜Cšœ ˜ šœœ ˜Kšœ˜ Kšœ3˜7—šœœ ˜Kšœ3˜7KšœM˜Q——K˜—K˜Kšœ˜—…—z"t