PWC.mesa
Copyright © 1985, 1986 by Xerox Corporation. All rights reversed.
Louis Monier February 14, 1986 11:00:35 am PST
Bertrand Serlet, August 11, 1986 7:53:59 pm PDT
Curry, October 8, 1986 7:24:29 am PDT
Don Curry October 27, 1986 1:19:52 pm PST
DIRECTORY
CD USING [commentLayer, Design, Instance, Layer, Object, Position, Rect],
Core,
CoreCreate USING [PA],
CoreGeometry USING[Side],
Sinix USING [Mode];
PWC: CEDAR DEFINITIONS = BEGIN
Theory
This interface defines how to generate layout attached to Core, using PatchWork (PW). Layout done by hand can also be attached. When layout is attached to Core, it is also specified how to decorate the original Core source with the interface geometry. The only way for clients to retrieve the Layout hanging on a Core CellType is Layout.
Basics
CellType: TYPE = Core.CellType;
Object: TYPE = CD.Object;
Wire: TYPE = Core.Wire;
ROPE: TYPE = Core.ROPE;
Properties: TYPE = Core.Properties;
Wires: TYPE = Core.Wires;
Primitive operations
LayoutProc: TYPE = PROC [cellType: CellType] RETURNS [obj: Object];
obj is the layout for cellType.
Identical (REF equal) cellTypes must have the same (REF equal) layout, and the same layout must correspond to the same cellType. To follow this restriction, the Layout function automatically insert one level of indirection (Indirect object).
DecorateProc: TYPE = PROC [cellType: CellType, obj: Object];
Checks that obj is compatible with the source cellType, and decorates cellType with the geometric information derived from obj.
RegisterLayoutAtom: PROC [layoutAtom: ATOM, layoutProc: LayoutProc, decorateProc: DecorateProc] RETURNS [sameAtom: ATOM];
LayoutProcs are not directly accessible and must be associated with an atom.
This delayed generation allows description or simulation of the Core structure before any geometry is present, and lazy evaluation of the geometry improves efficiency.
layoutAtomProp: ATOM; -- = $Layout. Property on cellTypes to specifies layoutAtoms
GetLayoutAtom: PROC [cellType: CellType] RETURNS [layoutAtom: ATOMNIL];
Retrieves the layoutAtom (if any) on the CellType, then on the CellClass.
Extract: PROC [obj: Object] RETURNS [cellType: CellType];
Layout: PROC [cellType: CellType] RETURNS [obj: Object];
Retrieves the layout corresponding to a cell type by:
1) fetching the layoutAtom with the function GetLayoutAtom (property layoutAtomProp),
2) finding the corresponding layoutProc and decorateProc,
3) evaluating layoutProc,
4) decorating cellType with a property recording the interestRect of the layout
5) using the decorateProc to decorate the original cellType
6) returning an indirect object of obj with a funny ExtractProc.
The result is cached, so that means that called twice with the same (REF equal) cellType, Layout will produce the same (REF equal) obj.
To follow the restriction that the same layout can not correspond to two different cellTypes, Layout automatically inserts one level of indirection (indirect object).
The extraction of the indirect object returns a CellType of class layoutClass that contains the source layout and the source CellType, and that recasts in a recordCell with only one sub cellType being the result of the extraction of the source layout.
SetObjName: PROC [obj: CD.Object, name: ROPE];
transistorCount: ATOM;
CountTransistors: PROC[cell: CellType] RETURNS[count: INT ← 0];
InterestRect: PROC [cellType: CellType] RETURNS [ir: CD.Rect];
Returns the InterestRect of a cellType (might call Layout, if the property is not present)
InterestSize: PROC [cellType: CellType] RETURNS [size: CD.Position];
might call Layout, if InterestRect property is not present
layoutClass: Core.CellClass; -- data field of such objects is of type LayoutData
LayoutData: TYPE = REF LayoutDataRec;
LayoutDataRec: TYPE = RECORD [
obj: CD.Object,  -- obj as returned by the layoutProc
cellType: CellType, -- source as passed by the user
mode: Sinix.Mode -- extractMode, at layout creation time
];
CorrespondingCellType: PROC [obj: Object] RETURNS [layoutCellType: CellType ← NIL];
This function returns a cellType of class layoutClass such as Layout[layoutCellType.data.cellType]=obj, if any, NIL otherwise.
In particular, obj.class#indirect => layoutCellType=NIL.
This function is used for checking the isomorphism between the source Core and the extracted Core.
Predefined layoutAtoms
$Get and $GetAndFlatten: expect a $PWCoreSourceDesign property [of type CD.Design] on the cellType. The Object of name the name of the CellType concatenated with maskSuffix is fetched in the attribute Design, and is Extracted. Publics of the extracted CellType must correspond [by full name] to the original public. GetAndFlatten flattens the layout, so that corresponding transistors inter-cells are fused.
$Value: expects a $PWCoreValue property [of type Object] on the cellType. The Object is extracted, and publics of the extracted CellType must correspond [by full name] to the original public.
$AbutX, $AbutY, $ReverseAbutX, $ReverseAbutY: the cellType must be a recordCell.
$ArrayX, $ArrayY, $ReverseArrayX, $ReverseArrayY: the cellType must be a sequenceCell.
$Recast: the cellType must have a Recast proc and the recasted cellType must have layout. This is the default for identity cellTypes.
$FlipX, $FlipY, $Rot90, $Rot180, $Rot270: the cellType must be an identityCell.
maskSuffix: ROPE;
Contains the rope that is to be concatenated to the name of a cellType to find the name of the corresponding layout cell. Used by the LayoutProc for $Get
Global Variable
A global variable is used for calling Sinix. This is going to change soon, but for now that is fine enough. Better rollback between changes, if you don't know what you are doing.
extractMode: Sinix.Mode;
Contains the mode that is to be passed to Sinix when doing extraction. Its default is SinixCMos.extractBMode and it can be changed to SinixCMos.checkBMode.
Help for writing DecorateProcs
SortProc: TYPE = PROC [CD.Position, CD.Position] RETURNS [BOOL];
Returns TRUE if the first position is "before" the second
SortInX: SortProc;
SortInY: SortProc;
ReverseSortInX: SortProc;
ReverseSortInY: SortProc;
DecorateValue: DecorateProc;
Provokes an extraction. Assumes the the full names of the publics cellType and the extracted CellType are corresponding.
DecorateAbut: PROC [cellType: CellType, obj: CD.Object, sort: SortProc];
Assumes that cellType is a record Cell for which each sub cell type has layout.
Assumes that obj (when expanded the appropriate number of times) is a CD Cell that contains translations of the layouts of the sub cell types.
Does not provoke an extraction.
DecorateAbutX: DecorateProc;
DecorateAbutY: DecorateProc;
DecorateReverseAbutX: DecorateProc;
DecorateReverseAbutY: DecorateProc;
DecorateRecasted: DecorateProc;
Assumes that cellType and its recast have similar public.
Copies the decorations of the recast.
Does not provoke an extraction.
DecorateRotated: DecorateProc;
Assumes that cellType is an identity Cell and obj a CD Cell with only one instance.
DecorateFlatten: PROC [cellType: CellType, obj: CD.Object, sort: SortProc];
Conceptually flattens obj (stopping for the cellTypes which have an associated layout), extracts it, sorts its instances, assumes they match the instances of cellType, and finally decorates cellType in accord to this sort.
SortInstances: PROC [cellType: CellType, sort: SortProc];
This function modifies physically the instances of cellType, by permuting the ith and the jth instance when sort (called with the positions of the instances) returns FALSE (for i<j).
Short cuts for the designer
SetExtractCell: PROC [obj: CD.Object, cellType: CellType];
SetLayoutObj: PROC [cellType: CellType, obj: CD.Object];
SetLayout: PROC [cellType: CellType, layoutAtom: ATOM, userDataProp: ATOMNIL, userData: REFNIL];
Attaches the atom as a property (layoutAtomProp) of the cell type.
If the user wants to supply some data, this data is stored under the property userDataProp on the cellType.
The implementation is the following:
CoreProperties.PutCellTypeProp[cellType, layoutAtomProp, layoutAtom];
IF userDataProp#NIL THEN CoreProperties.PutCellTypeProp[cellType, userDataProp, userData];
SetGet: PROC [cellType: CellType, source: CD.Design] =
INLINE {SetLayout[cellType, $Get, $PWCoreSourceDesign, source]};
Fetches layout from a source design.
SetAbutX: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $AbutX]};
SetAbutY: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $AbutY]};
SetArrayX: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $ArrayX]};
SetArrayY: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $ArrayY]};
rotatedCellClass: Core.CellClass;
RotateCellType: PROC[cellType: CellType, orientation: ATOM]
RETURNS [rotatedCellType: CellType];
Help for regular structures
The intent of this function is to permit building regular structures while specifying the minimum amount of information. For example only topology and renaming is given when calling this function, and all the details of the strictly internal wires are not specified.
AbutInstance: TYPE = RECORD [object: Object, pas: LIST OF CoreCreate.PANIL];
Object must be a layout cell with only atomic wires. There is no need to describe object by other means (it defines the truth!).
ATTENTION: pas should contain all bindings (no default binding when public and sub-publics have same name is happening)
AbutCell: PROC [public: Wire, abutInstances: LIST OF AbutInstance, inX: BOOL, shared: BOOLFALSE, name: ROPENIL, props: Properties ← NIL] RETURNS [recordCell: CellType];
Abuts (in X or in Y depending on inX) the layout of the given abutInstances. Extracts the result using extractMode, and uses the pas (given in abutInstances) to deduce the correspondance between extracted wires and public wires.
The truth for this generated recordCell comes soforth from the layout.
Boolean shared specifies which of PW.AbutList and PW.SharedAbutList should be used.
AbutList: PROC [cellTypes: LIST OF CellType, inX: BOOL] RETURNS [recordCell: CellType];
Abuts (in X or in Y depending on inX) the given cellTypes. Extracts the result using extractMode.
The truth for this generated recordCell comes soforth from the layout.
Side: TYPE = CoreGeometry.Side;
NWMML: TYPE = RECORD
[name: ROPENIL,
wire:  Core.Wire←NIL,
min:  INT𡤀,
max:  INT𡤀,
layer:  CD.Layer ← CD.commentLayer];
SidePinList: PROC [cellType: CellType, side: Side]
RETURNS [list: LIST OF NWMMLNIL];     -- sorted by min, max, name, wire, layer
PosSortNWMMLs:  PROC[lst: LIST OF NWMML]; -- sorted by min, max, name, wire, layer
AddMergeNWMMLs: PROC[item: NWMML, lst: LIST OF NWMML]
RETURNS[LIST OF NWMML];
CellShell: PROC[cell: CellType] RETURNS[shell: CD.Object]; -- no duplications
Exceptions
All the escapes from PWC functions are described in this section.
Error: ERROR [type: ATOM, message: ROPE, cellType: CellType];
This ERROR is called when attachment of layout is impossible. Current types are:
$NoLayoutAtom
$NoRegistration
$InternalBug
$CallerBug
GeometryCorrespondingToSeveralPublics: SIGNAL [cellType: CellType, obj: Object, publics: Wires, geometry: LIST OF CD.Instance];
This Signal is called during or after decoration of cellType, when some interface geometry corresponds to two several atomic wires of cellType. The variable publics holds the list of atomic publics corresponding; geometry holds all the geometry in error.
NoGeometryOnAtomicPublics: SIGNAL [cellType: CellType, obj: Object, publics: Wires, message: ROPENIL];
This Signal is called during or after decoration of cellType. The variable publics holds the list of atomic publics which have no geometry.
For those who really want to live dangerously ...
FromLayoutWithoutPublic: PROC [obj: Object] RETURNS [cellType: CellType];
This PROC is used to bypass all checks and get the Core description directly from the Layout using Sinix. Avoid using it!
FlushLayoutProperties: PRIVATE PROC [cellType: CellType];
Warning: it is dangerous to use this function without being aware of PWC implementation details.
END.