DIRECTORY
 DoradoBoard
;

Fluke: CEDAR PROGRAM
EXPORTS DoradoBoard
= BEGIN
OPEN DoradoBoard;


scanCard: TYPE = [0..57];
pin: TYPE = [0..128];
rowType: TYPE = [0..11];


bMiny: INTEGER = 1310; --minimum y in main pattern
bMaxy: INTEGER = 14410;
bMinx: INTEGER = 4050; --minimum x in main pattern
bMaxx: INTEGER = 16150;
MaxRows: INTEGER= (bMaxy - bMiny)/50;
maxX: INTEGER = (bMaxx - bMinx)/50;

rowDesc: TYPE = RECORD[ sc: scanCard, p: pin, rt: rowType];
X: rowDesc = [0,0,0]; --no legal row at this y coordinate
rowRef: TYPE = REF Rows;
Rows: TYPE = ARRAY[0..MaxRows] OF rowDesc ← [

 [01,01,10],X,[01,93,10],X,X,

 [02,057,1],X,X,X,X,X,[03,037,2],X,X,[04,025,3],X,X,[04,128,4],X,X,X,X,X,[05,117,11],X,X,

 [06,105,1],X,X,X,X,X,[07,085,2],X,X,[08,073,3],X,X,[09,048,4],X,X,X,X,X,[10,037,11],X,X,

 [11,025,1],X,X,X,X,X,[12,005,2],X,X,[12,121,3],X,X,[13,096,4],X,X,X,X,X,[14,085,11],X,X,

 [15,073,1],X,X,X,X,X,[16,053,2],X,X,[17,041,3],X,X,[18,016,4],X,X,X,X,X,[19,005,11],X,X,

 [19,121,1],X,X,X,X,X,[20,101,2],X,X,[21,089,3],X,X,[22,064,4],X,X,X,X,X,[23,053,11],X,X,

 [24,041,1],X,X,X,X,X,[25,021,2],X,X,[26,009,3],X,X,[26,112,4],X,X,X,X,X,[27,101,11],X,X,

 [28,089,1],X,X,X,X,X,[29,069,2],X,X,[30,057,3],X,X,[31,032,4],X,X,X,X,X,[32,021,11],X,X,

 [33,009,1],X,[33,117,5],X,X,X,[34,037,2],X,X,[35,025,3],X,X,[35,128,4],X,[36,117,5],X,X,X,[37,037,11],X,X,

 [38,025,1],X,X,X,X,X,[39,005,2],X,X,[39,121,3],X,X,[40,096,4],X,X,X,X,X,[41,085,11],X,X,

 [42,073,6],X,X,X,X,X,[43,055,2],X,X,[44,043,7],X,X,[45,020,4],X,X,X,X,X,[46,009,11],X,X,

 [46,125,8],X,X,X,X,X,[47,111,2],X,X,[48,099,9],X,X,[49,081,4],X,X,X,X,X,[50,069,11],X,X,

 [51,057,1],X,X,X,X,X,[52,037,2],X,X,[53,025,3],X,X,[53,128,4],X,X,X,X,X,[54,117,11],X,X,

X,X,X,[55,105,10],X,[56,69,10]
 ];

chan: TYPE = INTEGER; --probe channel within a row+1 (or zero if there is no probe at that x.
probe: TYPE = ARRAY [0..maxX] OF chan; --index with x/50 to get channel number+1, or 0 if there
--is no probe at that x.
probeRef: TYPE = REF probe;

probeArray: TYPE = ARRAY rowType OF probeRef;

pArray: probeArray ← [

  NIL, --there really isn't a row type 0
  
  NEW[probe ← [
  0,
  0,-5,108,-1,107,0,106,0,105,0,
  104,0,103,0,102,0,101,0,100,0,
  99,0,0,0,98,0,97,0,96,0,
  95,0,94,0,93,0,92,0,91,0,
  0,0,90,0,89,0,88,0,87,0,
  86,0,85,0,84,-1,83,-5,82,-1,
  81,0,80,0,79,0,78,0,77,0,
  76,0,75,0,74,0,73,0,0,0,
  72,0,71,0,70,0,69,0,68,0,
  67,0,66,0,65,0,0,0,64,0,
  63,0,62,0,61,0,60,0,59,0,
  58,-1,57,-5,56,-1,55,0,0,0,
  0,0,0,0,-5,54,-1,53,0,52,
  0,51,0,50,0,49,0,48,0,47,
  0,46,0,45,0,0,0,44,0,43,
  0,42,0,41,0,40,0,39,0,38,
  0,37,0,0,0,36,0,35,0,34,
  0,33,0,32,0,31,0,30,-1,29,
  -5,28,-1,27,0,26,0,25,0,24,
  0,23,0,22,0,21,0,20,0,19,
  0,0,0,18,0,17,0,16,0,15,
  0,14,0,13,0,12,0,11,0,0,
  0,10,0,9,0,8,0,7,0,6,
  0,5,0,4,-1,3,-5,2,-1,1,
  0,0]], --type 1 row
  
  NEW[probe ← [
  0,
  0,-1,116,-2,115,0,114,0,113,0,
  112,0,111,0,110,0,109,0,108,0,
  107,-4,106,-2,105,0,104,0,103,0,
  102,0,101,0,100,0,99,0,98,-4,
  97,-2,96,0,95,0,94,0,93,0,
  92,0,91,0,90,0,89,-1,88,-2,
  87,0,86,0,85,0,84,0,83,0,
  82,0,81,0,80,0,79,-4,78,-2,
  77,0,76,0,75,0,74,0,73,0,
  72,0,71,0,70,-4,69,-2,68,0,
  67,0,66,0,65,0,64,0,63,0,
  62,0,61,-1,60,-2,59,0,0,0,
  0,0,0,0,-1,58,-2,57,0,56,
  0,55,0,54,0,53,0,52,0,51,
  0,50,0,49,-4,48,-2,47,0,46,
  0,45,0,44,0,43,0,42,0,41,
  0,40,-4,39,-2,38,0,37,0,36,
  0,35,0,34,0,33,0,32,0,31,
  -1,30,-2,29,0,28,0,27,0,26,
  0,25,0,24,0,23,0,22,0,21,
  -4,20,-2,19,0,18,0,17,0,16,
  0,15,0,14,0,13,0,12,-4,11,
  -2,10,0,9,0,8,0,7,0,6,
  0,5,0,4,0,3,-1,2,-2,1,
  0,0]], --type 2 row
  
  NEW[probe ← [
  -4,
  103,0,0,-3,102,0,101,0,100,0,
  99,0,98,0,97,0,96,0,95,0,
  94,0,0,0,93,0,92,0,91,0,
  90,0,89,0,88,0,87,0,86,0,
  0,0,85,0,84,0,83,0,82,0,
  81,0,80,0,79,-4,78,0,0,-3,
  77,0,76,0,75,0,74,0,73,0,
  72,0,71,0,70,0,69,0,0,0,
  68,0,67,0,66,0,65,0,64,0,
  63,0,62,0,61,0,0,0,60,0,
  59,0,58,0,57,0,56,0,55,0,
  54,-4,53,0,0,-3,52,0,0,0,
  0,0,0,0,0,0,-3,51,0,50,
  0,49,0,48,0,47,0,46,0,45,
  0,44,0,43,0,0,0,42,0,41,
  0,40,0,39,0,38,0,37,0,36,
  0,35,0,0,0,34,0,33,0,32,
  0,31,0,30,0,29,0,28,-4,27,
  0,0,-3,26,0,25,0,24,0,23,
  0,22,0,21,0,20,0,19,0,18,
  0,0,0,17,0,16,0,15,0,14,
  0,13,0,12,0,11,0,10,0,0,
  0,9,0,8,0,7,0,6,0,5,
  0,4,0,3,-4,2,0,0,-3,1,
  0,0]], --type 3 row
  
  NEW[probe ← [
  0,
  0,-1,117,0,116,0,115,0,114,0,
  113,0,112,0,111,0,110,0,109,0,
  108,-1,107,0,106,0,105,0,104,0,
  103,0,102,0,101,0,100,-1,99,-1,
  98,0,97,0,96,0,95,0,94,0,
  93,0,92,0,91,0,90,-1,89,0,
  88,0,87,0,86,0,85,0,84,0,
  83,0,82,0,81,0,80,-1,79,0,
  78,0,77,0,76,0,75,0,74,0,
  73,0,72,-1,71,-1,70,0,69,0,
  68,0,67,0,66,0,65,0,64,0,
  63,0,62,-1,61,0,60,0,0,0,
  0,0,0,0,-1,59,0,58,0,57,
  0,56,0,55,0,54,0,53,0,52,
  0,51,0,50,-1,49,0,48,0,47,
  0,46,0,45,0,44,0,43,0,42,
  -1,41,-1,40,0,39,0,38,0,37,
  0,36,0,35,0,34,0,33,0,32,
  -1,31,0,30,0,29,0,28,0,27,
  0,26,0,25,0,24,0,23,0,22,
  -1,21,0,20,0,19,0,18,0,17,
  0,16,0,15,0,14,-1,13,-1,12,
  0,11,0,10,0,9,0,8,0,7,
  0,6,0,5,0,4,-1,3,0,2,
  0,1]], --type 4 row
  
  NEW[probe ← [
  0,
  0,0,0,0,0,0,48,0,47,0,
  46,0,45,0,44,0,43,0,42,0,
  41,0,40,0,39,0,38,0,37,0,
  0,0,0,0,36,0,35,0,34,0,
  33,0,32,0,31,0,30,0,29,0,
  28,0,27,0,26,0,25,0,0,0,
  0,0,24,0,23,0,22,0,21,0,
  20,0,19,0,18,0,17,0,16,0,
  15,0,14,0,13,0,0,0,0,0,
  12,0,11,0,10,0,9,0,8,0,
  7,0,6,0,5,0,4,0,3,0,
  2,0,1,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0,0,0,0,0,0,0,0,0,
  0,0]], --type 5 row
  
  NEW[probe ← [
  0,
  0,-5,110,-1,109,0,108,0,107,0,
  106,0,105,0,104,0,103,0,102,0,
  101,0,100,0,99,0,98,0,97,0,
  96,0,95,0,94,0,93,0,92,0,
  91,0,90,0,89,0,88,0,87,0,
  86,0,85,0,84,-1,83,-5,82,-1,
  81,0,80,0,79,0,78,0,77,0,
  76,0,75,0,74,0,73,0,0,0,
  72,0,71,0,70,0,69,0,68,0,
  67,0,66,0,65,0,0,0,64,0,
  63,0,62,0,61,0,60,0,59,0,
  58,-1,57,-5,56,-1,55,0,0,0,
  0,0,0,0,-5,54,-1,53,0,52,
  0,51,0,50,0,49,0,48,0,47,
  0,46,0,45,0,0,0,44,0,43,
  0,42,0,41,0,40,0,39,0,38,
  0,37,0,0,0,36,0,35,0,34,
  0,33,0,32,0,31,0,30,-1,29,
  -5,28,-1,27,0,26,0,25,0,24,
  0,23,0,22,0,21,0,20,0,19,
  0,0,0,18,0,17,0,16,0,15,
  0,14,0,13,0,12,0,11,0,0,
  0,10,0,9,0,8,0,7,0,6,
  0,5,0,4,-1,3,-5,2,-1,1,
  0,0]], --type 6 row
  
  NEW[probe ← [
  -4,
  105,0,0,-3,104,0,103,0,102,0,
  101,0,100,0,99,0,98,0,97,0,
  96,0,95,0,94,0,93,0,92,0,
  91,0,90,0,89,0,88,0,87,0,
  86,0,85,0,84,0,83,0,82,0,
  81,0,80,0,79,-4,78,0,0,-3,
  77,0,76,0,75,0,74,0,73,0,
  72,0,71,0,70,0,69,0,0,0,
  68,0,67,0,66,0,65,0,64,0,
  63,0,62,0,61,0,0,0,60,0,
  59,0,58,0,57,0,56,0,55,0,
  54,-4,53,0,0,-3,52,0,0,0,
  0,0,0,0,0,0,-3,51,0,50,
  0,49,0,48,0,47,0,46,0,45,
  0,44,0,43,0,0,0,42,0,41,
  0,40,0,39,0,38,0,37,0,36,
  0,35,0,0,0,34,0,33,0,32,
  0,31,0,30,0,29,0,28,-4,27,
  0,0,-3,26,0,25,0,24,0,23,
  0,22,0,21,0,20,0,19,0,18,
  0,0,0,17,0,16,0,15,0,14,
  0,13,0,12,0,11,0,10,0,0,
  0,9,0,8,0,7,0,6,0,5,
  0,4,0,3,-4,2,0,0,-3,1,
  0,0]], --type 7 row
  
  NEW[probe ← [
  0,
  0,-5,114,-1,113,0,112,0,111,0,
  110,0,109,0,108,0,107,0,106,0,
  105,0,104,0,103,0,102,0,101,0,
  100,0,99,0,98,0,97,0,96,0,
  95,0,94,0,93,0,92,0,91,0,
  90,0,89,0,88,-1,87,-5,86,-1,
  85,0,84,0,83,0,82,0,81,0,
  80,0,79,0,78,0,77,0,76,0,
  75,0,74,0,73,0,72,0,71,0,
  70,0,69,0,68,0,67,0,66,0,
  65,0,64,0,63,0,62,0,61,0,
  60,-1,59,-5,58,-1,57,0,0,0,
  0,0,0,0,-5,56,-1,55,0,54,
  0,53,0,52,0,51,0,50,0,49,
  0,48,0,47,0,46,0,45,0,44,
  0,43,0,42,0,41,0,40,0,39,
  0,38,0,37,0,36,0,35,0,34,
  0,33,0,32,0,31,0,30,-1,29,
  -5,28,-1,27,0,26,0,25,0,24,
  0,23,0,22,0,21,0,20,0,19,
  0,0,0,18,0,17,0,16,0,15,
  0,14,0,13,0,12,0,11,0,0,
  0,10,0,9,0,8,0,7,0,6,
  0,5,0,4,-1,3,-5,2,-1,1,
  0,0]], --type 8 row
  
  NEW[probe ← [
  -4,
  109,0,0,-3,108,0,107,0,106,0,
  105,0,104,0,103,0,102,0,101,0,
  100,0,99,0,98,0,97,0,96,0,
  95,0,94,0,93,0,92,0,91,0,
  90,0,89,0,88,0,87,0,86,0,
  85,0,84,0,83,-4,82,0,0,-3,
  81,0,80,0,79,0,78,0,77,0,
  76,0,75,0,74,0,73,0,72,0,
  71,0,70,0,69,0,68,0,67,0,
  66,0,65,0,64,0,63,0,62,0,
  61,0,60,0,59,0,58,0,57,0,
  56,-4,55,0,0,-3,54,0,0,0,
  0,0,0,0,0,0,-3,53,0,52,
  0,51,0,50,0,49,0,48,0,47,
  0,46,0,45,0,44,0,43,0,42,
  0,41,0,40,0,39,0,38,0,37,
  0,36,0,35,0,34,0,33,0,32,
  0,31,0,30,0,29,0,28,-4,27,
  0,0,-3,26,0,25,0,24,0,23,
  0,22,0,21,0,20,0,19,0,18,
  0,0,0,17,0,16,0,15,0,14,
  0,13,0,12,0,11,0,10,0,0,
  0,9,0,8,0,7,0,6,0,5,
  0,4,0,3,-4,2,0,0,-3,1,
  0,0]], --type 9 row
   
  NEW[probe ← [
  0,
  0,0,0,0,0,0,0,0,0,0,0,0,0,
  92,0,91,0,0,90,0,89,0,0,
  88,0,87,0,0,86,0,85,0,0,
  84,0,83,0,0,82,0,81,0,0,
  80,0,79,0,0,78,0,77,0,0,
  76,0,75,0,0,74,0,73,0,0,
  72,0,71,0,0,70,0,69,0,0,
  68,0,67,0,0,66,0,65,0,0,
  64,0,63,0,0,62,0,61,0,0,
  60,0,59,0,0,58,0,57,0,0,
  56,0,55,0,0,54,0,53,0,0,
  52,0,51,0,0,50,0,49,0,0,
  48,0,47,0,0,46,0,45,0,0,
  44,0,43,0,0,42,0,41,0,0,
  40,0,39,0,0,38,0,37,0,0,
  36,0,35,0,0,34,0,33,0,0,
  32,0,31,0,0,30,0,29,0,0,
  28,0,27,0,0,26,0,25,0,0,
  24,0,23,0,0,22,0,21,0,0,
  20,0,19,0,0,18,0,17,0,0,
  16,0,15,0,0,14,0,13,0,0,
  12,0,11,0,0,10,0,09,0,0,
  08,0,07,0,0,06,0,05,0,0,
  04,0,03,0,0,02,0,01,0]],--type 10 row
  
  NEW
[probe ← [
  0,
  0,0,116,-2,115,0,114,0,113,0,
  112,0,111,0,110,0,109,0,108,0,
  107,-1,106,-2,105,0,104,0,103,0,
  102,0,101,0,100,0,99,0,98,-1,
  97,-2,96,0,95,0,94,0,93,0,
  92,0,91,0,90,0,89,0,88,-2,
  87,0,86,0,85,0,84,0,83,0,
  82,0,81,0,80,0,79,-1,78,-2,
  77,0,76,0,75,0,74,0,73,0,
  72,0,71,0,70,-1,69,-2,68,0,
  67,0,66,0,65,0,64,0,63,0,
  62,0,61,0,60,-2,59,0,0,0,
  0,0,0,0,0,58,-2,57,0,56,
  0,55,0,54,0,53,0,52,0,51,
  0,50,0,49,-1,48,-2,47,0,46,
  0,45,0,44,0,43,0,42,0,41,
  0,40,-1,39,-2,38,0,37,0,36,
  0,35,0,34,0,33,0,32,0,31,
  0,30,-2,29,0,28,0,27,0,26,
  0,25,0,24,0,23,0,22,0,21,
  -1,20,-2,19,0,18,0,17,0,16,
  0,15,0,14,0,13,0,12,-1,11,
  -2,10,0,9,0,8,0,7,0,6,
  0,5,0,4,0,3,0,2,-2,1,
  0,0]] --type 11 row
  ];

  
cardRows: rowRef ← NEW[Rows];

ASItoFluke: PUBLIC PROC[x,y: INTEGER] RETURNS [pt: PadType ← [noProbe,0]] =

TRUSTED BEGIN

 rd: rowDesc;
 ch: INTEGER;

IF y<bMiny OR y>bMaxy THEN RETURN;
IF x<bMinx OR x>bMaxx THEN
  SELECT y FROM --The power pins at the corners of the board are handled
  --as a special case, since several pins on the board are considered connected
  --and are probed by a single probe.
   1310 => { SELECT x FROM
      4000 => RETURN[pt ←[vee,7203]];
      16350 => RETURN[pt ←[vcc,7202]];
      ENDCASE => RETURN};
   14410 => { SELECT x FROM
      4000 => RETURN[pt ←[vtt,7200]];
      16350 => RETURN[pt ←[vdd,7201]];
      ENDCASE => RETURN};
   ENDCASE => RETURN;

 y ← y-bMiny;
IF y MOD 50 # 0 THEN RETURN; --not on 50 mil grid
 y ← y/50;

 x ← x - bMinx;
IF x MOD 50 # 0 THEN RETURN;
 x ← x/50;
 rd ← cardRows[y];
IF rd.rt = 0 THEN RETURN;
 ch ← pArray[rd.rt][x];
IF ch = 0 THEN RETURN;
 pt.n ← ch + rd.p + 128*(rd.sc-1) - 2; --the -2 is because both ch and rd.p are 1-origined
 pt.t ← SELECT pArray[rd.rt][x-1] FROM
   0 => signal,
  -1 => gnd,
  -2 => vee,
  -3 => vdd,
  -4 => vtt,
  -5 => vcc,
  ENDCASE => noProbe;
  
END;


END.