StoreLayoutImpl.mesa 
Copyright © 1985 by Xerox Corporation. All rights reversed.
Bertrand Serlet April 22, 1986 4:35:28 pm PST
DIRECTORY CD, CDDirectory, CDIO, CDOps, CDProperties, CDSimpleRules, CDSymbolicObjects, CDTexts, Core, CoreOps, CoreProperties, PW, PWCore, StoreLayout;
StoreLayoutImpl: CEDAR PROGRAM
IMPORTS CD, CDDirectory, CDIO, CDOps, CDProperties, CDSimpleRules, CDSymbolicObjects, CDTexts, CoreOps, CoreProperties, PW, PWCore
EXPORTS StoreLayout =
BEGIN OPEN StoreLayout;
Storing and retrieving
StoreDesign: PUBLIC PROC [cellType: CellType, name: ROPE] = {
font: CDTexts.CDFont ← CDTexts.MakeFont["Xerox/TiogaFonts/Helvetica8", 2];
EachWirePin: PWCore.EachWirePinProc = {
minW: INT ← CDSimpleRules.MinWidth[layer];
wireName: ROPE ← CoreOps.GetFullWireName[cellType.public, wire];
pos: CD.Position ← SELECT side FROM
left => [0, min],
right => [iSize.x-minW, min],
top => [min, iSize.y-minW],
bottom => [min, 0],
ENDCASE => ERROR;
inst: CD.Instance ← PW.IncludeInCell[shell, CDSymbolicObjects.CreatePin[IF side=left OR side=right THEN [minW, max-min] ELSE [max-min, minW]], pos];
CDSymbolicObjects.SetLayer[inst, layer];
CDSymbolicObjects.SetName[inst, wireName];
inst ← PW.IncludeInCell[shell, CDSimpleRules.Rect[IF side=left OR side=right THEN [minW, max-min] ELSE [max-min, minW], layer], pos];
inst.properties ← CDProperties.DCopyProps[instance.properties];
[] ← PW.IncludeInCell[
shell,
CDTexts.CreateText[wireName, font],
SELECT side FROM left => [pos.x-100, pos.y], right => [pos.x+minW+10, pos.y], top => [pos.x, pos.y+minW+10], bottom => [pos.x, pos.y-100], ENDCASE => ERROR,
SELECT side FROM left, right => 0, top, bottom => 2, ENDCASE => ERROR
];
};
iSize: CD.Position ← CD.InterestSize[PWCore.Layout[cellType]];
design: CD.Design ← CDOps.CreateDesign[CD.FetchTechnology[$cmosB]];
shell: CD.Object ← PW.CreateEmptyCell[];
[] ← PWCore.EnumerateWirePins[cellType, EachWirePin];
PW.SetInterestRect[shell, iSize];
PW.RepositionCell[shell];
[] ← CDDirectory.Include[design, shell, name];
CDOps.IncludeObjectI[design, shell];
PW.CleanUp[design];
[] ← PW.Draw[shell]; -- for debug
[] ← CDIO.WriteDesign[design, name];
};
SetRetrieveLayout: PUBLIC PROC [cellType: CellType, name: ROPE] = {
PWCore.SetLayout[cellType, $RetrieveLayout, $RetrieveDesign, name];
};
RetrieveLayout: PWCore.LayoutProc = {
name: ROPENARROW [CoreProperties.GetCellTypeProp[cellType, $RetrieveDesign]];
design: CD.Design ← PW.OpenDesign[name];
obj ← PW.Get[design, name];
};
[] ← PWCore.RegisterLayoutAtom[$RetrieveLayout, RetrieveLayout, PWCore.CheckAndDecorateGet];
END.