File: Pga207.mesa
Christophe Cuenod March 24, 1989 11:13:25 am PST
Enables to generate the 207 pin parts (Cypress Sparc...) for EXPERT.
(generates 208 pins PGA but pad stack for pin one can be choosen nul)
Requires 1 input file: Filename.tioga and generates file Filename.part
(to be transformed by the NewPart program).
The file Filename.tioga has one line per defined pin. The line format is: PinName PinLocation (b12... ) PinType (I, O, D, ...) and SwapNumber. (i.e. A0 K2 O 0)
DIRECTORY
Commander USING [CommandProc, Register],
Convert USING [RopeFromCard],
Rope USING [Cat, Equal, Fetch, FromChar, Length, ROPE],
FS USING [StreamOpen],
IO USING [card, Close, EndOf, EndOfStream, GetInt, GetLineRope, GetTokenRope, int, PutF, RIS, rope, STREAM];
Pga207:
CEDAR
PROGRAM
IMPORTS IO, Commander, Convert, Rope, FS =
BEGIN
ROPE: TYPE = Rope.ROPE;
Pin:
TYPE =
RECORD [
pinName: ROPE,
pinLocation: ROPE,
pinSite: NAT,
pinType: ROPE,
pinSwap: NAT
];
PGAPinsRep: TYPE = ARRAY[1..pGASideSize] OF ARRAY[1..pGASideSize] OF Pin;
PGAPins: TYPE = REF PGAPinsRep;
pGASideSize: CARD ~ 17;
pGARows: CARD ~ 4;
pin1Pad: CARD ~ 28;
standardPad: CARD ~ 29;
powerPad: CARD ~ 30;
cornerPad: CARD ~ 31;
diameter: CARD ~ 19; -- Max diameter of the lead in mills
BadFile: SIGNAL [];
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;
};
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]];
};
InsertPin:
PROC [x:
CARD, y:
CARD, pga: PGAPins, out:
IO.
STREAM] ~ {
type, pad: INT;
SELECT
TRUE
FROM
Rope.Equal [pga[x][y].pinType, "U",
FALSE] => {
type ← 0;
pad ← standardPad;
};
Rope.Equal [pga[x][y].pinType, "I",
FALSE] => {
type ← 1;
pad ← standardPad;
};
Rope.Equal [pga[x][y].pinType, "O",
FALSE] => {
type ← 2;
pad ← standardPad;
};
Rope.Equal [pga[x][y].pinType, "D",
FALSE] => {
type ← 3;
pad ← standardPad;
};
Rope.Equal [pga[x][y].pinType, "P",
FALSE] => {
type ← 4;
pad ← powerPad;
};
Rope.Equal [pga[x][y].pinType, "G",
FALSE] => {
type ← 5;
pad ← powerPad;
};
ENDCASE => ERROR;
IF x = 1 AND y = 1 THEN pad ← pin1Pad;
IF x = pGASideSize AND y = 1 THEN pad ← cornerPad;
IF x = pGASideSize AND y = pGASideSize THEN pad ← cornerPad;
IF x = 1 AND y = pGASideSize THEN pad ← cornerPad;
IO.PutF[out, "%g %g ", IO.int[100*(x-1)], IO.int[100*(y-1)]];
IO.PutF[out, "%g %g ", IO.rope[pga[x][y].pinName], IO.int[pga[x][y].pinSwap]];
IO.PutF[out, "%g %g ", IO.int[diameter], IO.int[pga[x][y].pinSite]];
IO.PutF[out, "%g %g\n", IO.int[type], IO.int[pad]];
};
Pga207Proc: Commander.CommandProc =
BEGIN
GetLine:
PROC [] ~ {
firstToken, secondToken: ROPE;
firstToken ← IO.GetTokenRope[in ! IO.EndOfStream => CONTINUE].token;
secondToken ← IO.GetTokenRope[in ! IO.EndOfStream => CONTINUE].token;
IF firstToken =
NIL
OR secondToken =
NIL
THEN {
IO.PutF[cmd.out, "File %g is too short: line %g is missing or incomplete.\n",
IO.rope[Rope.Cat[fileName,".tioga"]], IO.card[i+1]];
SIGNAL BadFile[];
};
[x, y] ← XYFromRope[secondToken];
IF x < 1
OR pGASideSize < x
OR y < 1
OR pGASideSize < y
THEN {
IO.PutF[cmd.out, "Line %g: %g not a valid pin location.\n",
IO.card[i], IO.rope[secondToken]];
SIGNAL BadFile[];
};
IF
NOT Rope.Equal[pGAPins[x][y].pinName, "NC"]
THEN
ERROR;
try to assign twice the same pin!!
pGAPins[x][y].pinName ← firstToken;
pGAPins[x][y].pinLocation ← secondToken;
IF Rope.Equal[firstToken, "VCC",
FALSE]
OR
Rope.Equal[firstToken, "VCCO",
FALSE]
OR
Rope.Equal[firstToken, "VCCI",
FALSE]
OR
Rope.Equal[firstToken, "VCCT",
FALSE]
THEN {
pGAPins[x][y].pinSite ← 0; -- Site 0 = site 256
pGAPins[x][y].pinType ← "P"; -- Power
pGAPins[x][y].pinSwap ← 1;
}
ELSE
IF Rope.Equal[firstToken, "GND",
FALSE]
OR
Rope.Equal[firstToken, "VSSO",
FALSE]
OR
Rope.Equal[firstToken, "VSSI",
FALSE]
OR
Rope.Equal[firstToken, "VSST",
FALSE]
THEN {
pGAPins[x][y].pinSite ← 0; -- Site 0 = site 256
pGAPins[x][y].pinType ← "G"; -- Ground
pGAPins[x][y].pinSwap ← 1;
}
ELSE {
pGAPins[x][y].pinSite ← 1;
pGAPins[x][y].pinType ← IO.GetTokenRope[in ! IO.EndOfStream => CONTINUE].token;
pGAPins[x][y].pinSwap ← IO.GetInt[in ! IO.EndOfStream => CONTINUE];
};
[] ← IO.GetLineRope[in ! IO.EndOfStream => CONTINUE]; -- flush the end of the line
};
i: NAT;
x, y: CARD;
in: IO.STREAM;
out: IO.STREAM;
fault: BOOLEAN ← FALSE;
fileName: ROPE ← IO.GetTokenRope[IO.RIS[cmd.commandLine]].token;
pGAPins: PGAPins ← NEW[PGAPinsRep];
Filling the array with No Connect pins
FOR x
IN [1..pGASideSize]
DO
FOR y
IN [1..pGASideSize]
DO
pGAPins[x][y].pinName ← "NC";
pGAPins[x][y].pinLocation ← Location[x, y];
pGAPins[x][y].pinSite ← 0; -- Site 0 = site 256
pGAPins[x][y].pinType ← "U";
pGAPins[x][y].pinSwap ← 1;
ENDLOOP;
ENDLOOP;
Reading Input file:
in ← FS.StreamOpen[Rope.Cat[fileName,".tioga"]];
i ← 1;
WHILE
NOT
IO.EndOf[in]
DO
GetLine[! BadFile => {
fault ← TRUE;
CONTINUE;
}];
i ← i + 1;
ENDLOOP;
IF
NOT fault
THEN {
Writing output file
out ← FS.StreamOpen[Rope.Cat[fileName,".part"],$create];
IO.PutF[out, "4096 2048 -100 -100 1500 1500 700 -100 %g207 PARC-%g207 U\n",
IO.rope[fileName], IO.rope[fileName]];
FOR x
IN [1..pGARows]
DO
FOR y
IN [1..pGASideSize]
DO
InsertPin[x, y, pGAPins, out];
ENDLOOP;
ENDLOOP;
FOR x
IN [pGARows+1..pGASideSize-pGARows]
DO
FOR y
IN [1..pGARows]
DO
InsertPin[x, y, pGAPins, out];
ENDLOOP;
FOR y
IN [pGASideSize-pGARows+1..pGASideSize]
DO
InsertPin[x, y, pGAPins, out];
ENDLOOP;
ENDLOOP;
FOR x
IN [pGASideSize-pGARows+1..pGASideSize]
DO
FOR y
IN [1..pGASideSize]
DO
InsertPin[x, y, pGAPins, out];
ENDLOOP;
ENDLOOP;
IO.Close[out];
IO.PutF[cmd.out, "File %g.part Written\n", IO.rope[fileName]];
};
END;
Commander.Register[
key: "Pga207", proc: Pga207Proc, doc: "Transform the input file: \tFilename.tioga into: \n\t\tFilename.part (to be used by the NewPart program)."];
END.