PW.mesa
Copyright © 1984 by Xerox Corporation. All rights reversed.
Created by: Monier, January 31, 1985 3:11:27 pm PST
Last Edited by: Serlet, February 28, 1985 10:53:27 am PST
DIRECTORY
CD USING [Design],
CDOrient USING [mirrorX, mirrorY, Orientation, rotate90, rotate180, rotate270],
Rope USING [ROPE];
PW:
CEDAR
DEFINITIONS =
BEGIN
-- Basic user types
ObjName: TYPE = ROPE ← NIL; -- so that user only deals with names (preferred)
InstName: TYPE = ObjName; -- old form
ROPE: TYPE = Rope.ROPE; -- waiting for some Cedar release when it is predefined
-- Utilities always useful
-- Predicates
ODD: PUBLIC PROC [i: INT] RETURNS [BOOL] = INLINE {RETURN [(i MOD 2 # 0)]};
EVEN: PUBLIC PROC [i: INT] RETURNS [BOOL] = INLINE {RETURN [(i MOD 2 = 0)]};
Dealing with Log2 of numbers
Log2: PROC [n: INT] RETURNS [INT];
TwoToThe: PROC [x: INT] RETURNS [INT];
TwoToTheLog2: PROC [n: INT] RETURNS [INT] = INLINE {RETURN [TwoToThe[Log2[n]]]};
Extraction of bits in INT
XthBitOfN: PROC [x, n: INT] RETURNS [BOOL];
Warning: bit 0 is the LOW order bit (lsb)
-- Simple Abuts
AbutX: PROC [t1, t2, t3, t4, t5, t6, t7, t8: ObjName ← NIL] RETURNS [new: ObjName];
AbutY: PROC [t1, t2, t3, t4, t5, t6, t7, t8: ObjName ← NIL] RETURNS [new: ObjName];
-- Abutment of lists
AbutListX: PROC [subNames: LIST OF ObjName] RETURNS [new: ObjName];
AbutListY: PROC [subNames: LIST OF ObjName] RETURNS [new: ObjName];
-- Parametrized cells (conditional objects)
Inst: PUBLIC PROC [name: ObjName, conds: LIST OF ROPE, removeNamed: BOOL ← TRUE] RETURNS [ObjName];
-- Arrays and other repetitions of Cells
XYFunction: TYPE = PROC [x, y: INT] RETURNS [instName: ObjName];
Evaluates the function function over the domain [lx..ux)*[ly..uy) and abuts the resulting tiles in an array. Creates empty cell when lx>=ux or ly>=uy.
MapFunction: PROC [function: XYFunction, lx: INT ← 0, ux: INT, ly: INT ← 0, uy: INT] RETURNS [ObjName];
Aligns nx tiles in the X direction. If nx<=0 an empty cell is created
ArrayX: PROC [objName: ObjName, nx: INT ← 1] RETURNS [ObjName];
Aligns ny tiles in the Y direction. If nx<=0 an empty cell is created
ArrayY: PROC [objName: ObjName, ny: INT ← 1] RETURNS [ObjName];
Array: PROC [objName: ObjName, nx, ny: INT ← 1] RETURNS [ObjName];
-- Rotating cells
ChangeOrientation: PROC [dir: CDOrient.Orientation, tile: ObjName] RETURNS [ObjName];
FlipX:
PROC [tile: ObjName]
RETURNS [ObjName] =
INLINE {RETURN [ChangeOrientation[CDOrient.mirrorX, tile]]};
FlipY:
PROC [tile: ObjName]
RETURNS [ObjName] =
INLINE {RETURN [ChangeOrientation[CDOrient.mirrorY, tile]]};
Identity:
PROC [tile: ObjName]
RETURNS [ObjName] =
INLINE {RETURN [tile]};
Rot90:
PROC [tile: ObjName]
RETURNS [ObjName] =
INLINE {RETURN [ChangeOrientation[CDOrient.rotate90, tile]]};
Rot180:
PROC [tile: ObjName]
RETURNS [ObjName] =
INLINE {RETURN [ChangeOrientation[CDOrient.rotate180, tile]]};
Rot270:
PROC [tile: ObjName]
RETURNS [ObjName] =
INLINE {RETURN [ChangeOrientation[CDOrient.rotate270, tile]]};
-- Other functions
Naming instances
ReName: PROC [oldName: ObjName, instanceName: ROPE] RETURNS [newCellName: ObjName];
Making objects non stretchable
MakeObjNonStretchable: PROC [objName: ObjName];
-- Facilities for client interface
UserProc: TYPE = PROC [design: CD.Design] RETURNS [ObjName];
Register: PROC [userProc: UserProc, name: ROPE];
END.