//routeip1.bcpl
// Board-specific Route routines for the Image Processing ECL Logic Board

// Part 1 of 2, last modified by S. Tom Chang, April 1, 1978 1:36 PM
// all co-ordinates are described with respect to the bottom or
// wiring side of the board. LevelTransform fixes these as necessary.

get "route.defs"

static [ maxICs = 450; boardInterfaceVersion = interfaceVersion ]

external [ Pin1of8 ] // defined elsewhere

let DeclareInitialNets(BuildTWNet, BuildTermNet, BuildConnector) be
[
BuildConnector("E", 200, EPinPos)
BuildConnector("C", 765, CPinPos)
BuildTWNet("GND", 476, GNDPinPos)
BuildTWNet("VCC", 154, VCCPinPos)
BuildTWNet("VTT", 110, VTTPinPos)
BuildTWNet("VEE", 238, VEEPinPos)
BuildTermNet("Term100/8/Term100", 8, "Term100", 770, AutoTermPinPos,"T")
]

and ZeroTablePoint(point) = selecton point into
[
case 0: "IP" // board type
case 1: "Z-j1.8"
case 2: "Z-E96"
case 3: "Z-E3"
case 4: "Z-VCC1"
default: empty
]

and LevelTransform(level, x, y, px, py, pName, pPullComponents, pWire; numargs na) = valof
[
DefaultArgs(lv na, -1, 0, 0, lv na, lv na, lv na, lv na, lv na)
switchon level into
[
case TopLevel:
@px = x
@py = 500-y
@pName = "Component side"
@pPullComponents = true
@pWire = false
resultis true

case BottomLevel:
@px = x
@py = y
@pName = "Wiring side"
@pPullComponents = false
@pWire = true
resultis true

default: resultis false
]
]

and EPinPos(icinst, pin, px, py) = valof
[
if (pin ls 1) % (pin gr 198) then resultis illegal
let pve = pin rem 100
if ((pve eq 99)%(pve eq 0)) then resultis illegal // -5.2 volts
if ((pve eq 96)%(pve eq 97)) then resultis illegal // -2 volts
let pv = pin rem 50
if ((pv eq 0)%(pv eq 1)) then resultis illegal // +5 volts
let pg = pin rem 10
if (pg eq 0) then resultis illegal // ground Epins
let pd = 99 - (pin rem 100)
@px = pd*4 - 4 + (pd le 48?0,20)
@py = 500 - ((pin - 1)/100)*4
resultis absolute
]

and CPinPos(icinst, pin, px, py) = valof
[
let pn = pin rem 100 - 1
let pd = pn rem 50
@px = 0
@py = 0
switchon pin/100 into
[
case 0:
[
if ((pd ge 19)&(pd le 36)) then @py = 4
if ((pn ge 0)&(pn le 36)) then
@px = 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
@px = 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

@px = @px - 8
resultis absolute
]
case 1:
[
if ((pd ge 19)&(pd le 36)) then @py = 4
if ((pn ge 0)&(pn le 36)) then
@px = 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
@px = 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

@px = @px - 8
resultis absolute
]

case 2:
[
if ((pd ge 13)&(pd le 24)) then @py = 4
if ((pn ge 0)&(pn le 24)) then
@px = 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
@px = 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

@px = @px - 8
resultis absolute
]

case 3:
[
if ((pd ge 13)&(pd le 24)) then @py = 4
if ((pn ge 0)&(pn le 24)) then
@px = 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
@px = 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

@px = @px - 8
resultis absolute
]

case 4:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = 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
@px = table [ 184; 180; 176; 172; 168; 164; 160; 156; 184; 180;
176; 172; 168; 164; 160 ]!pd

@px = @px - 8
resultis absolute
]

case 5:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = 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
@px = table [ 156; 160; 164; 168; 172; 176; 180; 184; 160; 164;
168; 172; 176; 180; 184 ]!pd

@px = @px - 8
resultis absolute
]

case 6:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = 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
@px = table [ 116; 112; 108; 104; 100; 96; 92; 88; 112; 108;
104; 100; 96; 92; 88 ]!pd

@px = @px - 8
resultis absolute
]

case 7:
[
if ((pd ge 8)&(pd le 14)) then @py = 4
if ((pn ge 0)&(pn le 14)) then
@px = 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
@px = table [ 88; 92; 96; 100; 104; 108; 112; 116; 88; 92;
96; 100; 104; 108; 112 ]!pd

@px = @px - 8
resultis absolute
]
]
resultis illegal
]

and VTTPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = Disconnect+noReconnect+TopLevel
if pin le 0 then resultis illegal
if pin le 110 then
[
pin=pin-1
let VttRow = (pin/10)+1
let VttCol = 10 - (pin rem 10)
@px = 36*VttCol + (VttCol ge 7?28,0)
@px = @px + (VttCol ge 4?4,0) + (VttCol eq 10?4,0)
@py = 42*VttRow - 8
resultis absolute
]
resultis illegal
]

and VEEPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = Disconnect+noReconnect+TopLevel
if pin le 0 then resultis illegal
if pin le 220 then
[
pin=pin-1
let VeeGp = (pin/20)
let VeeRow = (pin/10) rem 2
let VeeCol = 10 - (pin rem 10)
@px = 36*VeeCol - 28 + (VeeCol ge 7?28,0)
@px = @px + (VeeCol ge 4?4,0) + (VeeCol eq 10?4,0)
@py = 42*VeeGp + 16 + (VeeRow eq 1?24,0)
resultis absolute
]
if (pin gr 220)&(pin le 238) then
[
pin=pin-221
let VeeRow = (pin/6)
let VeeCol = 6 - (pin rem 6)
@px = 52*VeeCol - 42 + (VeeCol ge 3?8,0) + (VeeCol ge 5?32,0)
@py = 126*VeeRow + 106
resultis absolute
]
resultis illegal
]
and GNDPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = Disconnect+noReconnect+BottomLevel
if pin le 0 then resultis illegal
if pin le 440 then
[
pin=pin-1
let GndGp = (pin/40)
let GndRow = (pin/10) rem 4
let GndCol = 10 - (pin rem 10)
@px = 36*GndCol + (GndCol ge 7?28,0)
@px = @px + (GndCol ge 4?4,0) + (GndCol eq 10?4,0)
@py = 42*GndGp + 16 + GndRow*12
resultis absolute
]
if (pin gr 440)&(pin le 476) then
[
pin=pin-441
let GndGp = (pin/12)
let GndRow = (pin/6) rem 2
let GndCol = 6 - (pin rem 6)
@px = 52*GndCol + 2 + (GndCol ge 3?8,0) + (GndCol ge 5?32,0)
@py = 126*GndGp + 106 + (GndRow eq 1?24,0)
resultis absolute
]
resultis illegal
]

and VCCPinPos(icinst, pin, px, py, pInfo; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na)
@pInfo = Disconnect+noReconnect+TopLevel
if pin le 0 then resultis illegal
if pin le 154 then
[
pin=pin-1
let VccGp = (pin/14)
let VccRow = (pin/7) rem 2
let VccCol = 7 - (pin rem 7)
@px = 36*VccCol + 4 + (VccCol ge 5?64,0)
@px = @px + (VccCol ge 3?40,0) + (VccCol eq 7?40,0)
@py = 42*VccGp + 16 + (VccRow eq 1?36,0)
resultis absolute
]
resultis illegal
]

and AutoTermPinPos(icinst, pin, px, py, pInfo, pinName; numargs na) = valof
[
DefaultArgs(lv na, -4, lv na, 0)
if pin le 0 then resultis illegal
if pin le 770 then
[
pin=pin-1
let package = pin/7
pin = pin rem 7
Pin1of8(package/10, package rem 10, px, py)
@px = @px-4-4*pin
if pinName ne 0 then
ExpandTemplate(pinName, "$C$D.$D", $a+(package rem 10),
31+package/10, pin+2)
resultis absolute
]
resultis illegal
]