CD.mesa; Main definitions for ChipNDale, a VLSI design editor
Copyright © 1983, 1985 by Xerox Corporation. All rights reserved.
by Ch. Jacobi, June 24, 1983 3:54 pm
last edited Christian Jacobi, September 20, 1985 2:42:01 pm PDT
DIRECTORY
D2Basic USING [Number, Pos, Rect],
Imager USING [Context, Color],
MBQueue USING [Queue],
Properties USING [PropList],
RefTab USING [Ref],
Rope USING [ROPE],
SymTab USING [Ref];
CD: CEDAR DEFINITIONS =
-- CD: ChipNDale, a VLSI design editor and data base
BEGIN
-- measures
-- independent of coordinate system
Number: TYPE = D2Basic.Number;
Position: TYPE = D2Basic.Pos;
-- RECORD [x, y: Number];
Rect: TYPE = D2Basic.Rect;
-- RECORD [x1, y1, x2, y2: Number];
--A Rect is called normalized if (x1>x2) OR (y1>y2) means that the Rect is empty.
--Rects are normalized, except if a special comment denies.
--Rect's are closed: they include all the endpoints; as you expect, points have
--size 0; except if a special comment denies.
Orientation: TYPE = [0..7] ← 0;
-- Module CDOrient exports all you probably need about Orientations;
-- If your program depends on the representation of Orientation, it
-- is probably wrong.
original: Orientation = 0;
-- Errors
Error: ERROR [ec: ErrorCode ← programmingError, explanation: Rope.ROPENIL];
ErrorCode: TYPE = {programmingError, callingError, noResource, doubleRegistration, missingRegistration, other};
-- properties
PropList: TYPE = Properties.PropList;
--Friendly use expected: don't assign properties without first register
--their names with CDProperties.
--Use only CDProperties to access ChipNDale PropList; NOT Properties
--Unprotected enumeration is highly not recomended; ChipNDale might
--re-order the list asynchronously.
PropRef: TYPE = REF PropList ← --ABSOLUTELY NEVER NIL
InitPropRef: PROC [] RETURNS [PropRef] = INLINE {
RETURN [NEW[PropList←NIL]]
};
-- Layers
layerNum: NAT = 256;
Layer: TYPE = [0..layerNum);
combined: Layer = 0; -- layer used for object containing different or unknown Layers
highLightShade: Layer = 1; -- visualization; not for generating masks
highLightError: Layer = 2; -- visualization; not for generating masks
backGround: Layer = 3; -- special pushed-in backGround; not for generating masks
NewLayer: PROC [technology: Technology, uniqueKey: ATOM] RETURNS [Layer];
-- may raise Error[noResource] and others
-- the technolgy implementation must guarantee for uniqueness of uniqueKey's
-- (unique only for the technology)
FetchLayer: PROC [t: Technology, uniqueKey: ATOM] RETURNS [Layer];
LayerTechnology: PROC [l: Layer] RETURNS [Technology];
LayerKey: PROC [l: Layer] RETURNS [ATOM];
--object, cells, instances
markNum: NAT = 256;
Object: TYPE = REF ObjectRep;
--Objects are the main things in ChipNDale
--Objects must draw the same way independant of their environment
ObjectRep: TYPE = RECORD [
class: REF --READONLY-- ObjectClass, -- never modify class nor class^
size: Position ← [2, 2],
layer: Layer ← combined,
marked: [0..markNum) ← 0, --only objects with inDirectory are not shared through designs
specificRef: REF ANYNIL,
properties: PropList ← NIL -- see warning
];
-- Several instances may point to same object: consider on modifications.
-- Some implementors of object-classes share the bits of different ObjectRep's
-- (therefore usage of properties of Objects not in the directory is restricted to
-- the object class implentor.)
CellPtr: TYPE = REF CellRep;
CellRep: TYPE = RECORD [
contents: InstanceList ← NIL,
ir: Rect ← [0, 0, -1, -1], --actual interest rect
dIr: Rect ← [0, 0, -1, -1], --default value for interest rect
name: Rope.ROPENIL,
simplifyOn: NATLAST[NAT],
useDIr: BOOLTRUE, --should use the default for interest rect
origin: Position ← [0, 0]
];
RectPtr: TYPE = REF RectRep;
RectRep: TYPE = RECORD [filler: PRIVATE REF];
InstanceList: TYPE = LIST OF Instance←NIL;
Instance: TYPE = REF InstanceRep;
InstanceRep: TYPE = RECORD [
ob: Object,
location: Position ← [0, 0], --in cd-coords
orientation: Orientation ← 0,
selected: BOOLFALSE,
reserved: BOOLFALSE,
properties: PropList ← NIL
];
ObjectClass: TYPE = RECORD [ -- generic procedures for an object
quickDrawMe: DrawProc,
drawMe: DrawProc,
showMeSelected: DrawProc,
hitInside: HitInsideProc,
interestRect: RectProc,
oldInsideRect: RectProc,
technology: Technology, -- NIL on technology independent stuff
objectType: ATOM,
inDirectory: BOOL, -- if inDirectory then included in directory;
-- all object classes which have children must be in the directory
directoryProcs: REFNIL,
wireTyped: BOOL ← FALSE, -- if wiretyped then insideRect.y corresponds length
symbolic: BOOL ← FALSE,
reserved: BOOL ← FALSE,
internalWrite: InternalWriteProc,
internalRead: InternalReadProc,
description: Rope.ROPENIL,
describe: DescribeProc ← NIL,
describeInst: DescribeInstProc ← NIL,
origin: PosProc ← NIL,
further: PRIVATE RefTab.Ref,
properties: PropRef ← NIL
];
DrawProc: TYPE = PROC [inst: Instance, pos: Position, orient: Orientation, pr: REF DrawInformation];
--ignores inst.location and inst.orientation, may use inst.properties
HitInsideProc: TYPE = PROC [ob: Object, hitRect: Rect] RETURNS [BOOL];
PosProc: TYPE = PROC [ob: Object] RETURNS [Position];
RectProc: TYPE = PROC [ob: Object] RETURNS [Rect];
BoolProc: TYPE = PROC [ob: Object] RETURNS [BOOL];
InternalWriteProc: TYPE = PROC [me: Object];
InternalReadProc: TYPE = PROC [] RETURNS [Object];
DescribeProc: TYPE = PROC [me: Object] RETURNS [Rope.ROPE];
DescribeInstProc: TYPE = PROC [ap: Instance] RETURNS [Rope.ROPE];
DrawContextProc: TYPE = PROC [pr: DrawRef, proc: DrawContextLayerProc, ob: Object, pos: Position, orient: Orientation, layer: Layer];
DrawContextLayerProc: TYPE = PROC [context: Imager.Context, ob: Object, layer: Layer];
RegisterObjectClass: PROC [objectType: ATOM, technology: Technology←NIL] RETURNS [REF ObjectClass];
--may raise Error[doubleRegistration] and others
--Also initializes procedures with default values
--An object type may be used either in arbitrary technology or technology-independent.
--This should be the only way to create data of type ObjectProcsRec
FetchObjectClass: PROC [objectType: REF, technology: Technology←NIL] RETURNS [REF --readonly-- ObjectClass];
--may raise Error[missingRegistration]
--consider ObjectClass as readonly if you are not the implementor of the object type
-- Design
PushRec: TYPE = RECORD [
dummyCell: Instance,
originally a copy of mightReplace; warning: size may be wrong
mightReplace: Instance←NIL,
specific: CellPtr, -- cache of dummyCell.ob.specificRef
changed: BOOLFALSE,
indirectlyChanged: BOOLFALSE,
deletedList: REFNIL
];
Design: TYPE = REF DesignRec;
DesignRec: TYPE = RECORD [ -- use only CDOps.CreateDesign to create record
actual: LIST OF PushRec, -- actual.first is most deeply pushed cell;
cellDirectory: PRIVATE CellTableRef,
-- pushed cells are copied and not part of the cellDirectory
name: Rope.ROPE NIL,
technology: Technology ← NIL,
designValues: DesignValues ← NIL, --CDValue
queue: MBQueue.Queue,
seqPrivate: SequencerRef,
privateDrawQueue: PRIVATE REFNIL,
properties: PropRef ←
--CDValue supports more fields
];
SequencerRef: TYPE = REF SequencerDesignPrivate;
SequencerDesignPrivate: TYPE;
CellTableRef: PRIVATE TYPE = SymTab.Ref;
DesignValues: TYPE = REF DesignValuesRep; --CDValue
DesignValuesRep: TYPE; --CDValue
-- Technology
Technology: TYPE = REF TechnologyRep;
TechnologyRep: TYPE = RECORD [
-- use RegisterTechnology to create record
-- consider all fields read only
key: ATOM NIL,
name: Rope.ROPE NIL,
lambda: CD.Number ← 2,
technologyPrivate: PRIVATE TechnologyPrivate,
technologyValues: TechnologyValues, --CDValue
technologyCommands: TechnologyCommands, --CDSequencer
usedLayers: --READONLY-- LIST OF Layer, -- without constant Layers defined in CD
properties: PropRef ←
--CDValue supports more fields
];
TechnologyValues: TYPE = REF TechnologyValuesRep; --CDValue
TechnologyCommands: TYPE = REF TechnologyCommandsRep; --CDSequencer
TechnologyPrivate: TYPE = PRIVATE REF TechnologyPrivateRep;
TechnologyValuesRep: TYPE; --CDValue
TechnologyCommandsRep: TYPE; --CDSequencer
TechnologyPrivateRep: TYPE;
RegisterTechnology: PROC [key: ATOM, name: Rope.ROPE NIL, lambda: CD.Number ← 2] RETURNS [Technology];
--This must be the only way to create data of type TechnologyRep
--may raise Error[doubleRegistration] and others
FetchTechnology: PROC [key: ATOM] RETURNS [Technology];
--may raise Error[missingRegistration] and others
EnumerateTechnologies: PROC [proc: TechnologyEnumerator] RETURNS [quit: BOOL];
TechnologyEnumerator: TYPE = PROC[tech: CD.Technology] RETURNS [quit: BOOLFALSE];
-- drawing
DrawRef: TYPE = REF DrawInformation;
DrawInformation: TYPE = RECORD [
interestClip: Rect, -- (interrest area; not device area), in doubt is larger;
minimalSize: Number, -- if xyz<minimalSize; xyz is not drawn the normal way (Cells)
scaleHint: REAL, -- to monitor simplifications; 0 means no simplifications
drawChild: DrawProc,
drawRect: DrawRectProc, -- still world coordinates, how many bits do device coordinates use?
drawOutLine: DrawOutLineProc, -- usefull for visualization only; not for generating masks
drawContext: DrawContextProc,
drawComment: DrawCommentProc,
stopFlag: REF BOOL,
--special flags for certain hacks; not known by all devices
environment: BOOLTRUE, --draw the outside of pushed in cells
symbolics: BOOLTRUE, --draw symbolic objects
specialFonts: BOOLFALSE, --usually FALSE; replaces fonts
checkPriority: BOOLFALSE, --usually FALSE; priority of running process
priorityChecker: CheckPriorityProc ← NIL, --usually no-op
b4: PRIVATE BOOLTRUE, -- reserved for experiments
b5: PRIVATE BOOLTRUE, -- reserved for experiments
setGround: SetGroundProc,
devicePrivate: REF ← NIL, -- differentiate among multiple (viewers) with same drawProc's
deviceContext: Imager.Context ← NIL, --may or may not be used
viewerPrivate: ViewerPrivate ← NIL, -- speed up for viewers devicePrivate
contextFilter: REF READONLY ContextFilter ← NIL,
design: Design ← NIL,
properties: PropRef ←
];
-- DrawInformation records should not be copied unless the state of drawing is
-- separately initialized.
ViewerPrivate: TYPE = REF ViewerPrivateRep;
ViewerPrivateRep: TYPE;
DrawRectProc: TYPE = PROC [r: Rect, l: Layer, pr: DrawRef];
DrawOutLineProc: TYPE = PROC [r: Rect, pr: DrawRef];
DrawCommentProc: TYPE = PROC [r: Rect, comment: Rope.ROPE, pr: DrawRef];
SetGroundProc: TYPE = PROC [pr: DrawRef, pushedOut: BOOL];
CheckPriorityProc: TYPE = PROC [pr: DrawRef];
ContextFilter: TYPE = ARRAY Layer OF Imager.Color;
--Allows to specify an application specific mapping of layers to colors
--A NIL color entry means the layer is invisible
CreateDrawRef: PROC [design: Design, deviceContext: Imager.Context ← NIL] RETURNS [DrawRef];
-- for conveniance; assigns usefull null procedures and default values.
--vanilla procedures
InterestRect: PROC [ob: Object] RETURNS [r: Rect] = INLINE {
-- Returns the interest rect in objects internal cd coords
RETURN [ob.class.interestRect[ob]]
};
InterestSize: PROC [ob: Object] RETURNS [sz: Position] = INLINE {
-- Returns the size of the interest rect
r: CD.Rect = ob.class.interestRect[ob];
RETURN [[r.x2-r.x1, r.y2-r.y1]];
};
ClientOrigin: PROC [ob: Object] RETURNS [pos: Position] = INLINE {
-- Returns the position of the client's object origin in objects internal cd coords
RETURN [ob.class.origin[ob]]
};
END.