SparcPinNameConvert.mesa
Christophe Cuenod April 6, 1989 1:43:22 pm PDT
Generates a conversion table for the Cypress Sparc pins
DIRECTORY
Commander USING [CommandProc, Register],
Convert USING [RopeFromCard],
Rope USING [Cat, Fetch, FromChar, Length, ROPE],
FS USING [StreamOpen],
IO USING [card, Close, PutF, rope, STREAM];
SparcPinNameConvert: CEDAR PROGRAM
IMPORTS IO, Commander, Convert, Rope, FS =
BEGIN
ROPE: TYPE = Rope.ROPE;
pGASideSize: CARD ~ 17;
pGARows: CARD ~ 4;
Location: PROC [x, y: CARD] RETURNS [location: ROPE] ~ {
c: CHAR;
SELECT x FROM-- SOME LETTERS ARE MISSING IN THE NUMBERING
IN [1..8] => c ← x - 1 + 'A + 0;
IN [9..13] => c ← x - 1 + 'A + 1;
= 14 => c ← x - 1 + 'A + 2;
= 15 => c ← x - 1 + 'A + 3;
IN [16..17] => c ← x - 1 + 'A + 4;
ENDCASE => ERROR;
location ← Rope.Cat[Rope.FromChar[c], Convert.RopeFromCard[y]];
};
XYFromRope: PROC [location: ROPE] RETURNS [x, y: CARD] ~ {
c: CHAR;
SELECT Rope.Length[location] FROM-- verify the correct length
= 2 => {
y ← Rope.Fetch[location, 1] - '0;
};
= 3 => {
y ← (Rope.Fetch[location, 1] - '0) * 10 + Rope.Fetch[location, 2] - '0;
};
ENDCASE => ERROR;
c ← Rope.Fetch[location, 0]; -- Takes first character
SELECT c FROM-- SOME LETTERS ARE MISSING IN THE NUMBERING
IN ['A..'H] => x ← c - 'A + 1 - 0;
IN ['J..'N] => x ← c - 'A + 1 - 1;
= 'P => x ← c - 'A + 1 - 2;
= 'R => x ← c - 'A + 1 - 3;
IN ['T..'U] => x ← c - 'A + 1 - 4;
ENDCASE => ERROR;
};
SparcPinNameConvertProc: Commander.CommandProc = BEGIN
i: CARD;
x, y: CARD;
out: IO.STREAM;
out ← FS.StreamOpen["SparcPinNameConvert.tioga",$create];
i ← 1;
FOR x IN [1..pGARows] DO
FOR y IN [1..pGASideSize] DO
IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]];
i ← i + 1;
ENDLOOP;
ENDLOOP;
FOR x IN [pGARows+1..pGASideSize-pGARows] DO
FOR y IN [1..pGARows] DO
IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]];
i ← i + 1;
ENDLOOP;
FOR y IN [pGASideSize-pGARows+1..pGASideSize] DO
IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]];
i ← i + 1;
ENDLOOP;
ENDLOOP;
FOR x IN [pGASideSize-pGARows+1..pGASideSize] DO
FOR y IN [1..pGASideSize] DO
IO.PutF[out, "%g %g\n", IO.card[i], IO.rope[Location[x, y]]];
i ← i + 1;
ENDLOOP;
ENDLOOP;
IO.Close[out];
END;
Commander.Register[
key: "SparcPinNameConvert", proc: SparcPinNameConvertProc];
END.