PWCore.mesa
Copyright Ó 1985, 1986, 1987 by Xerox Corporation. All rights reversed.
Louis Monier February 14, 1986 11:00:35 am PST
Bertrand Serlet, August 15, 1988 12:10:08 pm PDT
DIRECTORY
CD USING [Design, InterestRect, Object, Position, Rect],
Core,
CoreGeometry,
RefTab USING [Ref],
Sinix USING [Mode];
PWCore: CEDAR DEFINITIONS IMPORTS CD = 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;
WireSeq: TYPE = Core.WireSeq;
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, LayoutProcs must insert one level of indirection (using PW.CreateIndirect) if the object they return can be returned by other calls with a different cell type. For example the Get Layout function always return an indirect object.
DecorateProc: TYPE = PROC [cellType: CellType, obj: Object];
Decorates cellType with the geometric information derived from obj. That is decorates the atomic publics with the pins.
AttributesProc: TYPE = PROC [cellType: CellType];
This function allows the computation of arbitrary attributes that can be stored on the cellType for the LayoutProc.
RegisterLayoutAtom: PROC [layoutAtom: ATOM, layoutProc: LayoutProc, decorateProc: DecorateProc ← NIL, attributesProc: AttributesProc ← NIL] 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.
decorateProc can only be NIL if layoutProc is decorating its argument.
GetLayoutAtomRegistration: PROC [layoutAtom: ATOM] RETURNS [layoutProc: LayoutProc ← NIL, decorateProc: DecorateProc ← NIL, attributesProc: AttributesProc ← NIL];
Retrieves the registration of layoutAtom.
Might load some program according to the ChipNDale-CD-PWCore.CDLoadList.
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, then on the recasted cell type, etc...
Usage should be limited to testing if the returned layoutAtom is NIL or not.
Layout: PROC [cellType: CellType] RETURNS [obj: Object];
Retrieves the layout corresponding to a cell type by:
- fetching the layoutAtom with the function GetLayoutAtom (property layoutAtomProp), and finding the corresponding layoutProc and decorateProc,
- if that fails start all over again with the recast of cellType.
- evaluating the attributesProc (if present),
- evaluating layoutProc,
- using the decorateProc (if present) to decorate the original cellType
Calling twice Layout with the same (REF equal) cellType will produce the same (REF equal) obj.
InterestRect: PROC [cellType: CellType] RETURNS [ir: CD.Rect] = INLINE {ir ← CD.InterestRect[Layout[cellType]]};
For backward compatibility and ease of use
Predefined layoutAtoms
Predefined layoutAtoms to be used in schematics
$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.
$AbutX, $AbutY, $ReverseAbutX, $ReverseAbutY: the cellType must be a recordCell. Sorts the instances according to the Sisyph decoration.
$Abut: the cellType must be a recordCell. Decides if it is an Abut in X or Y by looking at the Sisyph decorations. Then sorts the instances according to the Sisyph decoration.
$ArrayX, $ArrayY, $ArrayFlipX, $ArrayFlipY, ReverseArrayX, $ReverseArrayY: the cellType must be a sequenceCell.
$FlipX, $FlipY, $Rot90, $Rot180, $Rot270: the cellType must be a RecordCell with a unique instance.
Predefined layoutAtoms to be used by code
$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. No indirection is added, so that if different cell types (e.g. extracted by Sisyph in different contexts) need the same layout they must insert an indirection level in the CD hierarchy.
$RawAbutX, $RawAbutY, $RawReverseAbutX, $RawReverseAbutY: the cellType must be a recordCell. The order of the cell instances is important.
$Recast: the cellType must have a Recast proc and the recasted cellType must have layout.
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 SinixOps.GetExtractMode[$cmosB].
Short cuts for the designer
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.
SetLayoutAndDecoration: PROC [cellType: CellType, layout: Object] = INLINE {SetLayout[cellType, $ValueNoDecorate, $PWCoreValue, layout]};
For cases when designer knows the layout of a cellType (without any lazyness), and has already decorated cellType with the interface decorations.
SetAbutX: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $RawAbutX]};
SetAbutY: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $RawAbutY]};
SetArrayX: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $ArrayX]};
SetArrayY: PROC [cellType: CellType] = INLINE {SetLayout[cellType, $ArrayY]};
RotateCellType: PROC [rotatedCellType: CellType, orientation: ATOM] RETURNS [cellType: CellType];
Creates a new cellType which layout is the same as the rotatedCellType, but rotated by orientation.
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: 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 a RecordCell with a unique instance, and obj a CD Cell with a unique instance.
InstancesInXOrY: PROC [decoration: CoreGeometry.Decoration, record: CellType, fudge: INT ← 0] RETURNS [ambiguous, inX: BOOL];
Assuming that record is a decorated Record Cell, looks if the instances are spread in X or Y.
Result inX is only valid when non ambiguous.
The exact rule is to see if projections along one axis are all non overlapping, while projections along the other axis are overlapping.
Overlapping takes into account the fudge quantity to allow instances that overlap by l/2 to be qualified "non-overlapping". In that case l/2 should be passed for the fudge argument.
SortInstances: PROC [decoration: CoreGeometry.Decoration, 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).
Saving "Checkpoints"
This section allows the user of PWCore to insert "checkpoints", that is places where the generated layout is stored on a file.
Store: PROC [cellType: CellType, withCuteFonts: BOOLFALSE];
Assumes that the cellType is decorated with layout.
Stores the decorated Core itself on the file named "<nameOfCellType>.core".
Stores the layout on the file named "<nameOfCellType>Layout.dale".
Stores a shell of the layout on the file named "<nameOfCellType>Shell.dale".
Retrieve: PROC [name: ROPE, withLazyExtract: BOOLTRUE] RETURNS [cellType: CellType];
Retrieves the decorated Core itself from the file named "<nameOfCellType>.core".
If withLazyExtract, uses Sinix.DecorateObjectWithLazyExtract, so that things like Lichen can be applied.
Backdoor for clients such as PWCoreLichen
LayoutInfo: PROC [sourceCT: CellType] RETURNS [layout: Object, extractedCT: CellType, extractedToSource: RefTab.Ref, key: INT];
Makes the bridge between sourceCT and extractedCT.
GetPWCoreExtractedCTKey: PROC [extractedCT: CellType] RETURNS [key: INT ← 0];
Returns 0 if obj has not been obtained by PWCore.Layout.
Otherwise returns a key suck that GetPWCoreExtractedCTKey[LayoutInfo[sourceCT].extractedCT]=LayoutInfo[sourceCT].key.
IsPWCoreGenerated: PROC [obj: Object] RETURNS [BOOL];
Returns TRUE if obj has been obtained by PWCore.Layout.
Exceptions
All the escapes from PWCore functions are described in this section.
Signal: SIGNAL [cellType: CellType];
This SIGNAL is called when implementor should be called ...
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
PinsCorrespondingToSeveralPublics: SIGNAL [cellType: CellType, obj: Object, publics: Wires, geometry: CoreGeometry.Instances];
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.
NoPinsOnAtomicPublic: SIGNAL [cellType: CellType, obj: Object, public: Wire, message: ROPENIL];
This Signal is called during or after decoration of cellType. The variable public holds the atomic public which has 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!
END.