+ nepads = bondmap['N'].keys()
+ nepads.sort()
+ wepads = bondmap['W'].keys()
+ wepads.sort()
+ eepads = bondmap['E'].keys()
+ eepads.sort()
+ sepads = bondmap['S'].keys()
+ sepads.sort()
+
+ owoffs = woffs + (width/2) - len(nepads)/2 * outerscale
+ ohoffs = hoffs + (height/2) - len(wepads)/2 * outerscale
+
+ # north outer pads
+ for i in nepads:
+ (epinnum, ipin, bank) = pad = bondmap['N'][i]
+ wd = owoffs + i * outerscale + outerscale*1.5
+ endline = (wd, ohoffs-outerscale*2)
+ startline = innerpos[bank][ipin]
+ dwg.add(dwg.line(startline,
+ endline,
+ stroke=svgwrite.rgb(255, 16, 16, '%'),
+ stroke_width=scale/10.0))
+ pin = pins[sidepad[bank]][ipin]
+ pos=(wd, ohoffs-outerscale*4.0)
+ txt = dwg.text("%s (%s%d)" % (pin.upper(), bank, ipin+1),
+ insert=pos, fill='black')
+ txt.rotate(-90, pos)
+ dwg.add(txt)
+ pos=(wd, ohoffs-outerscale*2.5)
+ txt = dwg.text("%d N" % epinnum, insert=pos, fill='blue')
+ txt.rotate(-90, pos)
+ dwg.add(txt)
+
+ # west outer pads
+ for i in wepads:
+ (epinnum, ipin, bank) = pad = bondmap['W'][i]
+ ht = ohoffs + (i * outerscale) + outerscale*1.5
+ endline = (owoffs+outerscale*0.5, ht)
+ startline = innerpos[bank][ipin]
+ dwg.add(dwg.line(startline,
+ endline,
+ stroke=svgwrite.rgb(255, 16, 16, '%'),
+ stroke_width=scale/10.0))
+ pin = pins[sidepad[bank]][ipin]
+ pos = (owoffs-outerscale*6.0, ht)
+ dwg.add(dwg.text("%s (%s%d)" % (pin.upper(), bank, ipin+1),
+ pos,
+ fill='black'))
+ pos = (owoffs-outerscale*1.0, ht)
+ dwg.add(dwg.text("%d W" % epinnum, insert=pos,
+ fill='blue'))
+
+ # south outer pads
+ for i in sepads:
+ (epinnum, ipin, bank) = pad = bondmap['S'][i]
+ wd = owoffs + i * outerscale + outerscale*1.5
+ ht = ohoffs + len(wepads)*outerscale + outerscale*4
+ endline = (wd, ht)
+ startline = innerpos[bank][ipin]
+ dwg.add(dwg.line(startline,
+ endline,
+ stroke=svgwrite.rgb(255, 16, 16, '%'),
+ stroke_width=scale/10.0))
+ pin = pins[sidepad[bank]][ipin]
+ pos=(wd-outerscale*0.25, ht+outerscale*1.5)
+ txt = dwg.text("%s (%s%d)" % (pin.upper(), bank, ipin+1),
+ insert=pos, fill='black')
+ txt.rotate(90, pos)
+ dwg.add(txt)
+ pos=(wd-outerscale*0.25, ht+outerscale*0.5)
+ txt = dwg.text("%d S" % epinnum, insert=pos, fill='blue')
+ txt.rotate(90, pos)
+ dwg.add(txt)
+
+ # east outer pads
+ for i in eepads:
+ (epinnum, ipin, bank) = pad = bondmap['E'][i]
+ ht = ohoffs + (i * outerscale) + outerscale*1.5
+ wd = owoffs+len(nepads)*outerscale
+ endline = (wd+outerscale*0.5, ht)
+ startline = innerpos[bank][ipin]
+ dwg.add(dwg.line(startline,
+ endline,
+ stroke=svgwrite.rgb(255, 16, 16, '%'),
+ stroke_width=scale/10.0))
+ pin = pins[sidepad[bank]][ipin]
+ pos = (wd+outerscale*2.5, ht)
+ dwg.add(dwg.text("%s (%s%d)" % (pin.upper(), bank, ipin+1),
+ pos,
+ fill='black'))
+ pos = (wd+outerscale*1.0, ht)
+ dwg.add(dwg.text("%d E" % epinnum, insert=pos,
+ fill='blue'))
+
+ # add QFP pack image in top-right
+ image_data = open(pack_drawing, "rb").read()
+ encoded = base64.b64encode(image_data).decode()
+ data = 'data:image/png;base64,{}'.format(encoded)
+ pos=(0, 0)
+ leads = svgwrite.image.Image(data, pos,
+ size=(327,300))
+ dwg.add(leads)
+
+ # add QFP lead image in centre
+ image_data = open(lead_drawing, "rb").read()
+ encoded = base64.b64encode(image_data).decode()
+ data = 'data:image/png;base64,{}'.format(encoded)
+ pos=(woffs+scale*3.5, hoffs+scale*3.5)
+ leads = svgwrite.image.Image(data, pos,
+ size=(400,400))
+ leads.rotate(-90, (pos[0]+200, pos[1]+200))
+ dwg.add(leads)
+
+ dwg.add(dwg.text("GREATEK ELECTRONICS INC.",
+ insert=(woffs+width/2-scale*5, woffs+height/2-scale*6),
+ fill='black'))
+ dwg.add(dwg.text("INNER LEAD DRAWING",
+ insert=(woffs+width/2-scale*5, woffs+height/2-scale*5),
+ fill='black'))
+ dwg.add(dwg.text("QFP 128L OPEN STAMPING",
+ insert=(woffs+width/2-scale*5, woffs+height/2-scale*4),
+ fill='black'))
+ dwg.add(dwg.text("BODY 14x20x2.75mm",
+ insert=(woffs+width/2-scale*5, woffs+height/2-scale*3),
+ fill='black'))
+ dwg.add(dwg.text("L/F PAD SIZE 236x236mil^2",
+ insert=(woffs+width/2-scale*5, woffs+height/2-scale*2),
+ fill='black'))
+
+ # add attribution
+ dwg.add(dwg.text("Libre-SOC ls180 QFP-128",
+ insert=(woffs+width/2-scale*5, woffs+height/2),
+ fill='black'))
+ dwg.add(dwg.text("In collaboration with LIP6.fr",
+ insert=(woffs+width/2-scale*5, woffs+height/2+scale),
+ fill='black'))
+ dwg.add(dwg.text("Cell Libraries by Chips4Makers",
+ insert=(woffs+width/2-scale*5, woffs+height/2+scale*2),
+ fill='black'))
+ dwg.add(dwg.text("IMEC TSMC 180nm",
+ insert=(woffs+width/2-scale*5, woffs+height/2+scale*3),
+ fill='black'))
+