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]]
]];
};