LayoutCheckpointImpl.mesa 
Copyright © 1985 by Xerox Corporation. All rights reversed.
Bertrand Serlet December 1, 1986 11:26:51 pm PST
Curry, July 30, 1986 3:46:29 pm PDT
DIRECTORY
CD, CDBasics, CDDirectory, CDInstances, CDIO, CDOps, CDProperties, CDTexts, CDValue,
Core, CoreIO, CoreOps,
CoreGeometry,
IO,
LayoutCheckpoint,
PW, PWCore,
Rope;
LayoutCheckpointImpl: CEDAR PROGRAM
IMPORTS CD, CDBasics, CDDirectory, CDInstances, CDIO, CDOps, CDProperties, CDTexts, CDValue, CoreIO, CoreOps, CoreGeometry, IO, PW, PWCore, Rope
EXPORTS LayoutCheckpoint
SHARES PWCore =
BEGIN OPEN LayoutCheckpoint;
Storing and retrieving entire Core + Layout
Store: PUBLIC PROC [cellType: CellType, withCuteFonts: BOOLFALSE] = {
props: LIST OF ATOM;
classes: LIST OF Core.CellClass;
name: ROPE ← CoreOps.GetCellTypeName[cellType];
PW.WriteF["Saving the Core for cell %g ...\n", IO.rope[name]];
[props, classes] ← CoreIO.ReportSaveCellType[cellType];
PW.WriteF["... core stored in %g.core ...\n", IO.rope[name]];
Checkpoint[cellType, withCuteFonts];
};
Retrieve: PUBLIC PROC [name: ROPE] RETURNS [cellType: CellType] = {
PW.WriteF["Retrieving the Core for cell %g ...\n", IO.rope[name]];
cellType ← CoreIO.RestoreCellType[name];
PW.WriteF["... core retrieved in %g.core ...\n", IO.rope[name]];
[] ← CoreOps.SetCellTypeName[cellType, name];
SetFromCheckpoint[cellType];
};
Storing and retrieving layout
Checkpoint: PUBLIC PROC [cellType: CellType, withCuteFonts: BOOLFALSE] = {
font: CDTexts.CDFont ← CDTexts.MakeFont["Xerox/TiogaFonts/Helvetica8", 4];
sourceObj: CD.Object ← PWCore.Layout[cellType];
ir: CD.Rect ← PWCore.InterestRect[cellType];
iSize: CD.Position ← CD.InterestSize[sourceObj];
name: ROPE ← CoreOps.GetCellTypeName[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]];
layout: CD.Object ← PW.CreateEmptyCell[];
shell: CD.Object ← PW.CreateEmptyCell[];
PW.WriteF["Making shell for cell %g ...\n", IO.rope[name]];
[] ← PW.IncludeInCell[layout, sourceObj];
PW.SetInterestRect[layout, iSize];
PW.RepositionCell[layout];
shell ← CoreGeometry.CreateShell[PWCore.extractMode.decoration, cellType, withCuteFonts];
layoutDesign.name ← layoutFileName;
shellDesign.name ← shellFileName;
[] ← CDDirectory.Include[layoutDesign, layout, name];
[] ← CDDirectory.Include[shellDesign, shell, name];
CDOps.IncludeObjectI[layoutDesign, sourceObj];
CDOps.IncludeObjectI[shellDesign, shell];
CDValue.Store[layoutDesign, $KeepObjects, $KeepObjects]; -- to avoid finalization!!! Have you ever seen objects of class: GCollected??
CDValue.Store[shellDesign, $KeepObjects, $KeepObjects]; -- to avoid finalization!!! Have you ever seen objects of class: GCollected??
We wan to store the irProp of the CellType somewhere. Not on the Core, because we want to avoid reading the whole file to get the real properties, not on the Layout, because we want to avoid reading the whole layout file, so we store them on the Shell.
CDProperties.PutDesignProp[shellDesign, $IRX1, NEW [INT ← ir.x1]];
CDProperties.PutDesignProp[shellDesign, $IRX2, NEW [INT ← ir.x2]];
CDProperties.PutDesignProp[shellDesign, $IRY1, NEW [INT ← ir.y1]];
CDProperties.PutDesignProp[shellDesign, $IRY2, NEW [INT ← ir.y2]];
PW.WriteF["Storing Layout for cell %g ...\n", IO.rope[name]];
[] ← CDIO.WriteDesign[layoutDesign, layoutFileName];
PW.WriteF["Storing Shell for cell %g ...\n", IO.rope[name]];
[] ← CDIO.WriteDesign[shellDesign, shellFileName];
PW.WriteF["... layout checkpoint stored in %gLayout.dale and %gShell.dale\n", IO.rope[name], IO.rope[name]];
};
SetFromCheckpoint: PUBLIC PROC [cellType: CellType] = {
we hack a lit bit to be lazy
RetrieveDecorate[cellType, NIL];
PWCore.SetLayout[cellType, $RetrieveLayout];
};
RetrieveLayout: PWCore.LayoutProc = {
name: ROPE ← CoreOps.GetCellTypeName[cellType];
layoutFileName: ROPE ← Rope.Cat[name, "Layout"];
layoutDesign: CD.Design ← PW.OpenDesign[layoutFileName];
obj ← PW.Get[layoutDesign, name];
IF CD.InterestRect[obj]#PWCore.InterestRect[cellType] THEN ERROR;
};
RetrieveDecorate: PWCore.DecorateProc = {
name: ROPE ← CoreOps.GetCellTypeName[cellType];
layoutFileName: ROPE ← Rope.Cat[name, "Layout"];
shellFileName: ROPE ← Rope.Cat[name, "Shell"];
shellDesign: CD.Design ← PW.OpenDesign[shellFileName];
ir: CD.Rect ← [
x1: NARROW [CDProperties.GetDesignProp[shellDesign, $IRX1], REF INT]^,
x2: NARROW [CDProperties.GetDesignProp[shellDesign, $IRX2], REF INT]^,
y1: NARROW [CDProperties.GetDesignProp[shellDesign, $IRY1], REF INT]^,
y2: NARROW [CDProperties.GetDesignProp[shellDesign, $IRY2], REF INT]^
];
shell: CD.Object ← PW.Get[shellDesign, name];
cellPtr: CD.CellPtr ← NARROW [shell.specificRef];
offset: CD.Position ← CDBasics.SubPoints[CDBasics.BaseOfRect[ir], CDBasics.BaseOfRect[CD.InterestRect[shell]]];
IF CD.InterestSize[shell]#CDBasics.SizeOfRect[ir] THEN ERROR;
CoreGeometry.PutIR[PWCore.extractMode.decoration, cellType, ir];
FOR list: LIST OF CD.Instance ← cellPtr.contents, list.rest WHILE list#NIL DO
wireName: ROPENARROW [CDProperties.GetInstanceProp[list.first, $InstanceName]];
wire: Wire;
instance: CD.Instance;
IF CDTexts.IsText[list.first.ob] THEN LOOP;
instance ← CDInstances.Copy[list.first];
CDProperties.PutInstanceProp[instance, $InstanceName, NIL]; -- save some memory
wire ← CoreOps.FindWire[cellType.public, wireName];
IF wireName=NIL OR wire=NIL THEN ERROR;
CDInstances.Translate[instance, offset];
CoreGeometry.PutPins[PWCore.extractMode.decoration, wire, CONS [instance, CoreGeometry.GetPins[PWCore.extractMode.decoration, wire]]];
ENDLOOP;
};
Initialization
[] ← PWCore.RegisterLayoutAtom[$RetrieveLayout, RetrieveLayout, RetrieveDecorate];
END.