//routeinit.bcpl // Initialization and driver module // last modified by Taft, September 22, 1979 7:11 PM get "sysdefs.d" get "streams.d" get "altofilesys.d" get "route.defs" external [ fpComCm fpSysDir sysDisk dsp OverlayScan GenerateOverlays OverlayNpages LookUpEntries LoadRam InitBcplRuntime RamImage initCodeEnd PrintTWPins PrintHoles MakeBuzzLists overlayCore ] static [ Correcting = false noroute = false whereTW = false buzzLists = false nlFileName = empty boardLocation = empty boardCodeFileName = empty wlNewFileName = empty wlOldFileName = empty ImplicitFile ADFile ErFile CommentsFile OldWlFile OutFile charTab dontCareNet StandardMetric SilZone = 0 initCodeEnd kf = empty epvec epsize overlayCore npBiggestOverlay ] let OnceOnlyInitCode(blv,params,cfa) be [ // sets up, also handles board type checking. (635)\f1 initCodeEnd = @#335 AddSpace(3000) // leave for stack @#420 = 0 //turn off display for speed let e = vec 100 epvec = e epsize = 0 AddDynamicEntry(lv AddEclTerminators) // in RouteTerm AddDynamicEntry(lv LocateAvailTerms) AddDynamicEntry(lv FreeTermStorage) AddDynamicEntry(lv AssignTWNet) // RouteTWNetAssign AddDynamicEntry(lv ManhattanDistFn) // in Routec AddDynamicEntry(lv EuclideanDistFn) AddDynamicEntry(lv CheckUnusedPins) // in Routea AddDynamicEntry(lv NLCompFn) // in Routeb AddDynamicEntry(lv AssignNetNumber) AddDynamicEntry(lv ReportRepairedPins) // in RouteCorrect AddDynamicEntry(lv ReportNewCutPins) AddDynamicEntry(lv PrintNewNet) AddDynamicEntry(lv MultiWirePanic) // in RouteBackpanel AddDynamicEntry(lv RouteEarlyNets) // in RouteNet AddDynamicEntry(lv RouteNetIfExternal) AddDynamicEntry(lv RouteNet) AddDynamicEntry(lv ComputeLengths) OverlayScan(lv (cfa>>CFA.fp), Allocate(SilZone, 200), 200, lv (cfa>>CFA.fa), 0, 0, 0, 0, sysDisk, epvec, epsize) npBiggestOverlay = 0 GenerateOverlays(HowBig) overlayCore = Allocate(SilZone, 256*npBiggestOverlay) charTab = Allocate(SilZone, 256) Zero(charTab, 256) AddAttribute(upperCaseMask%letterMask, $A, $Z) AddAttribute(lowerCaseMask%letterMask, $a, $z) AddAttribute(digitMask, $0, $9) AddAttribute(colonMask, ":") AddAttribute(breakMask, " :,;*t*n") AddAttribute(legalSpecialCharMask, "$#()'[]^_?/\|+-=&**~") let comcm = OpenFile("COM.CM",ksTypeReadOnly,charItem,0,fpComCm,0,SilZone) if comcm eq 0 then CallSwat("Can't open COM.CM") let fn = vec 128 ReadNext(comcm,fn) //throw away name let fnl = fn>>str.length let i=1 while i le fnl do test fn>>str.char^i eq $/ ifso [ i=i+1; break ] ifnot i=i+1 while i le fnl do [l4268\f1 switchon fn>>str.char^i into [l5538\f1 case $C: case $c:l6808\f1 Correcting = true endcasel8078\f1 case $M: case $m:l6808\f1 doMultiWire = true endcasel8078\f1 case $T: case $t:l6808\f1 whereTW = true endcasel8078\f1 case $B: case $b:l6808\f1 buzzLists = true endcasel8078\f1 case $R: case $r:l6808\f1 doResistances = true endcasel8078\f1 default:l6808\f1 ] i=i+1l5538\f1 ] StandardMetric = ManhattanDistFn DefaultString(lv boardLocation, "c1") DefaultString(lv boardCodeFileName, "routemlb.br") let nlFileCount = 0 until Endofs(comcm) do [l4268\f1 let filestring = vec 20 unless ReadNext(comcm,filestring) then break unless IsFunnyParameter(filestring) do [l5538\f1 NeedFile(filestring, 0, true) // input file if nlFileCount eq 0 & nlFileName eq empty then [l6808\f1 DefaultString(lv nlFileName, filestring) let lastGoodChar = nlFileName>>str.length for i=1 to nlFileName>>str.length do [l8078\f1 if nlFileName>>str.char^i eq $. then lastGoodChar = i-1l9348\f1 ] nlFileName>>str.length = lastGoodCharl8078\f1 ] nlFileCount = nlFileCount+1l6808\f1 ]l5538\f1 ] Closes(comcm) if LoadRam(RamImage) eq 0 then InitBcplRuntime() // fire up microcode SetupSpace() dontCareNet = DefineNamee("Whatever", typeNet, NewNet) dontCareNet>>net.hasBeenRouted = true dontCareNet>>net.dontTerminate = true SetupICclasses() // build icclass objects for all known IC classes SetupBoard(boardCodeFileName) // read in board code and plug into statics, then //plug edge connectors and trace-wired nets into data structures if whereTW then PrintTWPins() if buzzLists then MakeBuzzLists() if nlFileCount le 0 then finish let ts = vec 30 test Correcting & (wlOldFileName eq empty) ifsol4269\f1 [ ExpandTemplate(ts, "$S.wl", nlFileName) DefaultString(lv wlOldFileName, ts) ExpandTemplate(ts, "$S.wlNew", nlFileName) DefaultString(lv wlNewFileName, ts) ]l5539\f1 ifnotl4269\f1 [ ExpandTemplate(ts, "$S.wl", nlFileName) DefaultString(lv wlNewFileName, ts) ]l5539\f1 NeedFile(wlNewFileName) NeedFile(nlFileName, ".inl") NeedFile(nlFileName, ".re") NeedFile(nlFileName, ".bp") NeedFile(nlFileName, ".lc") NeedFile(nlFileName, ".comments") if Correcting then [l4269\f1 NeedFile(wlOldFileName, "", false, false) NeedFile(nlFileName, ".ad") NeedFile("route.dpf")l5539\f1 ] if doMultiWire then [l4269\f1 NeedFile(nlFileName, ".mw") NeedFile(nlFileName, ".mh") NeedFile(nlFileName, ".mhi")l5539\f1 ] if doResistances then [l4269\f1 NeedFile(nlFileName, ".resist")l5539\f1 ] MapNamees(typeIcinst, NeedConnInstFiles) FindOrMakeNeededFiles() ErFile = GetFile(nlFileName,".re",charItem) //routing errors PutTemplate(ErFile, "[0] = worst error severity*n") ImplicitFile = GetFile(nlFileName,".inl", charItem) // implicit net list PutTemplate(ImplicitFile, "; Implicitly generated wiring ...*n@") CommentsFile = GetFile(nlFileName,".comments",charItem) TruncateDiskStream(CommentsFile)l4269\f1 ] and DefaultString(sp, s) be [\f1 if @sp ne empty then Free(SilZone, @sp) @sp = Allocate(SilZone, (s>>str.length rshift 1)+1) MoveBlock(@sp, s, (s>>str.length rshift 1)+1)l4269\f1 ] and AddDynamicEntry(p) be [\f1 epvec!epsize = p epsize = epsize+1l4269\f1 ] and HowBig(od) be [\f1 let npThisOverlay = OverlayNpages(od) if npThisOverlay gr npBiggestOverlay then npBiggestOverlay = npThisOverlayl4269\f1 ] and NeedConnInstFiles(icinst) be [\f1 unless Icclass(icinst)>>icclass.isConnector do return let filename = vec 20 ExpandTemplate(filename, "$S-$S.nl", nlFileName, FindNameesString(icinst)) NeedFile(filename)l4269\f1 ] and AddAttribute(attributeMask, first, last) be [\f1 test first le 255 ifso for char=first to last do charTab!char = charTab!char%attributeMask ifnot for i=1 to first>>str.length do AddAttribute(attributeMask, first>>str.char^i, first>>str.char^i)l4269\f1 ] and ReadNext(stream,string) = valof [\f1 let ch = $*s if Endofs(stream) then resultis false until (Endofs(stream)%(ch gr $*s))do ch = Gets(stream) if ch le $*s then resultis false string>>str.length = 1 string>>str.char^1 = ch [l4268\f1 if Endofs(stream) then break ch = Gets(stream) if ch le $*s then break let sl = string>>str.length+1 string>>str.char^sl = ch string>>str.length = sll5538\f1 ] repeat resultis truel4268\f1 ] and IsFunnyParameter(string) = valof [\f1 43f0 let lastSlashPos = 0 for i=1 to string>>str.length do if string>>str.char^i eq $/ then lastSlashPos = i if lastSlashPos eq 0 then resultis false string>>str.length = lastSlashPos-1 switchon string>>str.char^(lastSlashPos+1) into [l4269\f1 20f0 1f1 32f0 1f1 50f0 1f1 41f0 1f1 35f0 1f1 47f0 1f1 case $h: case $H:l5539\f1 8f0 1f1 8f0 heuristicWork = CSN(string) endcasel6809\f1 27f0 1f1 7f0 case $m: case $M:l5539\1f1 8f0 1f1 8f0 StandardMetric = selecton string>>str.char^1 into [l6809\f1 49f0 1f1 case $M: case $m: ManhattanDistFn case $E: case $e: EuclideanDistFn default: ManhattanDistFnl8079\f1 8f0 1f1 25f0 1f1 8f0 1f1 25f0 1f1 ] endcasel6809\f1 1f0 1f1 7f0 case $E: case $e:l5539\1f1 8f0 1f1 8f0 exhaustThresh = CSN(string) endcasel6809\f1 27f0 1f1 7f0 case $L: case $l:l5539\1f1 DefaultString(lv boardLocation, string) endcasel6809\f1 case $B: case $b:l5539\f1 DefaultString(lv boardCodeFileName, string) endcasel6809\f1 case $C: case $c:l5539\f1 Correcting = true DefaultString(lv wlOldFileName, string) endcasel6809\f1 case $F: case $f:l5539\f1 DefaultString(lv nlFileName, string) endcasel6809\f1 default:l5539\f1 9f0 ] resultis truel4269\f1 2f0 1f1 ] and CSN(string) = valof [\f1 let value = 0 for i=1 to string>>str.length do [l4269\f1 let c = string>>str.char^i unless (charTab!c&digitMask)ne 0 do [l5539\f1 CallSwat("*nIllegal number in command file.", string) finishl6809\f1 ] value = value*10+c-$0l5539\f1 ] resultis valuel4269\f1 ] and NeedFile(fn, suffix, isInput, okToCreate; numargs na) be [\f1 DefaultArgs(lv na, -1, "", false, false) let filename = vec 20 ExpandTemplate(filename, "$S$S", fn, suffix) let fnwords = (filename>>str.length rshift 1)+1 let newkf = Allocate(SilZone, offset KF.string/16+fnwords) MoveBlock(lv newkf>>KF.string, filename, fnwords) newkf>>KF.input = isInput newkf>>KF.oktocreate = na gr 3? okToCreate, not isInput newkf>>KF.next = kf kf = newkfl4269\f1 ] and FindOrMakeNeededFiles() be [\f1 let kfCount = 0 let kfIndex = kf let kfRev = empty // reversed list until kfIndex eq empty do [l4269\f1 kfCount = kfCount+1 let kfTemp = kfIndex>>KF.next kfIndex>>KF.next = kfRev kfRev = kfIndex kfIndex = kfTempl5539\f1 ] kf = kfRev let names = Allocate(SilZone, kfCount) let kfCount = 0 let kfIndex = kf until kfIndex eq empty do [l4269\f1 names!kfCount = lv kfIndex>>KF.string kfCount = kfCount+1 kfIndex = kfIndex>>KF.nextl5539\f1 ] let dvs = Allocate(SilZone, kfCount*lDV) Zero(dvs, kfCount*lDV) let q = OpenFile(0,0,0,0,fpSysDir,0,SilZone) if q eq 0 then CallSwat("Can't open SysDir") LookUpEntries(q, names, dvs, kfCount, true) Closes(q) kfIndex = kf kfCount = 0 until kfIndex eq empty do [l4269\f1 test dvs!(kfCount*lDV) eq 0 ifnot [l5539\f1 MoveBlock(lv kfIndex>>KF.fp, lv dvs!(kfCount*lDV+offset DV.fp/16), lFP)l6809\f1 ] ifso [l5539\f1 if not kfIndex>>KF.oktocreate then CallSwat("Can't find input file ", lv kfIndex>>KF.string) let file = OpenFile(lv kfIndex>>KF.string,ksTypeReadWrite, 0,0,0,0,SilZone) let cfa = vec lCFA GetCompleteFa(file, cfa) MoveBlock(lv kfIndex>>KF.fp, lv cfa>>CFA.fp, lFP) Closes(file)l6809\f1 ]l5539\f1 kfCount = kfCount+1 kfIndex = kfIndex>>KF.nextl5539\f1 ]l4269\f1 ] and AddSpace(stackNeeds) be [\f1 static [ malFormed = 0 ] let Space = FixedLeft() while Usc(Space, stackNeeds+20) gr 0 do [l4268\f1 let grab = Space-stackNeeds if Usc(grab, #77777) gr 0 then grab = #77777 //+ infinity test SilZone eq 0 ifso SilZone = InitializeZone(GetFixed(grab), grab, SysErr, malFormed) ifnot AddToZone(SilZone, GetFixed(grab), grab) Space = FixedLeft()l5538\f1 ]l4269\f1 ] \f1