//routeIC.bcpl

// IC-specific routines.
// last modified by E. McCreight, June 19, 1979 1:32 AM

get "route.defs"

let DIP3Wide(icinst, pinNo, pv, ph) = valof
[
let npins = Npins(icinst)
if pinNo le 0 % pinNo gr npins then resultis illegal
let lefthalf = pinNo le npins/2
@pv = 4*(lefthalf? pinNo-1, npins-pinNo)
@ph = lefthalf? 0, 12
resultis relative
]

and DIP4Wide(icinst, pinNo, pv, ph) = valof
[
let result = DIP3Wide(icinst, pinNo, pv, ph)
@ph = @ph eq 0? 0, 16
resultis result
]

and DIP6Wide(icinst, pinNo, pv, ph) = valof
[
let result = DIP3Wide(icinst, pinNo, pv, ph)
@ph = 2*@ph
resultis result
]

and DIP9Wide(icinst, pinNo, pv, ph) = valof
[
let result = DIP3Wide(icinst, pinNo, pv, ph)
@ph = 3*@ph
resultis result
]

and SIP(icinst, pinNo, pv, ph) = valof
[
let npins = Npins(icinst)
if pinNo le 0 % pinNo gr npins then resultis illegal
@pv = 4*(pinNo-1)
@ph = 0
resultis relative
]

and QITPlat(icinst, pinNo, pv, ph) = valof // rev B; only MLB uses rev A
[
let npins = Npins(icinst)
if npins ne 26 then CallSwat("QIT ne 26 pins")
if pinNo le 0 % pinNo gr npins then resultis illegal
@ph = (table
[
0; 0; 0; 0; 0; 0; 0; 12; 12; 12; 18; 18;// pins 1-12
30; 30; 30; 30; 30; 30; 30; 18; 18; 12; 12; 12; 18; 30
// pins 13-26
])!(pinNo-1)
@pv = (table
[
0; 4; 8; 12; 16; 20; 24; 16; 28; 20; 20; 16;// pins 1-12
28; 24; 20; 16; 12; 8; 4; 12; 8; 8; 12; 0; 0; 0
// pins 13-26
])!(pinNo-1)
resultis relative
]

and Ecl4GAttributes(icinst, pinNo) = NullAttributes(icinst, pinNo)%
(pinNo ge Npins(icinst)-2? 0,
(pinNo eq 1? 0, (pinNo eq 15? 0, isEcl)))
// for QIT platform w/ Fujitsu Ram

and Ecl3GAttributes(icinst, pinNo) = Ecl2GAttributes(icinst,pinNo)-
(pinNo eq Npins(icinst)-1? isEcl, 0)

and Ecl2GAttributes(icinst, pinNo) = Ecl1GAttributes(icinst,pinNo)-
(pinNo eq 1? isEcl, 0)

and Ecl1GAttributes(icinst, pinNo) = NullAttributes(icinst, pinNo)%
(pinNo eq Npins(icinst) % pinNo eq Npins(icinst)/2? 0, isEcl)

and ETCAttributes(icinst, pinNo) = NullAttributes(icinst, pinNo)%
valof
[
for i=2 to 14 by 4 do if pinNo ge i & pinNo le i+1 then resultis isEcl
resultis 0
]

and TECAttributes(icinst, pinNo) = NullAttributes(icinst, pinNo)%
valof
[
for i=1 to 12 by 11 do if pinNo ge i & pinNo le i+3 then resultis isEcl
resultis 0
]

and F100KAttributes(icinst, pinNo) = NullAttributes(icinst, pinNo)%
((pinNo ne 6 & pinNo ne 7 & pinNo ne 18)? isEcl, 0)

and EclTermAttributes(icinst, pinNo) = pinNo ge 2? isTerminator, 0

and NullAttributes(icinst, pinNo) = valof
[
let ictype = icinst>>icinst.ictype
resultis (ictype ne empty & ictype>>namee.type eq typeIctype &
GetBit(lv (ictype>>ictype.outpins), pinNo) ne 0)? isOutput, 0
]

and Ecl4Gnd(icinst) be
// for QIT platform w/ Fujitsu Ram
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
for i=npins-2 to npins do
PutTemplate(ImplicitFile, "*nGND: $S.$Dp", str, i)
PutTemplate(ImplicitFile, "*nGND: $S.1p", str)
PutTemplate(ImplicitFile, "*nVEE: $S.$Dp", str, 15)
]

and Ecl3Gnd(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nGND: $S.$Dp",
str, npins-1)
Ecl2Gnd(icinst)
]

and Ecl2Gnd(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nGND: $S.1p", str)
Ecl1Gnd(icinst)
]

and Ecl1Gnd(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nGND: $S.$Dp", str, npins)
PutTemplate(ImplicitFile, "*nVEE: $S.$Dp", str, npins/2)
]

and EclConverter(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nVCC: $S.$Dp", str, npins/2+1)
Ecl1Gnd(icinst)
]

and F100K(icinst) be
[
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nGND: $S.6p, $S.7p", str, str)
PutTemplate(ImplicitFile, "*nVEE: $S.18p", str)
]

and EclTerm(icinst) be
[
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nVTT: $S.1p", str)
]

and FTTL(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nVCC: $S.$Dp", str, npins)
PutTemplate(ImplicitFile, "*nGND: $S.$Dp", str, (npins/2)-3)
]

and TTL(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nVCC: $S.$Dp", str, npins)
PutTemplate(ImplicitFile, "*nGND: $S.$Dp", str, npins/2)
]

and DynamicRam3Supply(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nGND: $S.$Dp", str, npins)
PutTemplate(ImplicitFile, "*nVDD: $S.$Dp", str, npins/2)
PutTemplate(ImplicitFile, "*nVEE: $S.1p", str)
PutTemplate(ImplicitFile, "*nVCC: $S.$Dp", str, npins/2+1)
]

and DynamicRam1Supply(icinst) be
[
let npins = Npins(icinst)
let str = FindNameesString(icinst)
PutTemplate(ImplicitFile, "*nGND: $S.$Dp", str, npins)
PutTemplate(ImplicitFile, "*nVCC: $S.$Dp", str, npins/2)
]