CoreDecoderImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Barth, August 23, 1985 2:57:23 pm PDT
DIRECTORY Core, CoreOps, CoreProperties, CoreDecoder;
CoreDecoderImpl: CEDAR PROGRAM
IMPORTS CoreOps, CoreProperties
EXPORTS CoreDecoder =
BEGIN OPEN Core, CoreDecoder;
decoderCellClass: PUBLIC CellClass ← NEW[CellClassRec ← [name: "Decoder", recast: Recast, write: Write, read: Read]];
Start: PROC = {
CoreOps.RegisterCellClass[decoderCellClass];
decoderCellClass.properties ← CoreProperties.PutProp[on: decoderCellClass.properties, prop: CoreOps.printClassProcProp, value: NEW[CoreOps.PrintClassProc ← PropPrintClass]];
};
Write: WriteProc = {
};
Read: ReadProc = {
};
Recast: RecastProc = {
decCell: DecoderCellType ← NARROW[me.data];
recCell: CoreRecord.RecordCellType ← NEW[CoreRecord.RecordCellTypeRec];
new ← NEW[CellTypeRec ← [
name: me.name,
class: CoreRecord.recordCellClass,
publicWire: CoreOps.CopyWire[wire: me.publicWire],
data: recCell,
properties: CoreProperties.CopyProps[propList: me.properties]]];
recCell.internalWire ← NEW[WireRec ← [
structure: record,
elements: NEW[WireSequenceRec[new.publicWire.elements.size + 1]]]];
FOR w: NAT IN [0..new.publicWire.elements.size) DO
recCell.internalWire.elements[w] ← new.publicWire.elements[w];
ENDLOOP;
recCell.internalWire.elements[recCell.internalWire.elements.size - 1] ← CoreOps.CreateSequenceWire[count: decCell.wordCount, base: CoreOps.CreateSequenceWire[count: decCell.bitCount - 1, base: CoreOps.CreateAtomWire[]]];
FOR word: NAT IN [0..decCell.wordCount) DO
FOR bit: NAT IN [0..decCell.bitCount) DO
bitCell: CellType ← decCell.cellTypes[decCell.select[word, bit, decCell]];
newActual: Wire ← NEW[WireRec ← [
structure: record,
elements: NEW[WireSequenceRec[bitCell.publicWire.elements.size]]]];
newActual.elements[0] ← recCell.internalWire.elements[0];
newActual.elements[1] ← recCell.internalWire.elements[1];
newActual.elements[2] ← recCell.internalWire.elements[2].elements[bit];
newActual.elements[3] ← recCell.internalWire.elements[3].elements[bit];
newActual.elements[4] ← recCell.internalWire.elements[4].elements[word];
newActual.elements[5] ← IF bit=0 THEN recCell.internalWire.elements[1] ELSE recCell.internalWire.elements[5].elements[word].elements[bit-1];
newActual.elements[6] ← IF bit=decCell.bitCount-1 THEN recCell.internalWire.elements[4].elements[word] ELSE recCell.internalWire.elements[5].elements[word].elements[bit];
recCell.instances ← CONS[
NEW[CoreRecord.CellInstanceRec ← [
name: IF bitCell.name=NIL THEN NIL ELSE IO.PutFR["%g%gx%g", IO.rope[bitCell.name], IO.int[word], IO.int[bit]],
actualWire: newActual,
type: bitCell]],
recCell.instances];
ENDLOOP;
ENDLOOP;
};
Create: PUBLIC PROC [decoderCellType: DecoderCellType, name: ROPENIL] RETURNS [cellType: CellType] = {
cellType ← NEW[CellTypeRec ← [
name: name,
class: decoderCellClass,
publicWire: CoreOps.CreateRecordWire[components: LIST [
CoreOps.CreateAtomWire["Vdd"],
CoreOps.CreateAtomWire["Gnd"],
CoreOps.CreateSequenceWire[name: "AdrBit", base: CoreOps.CreateAtomWire[], count: decoderCellType.bitCount],
CoreOps.CreateSequenceWire[name: "nAdrBit", base: CoreOps.CreateAtomWire[], count: decoderCellType.bitCount],
CoreOps.CreateSequenceWire[name: "nDecode", base: CoreOps.CreateAtomWire[], count: decoderCellType.wordCount]]],
data: decoderCellType]]
};
PropPrintClass: CoreOps.PrintClassProc = {Print[NARROW[data], out]};
Print: PUBLIC PROC [decoderCellType: DecoderCellType, out: STREAM] = {
};
Start[];
END.