// F U N C T I O N S F O R D0 L O G I C B O A R D
// Last Modified May 19, 1978 10:11 AM
// VDD and VEE on Row 19 moved due to stiffener

get "sysdefs.d"
get "gob.defs"

manifest
[
Mtype = $M-$A
]

external
[
BoardS
]


let BoardS() be
[
GetSVCoords=GetSVCoordsS
GetSVindex=GetSVindexS
SVoltReq = table [ 502; 502; 502 ; 0; 502 ]
NetHasSVolt = NetHasSvoltS
LegalBloc = LegalBlocS
ChiptoPinPos = ChiptoPinPosS
GetEpinCoords = GetEpinCoordsS
GetCpinCoords = GetCpinCoordsS
GetICcoords = GetICcoordsS
AddPotentialTerms = AddPotentialTermsS
FindBestTerm = ErrTfn
SetUpTerms = Nullfn
GetBoardPins = GetBoardPinsS
maxn = 19 //board locations 1-19
maxalph = $i-$a
TableZeroString = "*nZero Table At i1.10: <0> {8,8}*nZero Table At E98: <0> {8,500}*nZero Table At E2: <0> {412,500}*nZero Table At a1.1: <0> {412,8}"

]

and NetHasSvoltS(netname) = valof
[
if StEq("VCC",netname) then resultis $F
if StEq("GND",netname) then resultis $G
if StEq("VEE",netname) then resultis $M
if StEq("VDD",netname) then resultis $D
resultis 0
]

and GetSVindexS(SVType,bl,pin)=valof
[
let alph = bl rem 26
let alf = (bl rem 26) + $a
let num = bl/26
if ((num ge 1)&(num le 19)&(alf ge $a)&(alf le $i)) resultis bl
resultis 0
]

and GetSVCoordsS(SVType,SVIndex,cv) be
[
let alph = SVIndex rem 26
let num = SVIndex/26
let ald = 8 - alph
let alf = alph + $a
cv!0 = 8 + ald*44 + (alf le $d?16,0)
cv!1 = 8 + (num - 1)*24 + (num ge 8?12,0) + (num ge 12?12,0)
let row = (((num eq 5)%(num eq 10)%(num eq 15))?5,0) + (((num eq 8)%(num eq 12))&((alf ne $d)%(alf ne $i))?8,0)
switchon SVType into
[
case $G:
[
if (row eq 5) then
cv!0 = 4 + ald*48 - (alf le $h?16,0) + (alf le $d?16,0)
if (row eq 8) then
cv!0 = ald*52 - 32 - (alf le $d?36,0)
return
]
case $F:
[
cv!0 = cv!0 + 36
if (row eq 5) then
cv!0 = 28 + ald*48 + (alf le $d?16,0) - (alf eq $a?16,0)
if (row eq 8) then
cv!0 = 12 + ald*52 - (alf le $d?36,0)
cv!1 = cv!1 + 12
return
]
case $D:
case $M:
[
cv!1 = cv!1 + 4 + (SVType eq $M?4,0)
cv!0 = cv!0 + 4 + (SVType eq $D?28,0)
if ((row eq 5)&((alf ge $b)&(alf le $h))) then
cv!0 = ald*48 -8 + (alf le $d?16,0) + (SVType eq $D?32,0)
if ((row eq 5)&((alf eq $a)%(alf eq $i))) then
cv!1 = cv!1 - 24
if (row eq 8) then
[
cv!0 = ald*52 - 24 + (SVType eq $D?32,0) - (alf le $d?36,0)
cv!1 = cv!1 - 4 - (SVType eq $D?8,0)
]
if num eq 19 then cv!1 = cv!1 - (SVType eq $D?8,4)
return
]
]
]

and GetICcoordsS(alph,num,pin,cv) be
[
let boardloc = num*26 + alph
let tp = Boardvec!boardloc
let maxpins = tp>>icdesc.npins //max pins for chip
let alf = alph + $a
let ald = 8 - alph
let pint = (pin le (maxpins/2)?1,0)
let bpin = (pin le (maxpins/2)?((maxpins/2) - pin),(pin -1 - (maxpins/2)))
if (((num eq 8)%(num eq 12))&((alf ge $a)&(alf le $h)&(alf ne $d))) do
[
cv!0 = ald*52 - 32 + bpin*4 - (alf le $d?36,0)
cv!1 = (num gr 8?308,200) - ((pint eq 1)?12,0) - ((pint eq 1)&(maxpins eq 24)?12,0)

if (maxpins eq 22) then
ErrBL("*n22 pins IC assigned on row 8 or 12: ",boardloc)
return
]

if (((num eq 5)%(num eq 10)%(num eq 15))&((alf ge $a)&(alf le $i))) do
[
cv!0 = 4 + bpin*4 + ald*48 + (alf le $d?16,0) - (alf le $h?16,0)
cv!1 = 116 - ((pint eq 1)?12,0) - ((pint eq 1)&(maxpins eq 22)?4,0) + (num/7)*132
return
]

if ((num ge 1)&(num le 19)&(alf ge $a)&(alf le $i)) do
[
cv!0 = 8 + bpin*4 + ald*44 + (alf le $d?16,0)
cv!1 = 8 + ((pint eq 0)?12,0) + (num - 1)*24 + (num ge 8?12,0) + (num ge 12?12,0)
return
]

let v = vec 50; v!0 = 0 //bad board location
AppendS("*nBad BoardLoc, Pin: ",v)
AppendBL(26*num+alph, v)
AppendS(", ",v)
AppendN(pin,v)
WSS(ErFile,v)
cv!0=0
cv!1=0
]


and AddPotentialTermsS() be
[
//this function assigns svolt nodes to the corner pins of all TTL ICs
for alph = 0 to maxalph do
[
for n=1 to maxn do
[
let bl = 26*n + alph
let icptr = Boardvec!bl
if icptr eq 0 then loop
let ictype = icptr>>icdesc.ictype
let npins = icptr>>icdesc.npins //number of chip pins
let bpins = GetBoardPins(bl)
switchon ictype into
[
case Mtype: //Memory Storage IC with four volt pins
AddSVoltNode($M,bl,((npins/2) + 1))
AddSVoltNode($F,bl,1)
AddSVoltNode($D,bl,npins)
endcase

case Ntype: //N TTL
case Htype: //H TTL
case Stype: //S TTL
if (npins ls bpins) then AddSVoltNode($F,bl,npins)
endcase
]
]
]

]


and LegalBlocS(bl) = valof
[
let alph = (bl rem 26)+$a; let num = bl/26
if (alph eq $d)&((num eq 8)%(num eq 12)) then resultis false//d8 or d12 is illegal
if (alph eq $i)&((num eq 8)%(num eq 12)) then resultis false//i8 or i12 is illegal
if (alph gr $i) then resultis false //letter always le i
if (num eq 0)%(num gr 19) then resultis false //number always le 19
resultis true
]

and ChiptoPinPosS(boardloc,chippin) = valof
[
let tp = Boardvec!boardloc
let ictype = tp>>icdesc.ictype
let Halfmaxpins = (tp>>icdesc.npins)/2
if (ictype eq Mtype) then
[
test chippin gr Halfmaxpins
ifso resultis chippin - Halfmaxpins
ifnot resultis chippin + Halfmaxpins
]
resultis chippin
]

and GetCpinCoordsS(pin,cv) be
[
let pn = pin rem 100 - 1
let pd = pn rem 50
cv!0 = 0
cv!1 = 0
switchon pin/100 into
[
case 0:
[
if ((pd ge 19)&(pd le 36)) then cv!1 = 4
if ((pn ge 0)&(pn le 36)) then
cv!0 = table [ 312; 308; 304; 296; 292; 288; 284; 280; 276; 272;
268; 260; 256; 252; 248; 244; 240; 236; 232; 312;
308; 304; 292; 288; 284; 280; 276; 272; 268; 260;
256; 252; 248; 244; 240; 236; 232 ]!pn

if ((pn ge 50)&(pn le 86)) then
cv!0 = table [ 184; 180; 176; 172; 168; 164; 160; 156; 148; 144;
140; 136; 132; 128; 124; 116; 112; 108; 104; 184;
180; 176; 172; 168; 164; 160; 156; 148; 144; 140;
136; 132; 128; 124; 112; 108; 104 ]!pd

return
]
case 1:
[
if ((pd ge 19)&(pd le 36)) then cv!1 = 4
if ((pn ge 0)&(pn le 36)) then
cv!0 = table [ 232; 236; 240; 244; 248; 252; 256; 260; 268; 272;
276; 280; 284; 288; 292; 296; 304; 308; 312; 232;
236; 240; 244; 248; 252; 256; 260; 268; 272; 276;
280; 284; 288; 292; 304; 308; 312 ]!pn

if ((pn ge 50)&(pn le 86)) then
cv!0 = table [ 104; 108; 112; 116; 124; 128; 132; 136; 140; 144;
148; 156; 160; 164; 168; 172; 176; 180; 184; 104;
108; 112; 124; 128; 132; 136; 140; 144; 148; 156;
160; 164; 168; 172; 176; 180; 184 ]!pd

return
]

case 2:
[
if ((pd ge 13)&(pd le 24)) then cv!1 = 4
if ((pn ge 0)&(pn le 24)) then
cv!0 = table [ 284; 280; 276; 272; 268; 260; 256; 252; 248; 244;
240; 236; 232; 280; 276; 272; 268; 260; 256; 252;
248; 244; 240; 236; 232 ]!pn

if ((pn ge 50)&(pn le 74)) then
cv!0 = table [ 184; 180; 176; 172; 168; 164; 160; 156; 148; 144;
140; 136; 132; 184; 180; 176; 172; 168; 164; 160;
156; 148; 144; 140; 136 ]!pd

return
]

case 3:
[
if ((pd ge 13)&(pd le 24)) then cv!1 = 4
if ((pn ge 0)&(pn le 24)) then
cv!0 = table [ 232; 236; 240; 244; 248; 252; 256; 260; 268; 272;
276; 280; 284; 232; 236; 240; 244; 248; 252; 256;
260; 268; 272; 276; 280 ]!pn

if ((pn ge 50)&(pn le 74)) then
cv!0 = table [ 132; 136; 140; 144; 148; 156; 160; 164; 168; 172;
176; 180; 184; 136; 140; 144; 148; 156; 160; 164;
168; 172; 176; 180; 184 ]!pd

return
]

case 4:
[
if ((pd ge 8)&(pd le 14)) then cv!1 = 4
if ((pn ge 0)&(pn le 14)) then
cv!0 = table [ 328; 324; 320; 316; 312; 308; 304; 296; 328; 324;
320; 316; 312; 308; 304 ]!pn

if ((pn ge 50)&(pn le 74)) then
cv!0 = table [ 184; 180; 176; 172; 168; 164; 160; 156; 184; 180;
176; 172; 168; 164; 160 ]!pd

return
]

case 5:
[
if ((pd ge 8)&(pd le 14)) then cv!1 = 4
if ((pn ge 0)&(pn le 14)) then
cv!0 = table [ 296; 304; 308; 312; 316; 320; 324; 328; 304; 308;
312; 316; 320; 324; 328 ]!pn

if ((pn ge 50)&(pn le 74)) then
cv!0 = table [ 156; 160; 164; 168; 172; 176; 180; 184; 160; 164;
168; 172; 176; 180; 184 ]!pd

return
]

case 6:
[
if ((pd ge 8)&(pd le 14)) then cv!1 = 4
if ((pn ge 0)&(pn le 14)) then
cv!0 = table [ 260; 256; 252; 248; 244; 240; 236; 232; 256; 252;
248; 244; 240; 236; 232 ]!pn

if ((pn ge 50)&(pn le 74)) then
cv!0 = table [ 116; 112; 108; 104; 100; 96; 92; 88; 112; 108;
104; 100; 96; 92; 88 ]!pd

return
]

case 7:
[
if ((pd ge 8)&(pd le 14)) then cv!1 = 4
if ((pn ge 0)&(pn le 14)) then
cv!0 = table [ 232; 236; 240; 244; 248; 252; 256; 260; 232; 236;
240; 244; 248; 252; 256 ]!pn

if ((pn ge 50)&(pn le 74)) then
cv!0 = table [ 88; 92; 96; 100; 104; 108; 112; 116; 88; 92;
96; 100; 104; 108; 112 ]!pd

return
]

]
ErrN("*nSignal assigned to invalid I/O cable pin: ",pin)
]

and GetEpinCoordsS(pin,cv) be
[
if ((pin ls 1)%(pin gr 200)) then ErrN("*nSignal assigned to invalid Epin: ",pin)
if ((pin eq 1)%(pin eq 101)) then ErrN("*nSignal assigned to +12 volts power Epin: ",pin)
if ((pin eq 100)%(pin eq 200)) then ErrN("*nSignal assigned to -5 volts power Epin: ",pin)
let pv = pin rem 50
if ((pv eq 0)%(pv eq 1)) then ErrN("*nSignal assigned to +5 volts power Epin: ",pin)
let pg = pin rem 10
if (pg eq 0) then ErrN("*nSignal assigned to ground Epin: ",pin)
let px = 99 - (pin rem 100)
cv!0 = 4 + px*4 + (px le 48?0,20)
cv!1= 500 - ((pin - 1)/100)*4
]

and GetBoardPinsS(bl) = valof
[
let num = bl/26
let alph = bl rem 26
let n = alph*100 + num
if ((n eq 5)%(n eq 10)%(n eq 15)) then resultis 14
if ((n eq 805)%(n eq 810)%(n eq 815)) then resultis 14
if (((n ne 308)&(n ne 808)&(num eq 8))%((n ne 312)&(n ne 812)&(num eq 12))) then resultis 24
if ((num eq 5)%(num eq 10)%(num eq 15)) then resultis 22
if ((num ge 1)&(num le 19)&((alph + $a) ge $a)&((alph + $a) le $i)) then resultis 20
ErrBL("*nIllegal Board Location: ", bl)
resultis 0


]