DemoDecoder.mesa
Copyright © 1985-1986 by Xerox Corporation. All rights reversed.
Created by: Monier, May 9, 1985 11:18:58 pm PDT
Bertrand Serlet February 17, 1986 11:09:14 am PST
DIRECTORY PW, TerminalIO;
DemoDecoder: CEDAR PROGRAMIMPORTS PW, TerminalIO =
BEGIN OPEN PW;
Generate: UserProc = {
zero: Object ← Get[design, "zero"];
one: Object ← Get[design, "one"];
left: Object ← Get[design, "left"];
right: Object ← Get[design, "right"];
DecGen: PROC [n: INT] RETURNS [decoder: Object] = {
IF n=0
THEN RETURN [NIL]
ELSE {
subDecoder: Object ← DecGen [n-1];
decoder ← AbutY[
AbutX [ArrayY [zero, TwoToThe[n-1]], subDecoder],
AbutX [ArrayY [one, TwoToThe[n-1]], subDecoder]
];
};
};
n: INT ← TerminalIO.RequestInt["How many bits in the decoder? "];
RETURN [AbutX [
ArrayY [left, TwoToThe[n]],
DecGen [n],
ArrayY [right, TwoToThe[n]]
]];
};
Register[Generate, "Decoder"];
END.