//routepull.bcpl

// Routine to determine what IC’s to pull for re-work

// last modified by E. McCreight, May 25, 1978 10:54 PM

get "route.defs"

let PullComponents() be
[
headingpresent = false
DoInSortOrder(typeOldinst, NameCompareFn, DiscardIC)
headingpresent = false
DoInSortOrder(typeIcinst, NameCompareFn, PullIfAffected)
]

and DiscardIC(oldinst) be
[
unless Icclass(oldinst)>>icclass.printUsedList do return
let newinst = TryFindingNamee(FindNameesString(oldinst), typeIcinst)
if newinst ne empty & newinst>>icinst.ictype eq
oldinst>>oldinst.ictype then return
Heading("DISCARD")
PrintPin(oldinst, 1)
]

and PullIfAffected(icinst) be
[
unless Icclass(icinst)>>icclass.printUsedList do return
let isAffected = false
for pin=1 to Npins(icinst) do
[
let x,y,TWclass,TWpin = 0,0,empty,0
unless GetPinCoord(icinst, pin, lv x, lv y) do loop
FindIndexFromCoord(x, y, lv TWclass, lv TWpin)
if TWclass ne empty then
[
if GetBit(TWclass>>icclass.cutPins, TWpin) ne
GetBit(TWclass>>icclass.oldCutPins, TWpin) then
isAffected = true
let subnetstring = vec 20
let subnet = TryFindingNamee(ExpandTemplate(
subnetstring, "$S$D", FindNameesString(TWclass), TWpin),
typeNet)
if subnet ne empty & not subnet>>net.isSame then
isAffected = true
]

if icinst>>icinst.pin↑pin eq empty then loop
let net = FindNet(lv icinst>>icinst.pin↑pin)
unless net>>net.isSame % net>>net.isTraceWired %
net eq dontCareNet do isAffected = true
]

unless isAffected do return
Heading("UNPLUG")
PrintPin(icinst, 1)
]