PGACoordXlateImpl.mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Don Curry August 29, 1988 9:01:17 pm PDT
DIRECTORY
Convert, IO, PGACoordXlate, Rope;
PGACoordXlateImpl: CEDAR PROGRAM
IMPORTS Convert, IO, Rope
EXPORTS PGACoordXlate
~ BEGIN
Types
PGACoord: TYPE = PGACoordXlate.PGACoord;
Letter:  TYPE = PGACoordXlate.Letter;
Index:   TYPE = PGACoordXlate.Index;
SignalPins: TYPE = PGACoordXlate.SignalPins;
Table:   TYPE = REF TableRec;
TableRec:  TYPE = RECORD[
fixed: LIST OF SignalPins,
seq: SEQUENCE size: NAT OF PGACoord]; -- coord rng is elem 0
Rope PGACoord XLate
RopeToPGACoord: PUBLIC PROC[rope: IO.ROPE] RETURNS [coord: PGACoord] = {
char: CHAR ← rope.Fetch[];
int: INT ← Convert.IntFromRope[rope.Substr[1]];
coord ← [CharToLetter[char], int]};
PGACoordToRope: PUBLIC PROC[coord: PGACoord] RETURNS [rope: IO.ROPE] = {
rope ← IO.PutFR["%g%02g", IO.char[LetterToChar[coord.let]], IO.int[coord.idx]]};
Pin PGACoord XLate
PinToPGACoord: PUBLIC PROC[key: ATOM, pin: NAT] RETURNS [coord: PGACoord] = {
table: Table ← GetTable[ key];
RETURN[table[pin]]};
PGACoordToPin: PUBLIC PROC[key: ATOM, coord: PGACoord] RETURNS [pin: NAT𡤀] = {
table: Table ← GetTable[ key];
FOR i: NAT IN [1..table.size) DO IF table[i]=coord THEN RETURN[i] ENDLOOP};
PGAFixedPins: PUBLIC PROC[key: ATOM] RETURNS [fixed: LIST OF SignalPins ← NIL] = {
RETURN[CopySignalPinList[GetTable[key].fixed]]};
GetTable: PROC[key: ATOM] RETURNS[table: Table] = {
table ← SELECT key FROM
$PGA176A => table176,
$PGA300A => table300,
$PGA240A => table240,
ENDCASE  => ERROR};
CopySignalPinList: PROC[sigs: LIST OF SignalPins ← NIL]
RETURNS[copy: LIST OF SignalPins ← NIL]= {
IF sigs=NIL THEN RETURN[NIL];
RETURN[CONS[[sigs.first.nm, CopyPins[sigs.first.pins]], CopySignalPinList[sigs.rest]]]};
CopyPins: PROC[pins: LIST OF NAT] RETURNS[copy: LIST OF NATNIL]= {
IF pins=NIL THEN RETURN[NIL];
RETURN[CONS[pins.first, CopyPins[pins.rest]]]};
Table $PGA176A
table176: Table ← NIL;
Init176: PROC = {
Def: PROC[let: Letter, elems: LIST OF NAT] = {
FOR col: Index IN Index WHILE elems#NIL DO
IF elems.first#0 THEN {
IF table176[elems.first]#[z, 25] THEN ERROR;
table176[elems.first] ← [let, col]};
elems ← elems.rest ENDLOOP};
gnd:  SignalPins ← [nm: "Gnd",  pins: LIST
[146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176]];
vdd:  SignalPins ← [nm: "Vdd",  pins: LIST
[147, 149, 151, 155, 157, 159, 163, 165, 167, 171, 173, 175]];
table176  ← NEW[TableRec[176+1]];
table176.fixed ← LIST[gnd, vdd];
FOR pin: NAT IN [1..table176.size) DO table176[pin] ← [z, 25] ENDLOOP;
table176[0] ← [q, 15];
Def[ a,LIST[142, 1, 3, 6, 9, 12, 15, 16, 19, 20, 22, 25, 28, 31, 34]];
Def[ b,LIST[139,143, 2, 5, 8, 11, 14, 17, 21, 23, 26, 29, 32, 35, 37]];
Def[ c,LIST[136,140,144, 4, 7, 10, 13, 18, 24, 27, 30, 33, 36, 38, 39]];
Def[ d,LIST[133,137,141,145,146,147,148,149,150,151,152,153, 40, 41, 42]];
Def[ e,LIST[130,134,138,176, 0, 0, 0, 0, 0, 0, 0,154, 43, 44, 45]];
Def[ f,LIST[128,131,135,175, 0, 0, 0, 0, 0, 0, 0,155, 46, 47, 48]];
Def[ g,LIST[127,129,132,174, 0, 0, 0, 0, 0, 0, 0,156, 49, 50, 51]];
Def[ h,LIST[124,125,126,173, 0, 0, 0, 0, 0, 0, 0,157, 54, 53, 52]];
Def[ j,LIST[123,122,121,172, 0, 0, 0, 0, 0, 0, 0,158, 60, 57, 55]];
Def[ k,LIST[120,119,118,171, 0, 0, 0, 0, 0, 0, 0,159, 63, 59, 56]];
Def[ l,LIST[117,116,115,170, 0, 0, 0, 0, 0, 0, 0,160, 66, 62, 58]];
Def[ m,LIST[114,113,112,169,168,167,166,165,164,163,162,161, 69, 65, 61]];
Def[ n,LIST[111,110,108,105,102, 99, 96, 90, 85, 82, 79, 76, 72, 68, 64]];
Def[ p,LIST[109,107,104,101, 98, 95, 93, 89, 86, 83, 80, 77, 74, 71, 67]];
Def[ q,LIST[106,103,100, 97, 94, 92, 91, 88, 87, 84, 81, 78, 75, 73, 70]];
ValidateTable[table176]};
Table $PGA300A
table300: Table ← NIL;
Init300: PROC = {
Def: PROC[let: Letter, elems: LIST OF NAT] = {
FOR col: Index IN Index WHILE elems#NIL DO
IF elems.first#0 THEN {
IF table300[elems.first]#[z, 25] THEN ERROR;
table300[elems.first] ← [let, col]};
elems ← elems.rest ENDLOOP};
gnd:  SignalPins ← [nm: "Gnd",  pins: LIST
[270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300]];
vdd:  SignalPins ← [nm: "Vdd",  pins: LIST
[269, 271, 273, 275, 277, 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299]];
table300  ← NEW[TableRec[300+1]];
table300.fixed ← LIST[gnd, vdd];
FOR pin: NAT IN [1..table300.size) DO table300[pin] ← [z, 25] ENDLOOP;
table300[0] ← [v, 20];
Def[ a,LIST[263, 7, 11, 12, 16, 19, 22, 25, 29, 30, 37, 38, 42, 45, 48, 51, 55, 56, 60, 62]];
Def[ b,LIST[261, 5, 2, 8, 13, 17, 20, 24, 28, 33, 34, 39, 43, 47, 50, 54, 59, 65, 72, 74]];
Def[ c,LIST[257,266,267, 3, 9, 14, 18, 23, 27, 32, 35, 40, 44, 49, 53, 58, 64, 66, 69, 78]];
Def[ d,LIST[256,260,265, 1, 4, 10, 15, 21, 26, 31, 36, 41, 46, 52, 57, 63, 68, 70, 75, 79]];
Def[ e,LIST[252,255,259,264,268, 6,269,270,271,272,273,274,275,276, 61, 67, 71, 76, 80, 83]];
Def[ f,LIST[249,251,254,258,262, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 77, 81, 84, 86]];
Def[ g,LIST[247,248,250,253,300, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,277, 82, 85, 87, 89]];
Def[ h,LIST[243,244,245,246,299, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,278, 88, 90, 91, 92]];
Def[ j,LIST[239,240,241,242,298, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,279, 93, 94, 95, 96]];
Def[ k,LIST[238,235,236,237,297, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,280, 98, 99,100, 97]];
Def[ l,LIST[231,234,233,232,296, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,281,103,102,101,104]];
Def[ m,LIST[230,229,228,227,295, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,282,108,107,106,105]];
Def[ n,LIST[226,225,224,222,294, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,283,113,111,110,109]];
Def[ p,LIST[223,221,219,216,293, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,284,119,116,114,112]];
Def[ q,LIST[220,218,215,211,207, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,124,120,117,115]];
Def[ r,LIST[217,214,210,205,201,195,292,291,290,289,288,287,286,285,140,134,130,125,121,118]];
Def[ s,LIST[213,209,204,202,197,191,186,180,175,170,165,160,155,149,144,138,135,131,126,122]];
Def[ t,LIST[212,203,200,198,192,187,183,178,174,169,166,161,157,152,148,143,137,133,132,123]];
Def[ u,LIST[208,206,199,193,188,184,181,177,173,168,167,162,158,154,151,147,142,136,139,127]];
Def[ v,LIST[196,194,190,189,185,182,179,176,172,171,164,163,159,156,153,150,146,145,141,129]];
ValidateTable[table300]};
Table $PGA240A
table240: Table ← NIL;
Init240: PROC = {
Def: PROC[let: Letter, elems: LIST OF NAT] = {
FOR col: Index IN Index WHILE elems#NIL DO
IF elems.first#0 THEN {
IF table240[elems.first]#[z, 25] THEN ERROR;
table240[elems.first] ← [let, col]};
elems ← elems.rest ENDLOOP};
unused: LIST OF NAT;
table240  ← NEW[TableRec[240+1]];
table240.fixed ← NIL;
FOR pin: NAT IN [1..table240.size) DO table240[pin] ← [z, 25] ENDLOOP;
table240[0] ← [q, 15];
Def[ a,LIST[107, 80, 77, 74, 71, 68, 65, 62, 59, 56, 53, 50, 47, 44, 17]];
Def[ b,LIST[110, 92, 89, 83, 79, 73, 67, 61, 52, 41, 35, 29, 26, 13, 14]];
Def[ c,LIST[113, 98, 95, 86, 82, 76, 70, 58, 49, 38, 32, 23, 20, 10, 11]];
Def[ d,LIST[116,103,101, 87, 84, 75, 60, 45, 46, 34, 31, 22, 21, 7, 8]];
Def[ e,LIST[119,104,100, 94, 85, 78, 57, 39, 40, 28, 25, 19, 16, 4, 5]];
Def[ f,LIST[122,109,106, 97, 91, 88, 64, 55, 37, 24, 33, 15, 9, 1, 2]];
Def[ g,LIST[125,115,112,114,111,108,105, 43, 42, 18, 12, 6, 3,238,239]];
Def[ h,LIST[128,124,121,129,118,117,123, 66, 30,240,237,231,234,235,236]];
Def[ j,LIST[131,127,130,135,141,132,150,126, 27,216,219,228,225,232,233]];
Def[ k,LIST[134,133,136,138,147,159,168,162,210,201,213,217,222,229,230]];
Def[ l,LIST[137,139,142,153,156,165,171,192,189,195,207,208,214,226,227]];
Def[ m,LIST[140,145,148,157,163,169,174,183,186,198,204,202,211,223,224]];
Def[ n,LIST[143,151,154,160,166,172,177,180,187,193,196,199,205,220,221]];
Def[ p,LIST[146,152,158,164,170,175,178,181,184,190,194,200,206,212,218]];
Def[ q,LIST[149,155,161,167,173,176,179,182,185,188,191,197,203,209,215]];
unused←LIST[ 36, 48, 51, 54, 63, 69, 72, 81, 90, 93, 96, 99,102,120,144];
ValidateTable[table240, unused]};
Utils
Signal: SIGNAL[i: NAT] = CODE;
CharToLetter: PROC[char: CHAR] RETURNS [let: Letter] = {
nat: NAT;
IF char IN['a..'z] THEN char ← char -'a +'A;
nat ← SELECT char FROM
IN ['A..'I)  => char-0-'A,
IN ('I..'O)  => char-1-'A,
IN ('O..'Z] => char-2-'A,
ENDCASE  => ERROR;
let ← VAL[nat]};
LetterToChar: PROC[let: Letter] RETURNS [char: CHAR] = {
char ← SELECT let FROM
IN [a..h] => 'A + let.ORD,
IN [j..n] => 'A + let.ORD+1,
IN [p..z] => 'A + let.ORD+2,
ENDCASE => ERROR};
ValidateTable: PROC[table: Table, unused: LIST OF NATNIL] = {
FOR i: NAT IN [1..table.size) DO
IF table[i]=[z, 25]
THENIF unused=NIL OR unused.first#i
THEN Signal[i]
ELSE unused ← unused.rest
ELSEFOR j: NAT IN (i..table.size) DO
IF table[i]=table[j] THEN ERROR ENDLOOP ENDLOOP;
IF unused#NIL THEN ERROR};
Init176[];
Init300[];
Init240[];
END.