CoreStructuralComparison.Mesa
Last tweaked by Mike Spreitzer on March 24, 1987 2:34:09 pm PST
DIRECTORY Basics, Core, CoreClasses, CoreFlat, HashTable, Rope;
CoreStructuralComparison: CEDAR DEFINITIONS = {
ROPE: TYPE ~ Rope.ROPE;
Role: TYPE ~ {A, B};
RoleNames: TYPE ~ ARRAY Role OF ROPE;
CellTypePair: TYPE ~ ARRAY Role OF Core.CellType;
FlattenAndCompare:
PROC [
roleNames: ARRAY Role OF ROPE,
cts: CellTypePair,
stss: ARRAY Role OF SubtreeSpec ← ALL[ToLeaves],
mss: ARRAY Role OF MergeSpec ← ALL[MergeNothing],
GiveHints: HintsGiver ← NIL,
PerPair: AssociationPairConsumer ← NIL,
PerMismatch: MismatchConsumer ← NIL,
Querier: AssociationQuerier ← NIL,
automorphismHack, mayQuitEarly: BOOLFALSE,
didQuitEarly, abort: REF BOOL
]
RETURNS [isomorphic: BOOL];
HintsGiver: TYPE = PROC [Consume: HintConsumer];
HintConsumer: TYPE = PROC [ds: ARRAY Role OF Descendant];
ds[A], and all the stuff it merges with, is to be colored the same unique colors as ds[B] (and all the stuff it merges with).
For now, ds[A] and ds[B] may only be parts of the public wires of the given cell types (not Recasts of them).
AssociationPairConsumer: TYPE = PROC [Pair];
Consumes the uniquely paired elements.
AssociationQuerier: TYPE = PROC [Ans: QueryAnswerer];
QueryAnswerer: TYPE = PROC [Role, Descendant] RETURNS [Pair];
The one the given Descendant is in, if any; [NIL, NIL] otherwise.
ColorElts: TYPE ~ ARRAY Role OF ElementList;
ElementList: TYPE ~ LIST OF Element;
Pair: TYPE ~ ARRAY Role OF Element;
Element: TYPE ~ LIST OF Descendant;
Descendant: TYPE = REF ANY--actually UNION [DescendantWire, DescendantCellInstance]--;
DescendantWire: TYPE = REF DescendantWirePrivate;
DescendantWirePrivate: TYPE = CoreFlat.FlatWireRec;
DescendantCellInstance: TYPE = REF DescendantCellInstancePrivate;
DescendantCellInstancePrivate: TYPE = CoreFlat.InstancePath;
SubtreeSpec: TYPE = PROC [instance: CoreClasses.CellInstance, path: CoreFlat.InstancePath] RETURNS [leafType: Core.CellType];
You may want to Recast (or worse) a bit to get the CellType you use.
Return NIL to get flattening.
A SubtreeSpec must be directly in a global frame and should not change its behavior over time (it is used as a key in a cache).
ToLeaves: SubtreeSpec;
Flattens everything that has a known expansion into something else.
DontFlatten: SubtreeSpec;
Flattens everything that has a known expansion into something else.
MergeSpec: TYPE = PROC [
original, parent: Core.CellType,
path: CoreFlat.InstancePath,
EnumerateInstances: PROC [Consume: PROC [ci: CoreClasses.CellInstance] RETURNS [stop: BOOLFALSE]],
IdentifyActual: PROC [ci: CoreClasses.CellInstance, actual: Core.Wire, describe: BOOLFALSE] RETURNS [ActualID],
Consume: MergeConsumer];
The original is the cell type handed to FlattenAndCompare, no Recasting done. The parent is reachable from the original by Recasting and visiting children. The MergeSpec will be called multiple times --- once for each subDAG in the cell composition hierarchy. Thus, you can only merge things introduced in the same cell --- sorry, we hope this is enough.
A MergeSpec must also be directly in a global frame and not change its behavior over time (it's also used as a key in a cache).
MergeConsumer: TYPE = PROC [ds: Element];
The Descendants may be any of their aliases.
ActualID: TYPE = RECORD [id: REF ANY, description: ROPE];
MergeNothing: MergeSpec;
MismatchConsumer: TYPE = PROC [
msg: ROPENIL,
kind: MismatchKind,
cts: CellTypePair,
colorElts: ColorElts,
Ans: QueryAnswerer
];
MismatchKind: TYPE = {stuck, difference, transistorShape};
difference is when a color has a different number of vertices from the two graphs; stuck is when both graphs contribute the same number of vertices to a color, but that number is greater than one (we don't try picking a pair to try to resolve this). transistorSize is when there's a transistor size mismatch.
HashDescendant: PROC [ra: REF ANY] RETURNS [hash: CARDINAL];
DescendantEqual: PROC [r1, r2: REF ANY] RETURNS [equal: BOOL];
RefHash: PROC [ra: REF ANY] RETURNS [CARDINAL] = INLINE {
ln: Basics.LongNumber = [lc[LOOPHOLE[ra]]];
RETURN [ln.lo + ln.hi];
};
}.