LayoutCheckpointImpl.mesa 
Copyright © 1985 by Xerox Corporation. All rights reversed.
Bertrand Serlet December 17, 1986 6:09:26 am PST
Curry, July 30, 1986 3:46:29 pm PDT
DIRECTORY
CD, CDCells, CDDirectory, CDInstances, CDIO, CDOps, CDProperties, CDSymbolicObjects, CDTexts,
Core, CoreIO, CoreOps,
CoreGeometry,
IO,
LayoutCheckpoint,
PW, PWCore, PWObjects,
Rope, TerminalIO;
LayoutCheckpointImpl: CEDAR PROGRAM
IMPORTS CD, CDCells, CDDirectory, CDInstances, CDIO, CDOps, CDProperties, CDSymbolicObjects, CDTexts, CoreIO, CoreOps, CoreGeometry, IO, PW, PWCore, PWObjects, Rope, TerminalIO
EXPORTS LayoutCheckpoint
SHARES PWCore =
BEGIN OPEN LayoutCheckpoint;
Storing
Store: PUBLIC PROC [cellType: CellType, withCuteFonts: BOOLFALSE] = {
name: ROPE ← CoreOps.GetCellTypeName[cellType];
layout: CD.Object ← PWCore.Layout[cellType];
layoutFileName: ROPE ← Rope.Cat[name, "Layout"];
shellFileName: ROPE ← Rope.Cat[name, "Shell"];
layoutDesign: CD.Design ← CDOps.CreateDesign[CD.FetchTechnology[$cmosB]];
shellDesign: CD.Design ← CDOps.CreateDesign[CD.FetchTechnology[$cmosB]];
shell: CD.Object;
Core
TerminalIO.PutF["Saving the Core for cell %g ...\n", IO.rope[name]];
[] ← CoreIO.ReportSaveCellType[cellType];
Shell
We wan to store the bbox of layout somewhere. Not on the Layout, because we want to avoid reading the whole layout file, so we store them on the Shell.
CDProperties.PutDesignProp[shellDesign, $BBOXX1, NEW [INT ← layout.bbox.x1]];
CDProperties.PutDesignProp[shellDesign, $BBOXX2, NEW [INT ← layout.bbox.x2]];
CDProperties.PutDesignProp[shellDesign, $BBOXY1, NEW [INT ← layout.bbox.y1]];
CDProperties.PutDesignProp[shellDesign, $BBOXY2, NEW [INT ← layout.bbox.y2]];
TerminalIO.PutF["Making shell for cell %g ...\n", IO.rope[name]];
shell ← CoreGeometry.CreateShell[PWCore.extractMode.decoration, cellType, withCuteFonts];
shellDesign.name ← shellFileName;
[] ← CDDirectory.Include[shellDesign, shell, name];
CDOps.IncludeObjectI[shellDesign, shell];
TerminalIO.PutF["Storing Shell for cell %g ...\n", IO.rope[name]];
[] ← CDIO.WriteDesign[shellDesign, shellFileName];
Layout
layoutDesign.name ← layoutFileName;
layout ← PWObjects.CreateCell[LIST [CDInstances.NewInst[layout]], CD.InterestRect[layout], name];
[] ← CDDirectory.Include[layoutDesign, layout, name];
CDOps.IncludeObjectI[layoutDesign, layout];
TerminalIO.PutF["Storing Layout for cell %g ...\n", IO.rope[name]];
[] ← CDIO.WriteDesign[layoutDesign, layoutFileName];
TerminalIO.PutF["... layout checkpoint stored in %g.core, %gLayout.dale and %gShell.dale\n", IO.rope[name], IO.rope[name], IO.rope[name]];
};
Retrieving
Retrieve: PUBLIC PROC [name: ROPE] RETURNS [cellType: CellType] = {
TerminalIO.PutF["Retrieving the Core for cell %g ...\n", IO.rope[name]];
cellType ← CoreIO.RestoreCellType[name];
TerminalIO.PutF["... core retrieved in %g.core ...\n", IO.rope[name]];
[] ← CoreOps.SetCellTypeName[cellType, name]; -- just to make sure
PWCore.SetLayout[cellType, $RetrieveLayout];
};
RetrieveLayout: PWCore.LayoutProc = {
name: ROPE ← CoreOps.GetCellTypeName[cellType];
shellFileName: ROPE ← Rope.Cat[name, "Shell"];
shellDesign: CD.Design ← PW.OpenDesign[shellFileName];
bbox: CD.Rect ← [
x1: NARROW [CDProperties.GetDesignProp[shellDesign, $BBOXX1], REF INT]^,
x2: NARROW [CDProperties.GetDesignProp[shellDesign, $BBOXX2], REF INT]^,
y1: NARROW [CDProperties.GetDesignProp[shellDesign, $BBOXY1], REF INT]^,
y2: NARROW [CDProperties.GetDesignProp[shellDesign, $BBOXY2], REF INT]^
];
shell: CD.Object ← PW.Get[shellDesign, name];
DecorateInst: CDCells.InstEnumerator = {
IF CDTexts.IsText[inst.ob] THEN RETURN;
BEGIN
wireName: ROPENARROW [CDProperties.GetInstanceProp[inst, $InstanceName]];
wire: Wire ← CoreOps.FindWire[cellType.public, wireName];
instance: CoreGeometry.Instance ← [
IF CDSymbolicObjects.IsSymbolicOb[inst.ob]
THEN CoreGeometry.CDPinToCoreGeometryPin[inst.ob, inst.properties]
ELSE inst.ob,
inst.trans];
IF wireName=NIL OR wire=NIL THEN ERROR;
CoreGeometry.PutPins[PWCore.extractMode.decoration, wire, CONS [instance, CoreGeometry.GetPins[PWCore.extractMode.decoration, wire]]];
END;
};
[] ← CDCells.EnumerateInstances[shell, DecorateInst];
obj ← PWObjects.CreateLazy[info: NEW [InfoRec ← [name]], createProc: LazyReadLayout, bbox: bbox, ir: CD.InterestRect[shell]];
};
Info: TYPE = REF InfoRec;
InfoRec: TYPE = RECORD [
name: ROPE,
obj: CD.Object ← NIL -- treated as a cache
];
LazyReadLayout: PWObjects.CreateProc = {
data: Info = NARROW [info];
obj ← data.obj;
IF obj=NIL THEN
data.obj ← obj ← PW.Get[PW.OpenDesign[Rope.Cat[data.name, "Layout"]], data.name];
};
Initialization
[] ← PWCore.RegisterLayoutAtom[$RetrieveLayout, RetrieveLayout, NIL];
END.