// F U N C T I O N S F O R PIM L O G I C B O A R D
// Last Modified February 3, 1979 12:41 PM
// #1: Exchange Epins from num to ((num + 50) rem 100)
// #2: Add VCC and GND connections for the Jumbo’s
// #3: correct voltage pins at d7, d11, & d14 --- use those for c’s

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

manifest
[
Mtype = $M-$A
]

external
[
BoardP
]

static
[
Check
]

let BoardP() be
[
GetSVCoords=GetSVCoordsP
GetSVindex=GetSVindexP
SVoltReq = table [ 598; 598; 598 ; 0; 598 ]
NetHasSVolt = NetHasSvoltP
LegalBloc = LegalBlocP
ChiptoPinPos = ChiptoPinPosP
GetEpinCoords = GetEpinCoordsP
GetCpinCoords = GetCpinCoordsP
GetICcoords = GetICcoordsP
AddPotentialTerms = AddPotentialTermsP
FindBestTerm = ErrTfn
SetUpTerms = Nullfn
GetBoardPins = GetBoardPinsP
maxn = 20 //board locations 1-20
maxalph = $g-$a
TableZeroString = "*nZero Table At a20.20: <0> {0,0}*nZero Table At a2.1: <0> {0,480}*nZero Table At g2.8: <0> {292,480}*nZero Table At g20.9: <0> {292,0}"
let Check = 0
]

and NetHasSvoltP(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 ChiptoPinPosP(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 GetSVindexP(SVType,bl,pin) = valof
[
let alph = bl rem 26
let alf = (bl rem 26) + $a
let num = bl/26
if ((alf eq $d)&((num eq 7)%(num eq 11)%(num eq 14))) then resultis (bl-1)
if ((num ge 1)&(num le 20)&(alf ge $a)&(alf le $g)) resultis bl
resultis 0
]

and GetSVCoordsP(SVType,SVIndex,cv) be
[
let alph = SVIndex rem 26
let num = SVIndex/26
let alf = alph + $a
let Top = ((alf ge $a)&(alf le $d)&(num ge 2)&(num le 20))
let Bot = ((alf ge $e)&(alf le $g)&(num ge 1)&(num le 20))
let Col7s = ((num eq 7)%(num eq 11)%(num eq 14))
cv!0 = 36 + alph*44
// basic GND coords for dips in Top and Regular
cv!1 = 528 - num*24 - ((num ge 8)?12,0) - ((num ge 12)?12,0) - ((num ge 15)?12,0)
let Gndcv = (alf eq $b?76,0)+(alf eq $c?128,0)+(alf eq $d?128,0)+(alf eq $e?196,0)+(alf eq $f?248,0)
let cmpsat = (num eq 11?108,0) + (num eq 14?192,0)
switchon SVType into
[
case $G:
[
if (Bot & (not Col7s)) then
[
cv!0 = cv!0 + 16 - (alf - $d)*8
return
]
if (Col7s) then
[
cv!0 = Gndcv
cv!1 = 352 - cmpsat
]
return
]
case $F:
[
cv!0 = cv!0 - 36
cv!1 = cv!1 - 12
if (Bot &(not Col7s)) then
[
cv!0 = cv!0 + 16 - (alf - $e)*8
return
]
if (Col7s) then
[
cv!0 = Gndcv
cv!1 = 340 - cmpsat
return
]
return
]
case $D:
case $M:
[
if (Bot &(not Col7s)) then
[
ErrBL("*nNo VDD nor VEE supplied in bottom location: ",SVIndex)
cv!1 = 320
// off the board so no wiring is possible
cv!0 = 100
// off the board so no wiring is possible
return
]

cv!1 = cv!1 - 4 - (SVType eq $M?4,0)
cv!0 = cv!0 - (SVType eq $D?32,0)
if (Col7s) then
[
cv!0 = 44 +(alf eq $b?52,0)+(alf eq $c?104,0)+(alf eq $d?104,0)+(alf eq $e?172,0)+(alf eq $f?224,0)
cv!0 = cv!0-(((SVType eq $M)&(alf ne $b))?8,0)
cv!1 = 356-(SVType eq $M?12,0) - cmpsat
]
return
]
]
]

and GetICcoordsP(alph,num,pin,cv) be
[
let boardloc = num*26 + alph
let tp = Boardvec!boardloc
let maxpins = tp>>icdesc.npins //max pins for chip
let SmallDip = (maxpins le 20)&(maxpins ge 14)
let alf = alph + $a
let pint = (pin le (maxpins/2)?1,0)
let bpin = (pin le (maxpins/2)?((maxpins/2) - pin),(pin - 1 - (maxpins/2)))
let Top = ((alf ge $a)&(alf le $d)&(num ge 2)&(num le 20))
let Bot = ((alf ge $e)&(alf le $g)&(num ge 1)&(num le 20))
let Col7s = ((num eq 7)%(num eq 11)%(num eq 14))
let Jumbo = (Top % (Bot &(alf ne $g)))& Col7s
let modf = ((num ge 8)?12,0) + ((num ge 12)?12,0) + ((num ge 15)?12,0)
let cmpsat = ((num eq 11)?108,0)+((num eq 14)?192,0)
if (Top &(not Col7s)) then
[
if ((num eq 2)&((Check rem 2) eq 1)) then
ErrBL("*nHad cable connector, adding dip to a2-d2: ",boardloc)
if (num eq 2)&(Check ls 2) then Check = Check + 2
cv!0 = 36 - bpin*4 + alph*44
cv!1 = 528 - ((pint eq 1)?0,12) - num*24 - modf
return
]
if (Bot &(not Col7s)) then
[
cv!0 = 220 - bpin*4 + (alf - $e)*36
cv!1 = 528 - ((pint eq 1)?0,12) - num*24 - modf
return
]
if (Top & Col7s &((alf eq $a)%(alf eq $b))&(maxpins eq 24)) then
[
cv!0 = 60 - bpin*4 + ((alf eq $b)?56,0)
cv!1 = 528 - ((pint eq 1)?0,24) - num*24 - modf
return
]
if ((Jumbo &(maxpins gr 20))&(alf ne $d)) then
[
cv!0 = 80-bpin*4+((alf eq $c)?92,0)+((alf eq $e)?160,0)+ ((alf eq $f)?212,0)
cv!1 = 336+((pint eq 1)?24,0)- cmpsat
return
]
if (Jumbo & SmallDip) then
[
cv!0 = 40 - bpin*4 + alph*44 + ((alf eq $e)?24,0) + ((alf eq $f)?32,0)
cv!1 = 336+((pint eq 1)?12,0)- cmpsat
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 AddPotentialTermsP() be
// G and V’s of Top Jumbo supplied by user!
// The note above is conflict to SIL manual,
// change made on January 25, 1978 10:29 AM
[
// assigns VCC nodes to the corner pins of all irregular TTL ICs
for alph = 0 to maxalph do
[
for n=1 to maxn do
[
let alf = alph + $a
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)
let SmallDip = (npins le 20)&(npins ge 14)
let Col7s = (n eq 7)%(n eq 11)%(n eq 14)
let RowT = (alf ge $a)&(alf le $d)&(Col7s)
let RowB = (alf ge $e)&(alf le $g)&(Col7s)
switchon ictype into
[
case Mtype: //Memory Storage IC with four volt pins
if (alf ge $e)&(alf le $g)&(not Col7s) then
[
ErrBL("*NMOS-dip assigned to bottom location: ",bl)
return
]
AddSVoltNode($M,bl,((npins/2) + 1)) // -5 v
if (npins eq 16) then AddSVoltNode($F,bl,1) // +5 v
if (npins eq 16) then AddSVoltNode($D,bl,npins) // +12 v
if (npins eq 18) then AddSVoltNode($D,bl,1)
endcase

case Ntype: //N TTL
case Htype: //H TTL
case Stype: //S TTL
// removed SmallDip on January 25, 1978 10:32 AM
if RowT then AddSVoltNode($G,bl,npins/2)
// removed SmallDip on January 25, 1978 10:32 AM
if (RowT % RowB) then AddSVoltNode($F,bl,npins)
if ((not Col7s)&(npins ls bpins)) then AddSVoltNode($F,bl,npins)
endcase
]
]
]

]


and LegalBlocP(bl) = valof
[
let alph = (bl rem 26)+$a; let num = bl/26
let numb = ((num eq 7)%(num eq 11)%(num eq 14))
if ((alph eq $g) & numb) then resultis false // those locations are illegal
if (alph ls $a)%(alph gr $g) then resultis false // letter always a to g
if (num ls 1)%(num gr 20) then resultis false // number always 1 to 20
resultis true
]

and GetCpinCoordsP(pin,cv) be
[
cv!0 = 0
cv!1 = 0
if ((pin ls 1)%(pin gr 85)) then
[
ErrN("*NSignal assigned to non-existed Cable connector Cpin: ",pin)
return
]
if (Check ge 2) then
ErrN("*NHad dip in locations a2-d2, using Cable connector Cpin: ",pin)
let pn = pin rem 2
let pvtgd = pin rem 22
if ((pvtgd eq 0)%(pvtgd eq 2)) then
ErrN("*NSignal assigned to +5 volt Cable connector Cpin: ",pin)
if ((pvtgd eq 19)%(pvtgd eq 21)) then
ErrN("*NSignal assigned to GND Cable connector Cpin: ",pin)
cv!0 = ((pin-1)/2)*4
cv!1 = 468 + pn*12
if ((Check rem 2) eq 0) then Check = Check + 1
]

and GetEpinCoordsP(pin,cv) be
[
cv!0 = 0 ; cv!1 = 0
let pinds = pin rem 50
if ((pin ls 1)%(pin gr 100)) then
[
ErrN("*nSignal assigned to invalid Epin: ",pin)
return
]
if ((pin eq 50)%(pin eq 100)) then
ErrN("*nSignal assigned to +12 volts power Epin: ",pin)
if (pinds eq 9) then
ErrN("*nSignal assigned to -5 volts power Epin: ",pin)
if ((pinds eq 3)%(pinds eq 4)) then
ErrN("*nSignal assigned to +5 volts power Epin: ",pin)
if ((pinds eq 6)%(pinds eq 7)%(pin eq 76)%(pin eq 96)) then
ErrN("*nSignal assigned to ground Epin: ",pin)
cv!0 = 304 + ((pin le 50)?4,0)
cv!1 = 387 - pinds*5
return
]

and GetBoardPinsP(bl) = valof
[
let num = bl/26
let alph = bl rem 26 + $a
let rowef = ((alph eq $b)%(alph eq $d)%(alph eq $e)%(alph eq $f))
let coljumbo = ((num eq 7)%(num eq 11)%(num eq 14))
if (((alph eq $a)%(alph eq $c)) & coljumbo) then resultis 40
if (rowef & coljumbo) then resultis 24
if ((alph ge $a)&(alph le $d)&(num ge 2)&(num le 20)) then resultis 20
if ((alph ge $e)&(alph le $g)&(num ge 1)&(num le 20)) then resultis 16
ErrBL("*nIllegal Board Location: ", bl)
resultis 0


]