<> <> <> <> <> DIRECTORY CD, Rope; PWDescr: CEDAR DEFINITIONS = BEGIN ROPE: TYPE = Rope.ROPE; allOnes: INT = LAST[INT]; -- same as 2B10-1=2147483647 <<-- Types for describing control parts>> Descriptor: TYPE = REF DescriptorRec; DescriptorRec: TYPE = RECORD[ genRef: REF, items: SEQUENCE size: CARDINAL OF Item]; -- which generator to use Item: TYPE = REF ItemRec; ItemRec: TYPE = RECORD [ name: ROPE _ NIL, -- name of the field, e.g. cAdr data: REF _ NIL, -- think of it as a property specificRef: REF _ NIL]; <<-- Specific refs>> <<-- A single bit (clock)>> BitRef: TYPE = REF BitRec; -- coded on one wire BitRec: TYPE = RECORD[val: BOOL _ FALSE]; <<-- A pair of bits (usually complementary values)>> BoolRef: TYPE = REF BoolRec; -- coded on two wires BoolRec: TYPE = RECORD[val0, val1: BOOL]; <<-- A sequence of booleans, high order bit=0 "on the left">> IntRef: TYPE = REF IntRec; -- every bit is coded as a boolean IntRec: TYPE = RECORD[val, mask: INT, bools: SEQUENCE nbBits: CARDINAL OF BoolRef]; <<-- A set of "things">> PadRef: TYPE = REF PadRec; -- no value, but positions PadRec: TYPE = RECORD[SEQUENCE size: CARDINAL OF INT]; <<>> <<--Turn a list of ropes in a vanilla descriptor of the appropriate size>> RopesToDescr: PUBLIC PROC [names: LIST OF ROPE, genRef: REF _ NIL] RETURNS [descr: Descriptor]; <<-- Set the type of an item, with an initial value if you wish and a data (usually an atom)>> SetTypeBit: PUBLIC PROC [descr: Descriptor, name: ROPE, initVal: BOOL _ FALSE, data: REF _ NIL]; SetTypeBool: PUBLIC PROC [descr: Descriptor, name: ROPE, initVal: BOOL _ FALSE, complement: BOOL _ FALSE, data: REF _ NIL]; SetTypeInt: PUBLIC PROC [descr: Descriptor, name: ROPE, nbBits: INT, initVal: INT _ 0, complement: INT _ 0, data: REF _ NIL]; SetTypePad: PUBLIC PROC [descr: Descriptor, name: ROPE, padRef: PadRef, data: REF _ NIL]; <<-- Set the value of an item; complement has to be interpeted bitwise as follows: if set to TRUE, then [val0, val1] _ [val, ~val], otherwise [val0, val1] _ [val, val] >> SetBit: PUBLIC PROC [descr: Descriptor, name: ROPE, val: BOOL]; SetBool: PUBLIC PROC [descr: Descriptor, name: ROPE, val: BOOL, complement: BOOL _ TRUE]; SetInt: PUBLIC PROC [descr: Descriptor, name: ROPE, val: INT, complement: INT _ allOnes]; <> SetData: PUBLIC PROC [descr: Descriptor, name: ROPE, data: REF]; <<-- Find an item by name>> NameToItem: PUBLIC PROC [descr: Descriptor, name: ROPE] RETURNS [item: Item]; IsInDescr: PUBLIC PROC [descr: Descriptor, name: ROPE] RETURNS [yes: BOOL]; <<-- Enumeration procs (the order matters)>> ForEachItemProc: TYPE = PROC [item: Item]; EnumerateItems: PUBLIC PROC [descr: Descriptor, forEachItemDo: ForEachItemProc]; END.