15f8962f1944d5f21b00358ba83c173428fa9bd5
[hw/micropeak] / packages / udfn.py
1 # author: Keith Packard
2 # email: keithp@keithp.com
3 # dist-license: GPL 2
4 # use-license: unlimited
5
6 def mm2mils100( mm ):
7         return int( mm / 25.4 * 1000.0 * 100.0 + 0.5 )
8
9 PkgWidth = 3.00
10 PkgHeight = 2.00
11 PadWidth = 0.85
12 PadHeight = 0.30
13 PadSpacingY = 0.5
14 PadSpacingX = PkgWidth
15 GroundWidth = 1.30
16 GroundHeight = 1.50
17 Clearance = 0.2
18
19 NumPad=8
20 NumX=2
21 NumY=NumPad/NumX
22
23 print '# author: Keith Packard'
24 print '# email: keithp@keithp.com'
25 print '# dist-license: GPL 2'
26 print '# use-license: unlimited'
27
28 print 'Element["" "UDFN-%d" "" "" 0 0 0 0 0 100 ""]' % NumPad
29 print "("
30
31 def pad(cx, cy, w, h, name, num):
32     x1 = 0
33     y1 = 0
34     x2 = 0
35     y2 = 0
36     thickness = 0
37     if w > h:
38         thickness = h
39         y1 = cy
40         x1 = cx - (w - h) / 2
41         y2 = cy
42         x2 = cx + (w - h) / 2
43     else:
44         thickness = w
45         x1 = cx
46         y1 = cy - (h - w) / 2
47         x2 = cx
48         y2 = cy + (h - w) / 2
49     mask = thickness + Clearance / 2
50     print '    Pad[',\
51         mm2mils100(x1), \
52         mm2mils100(y1), \
53         mm2mils100(x2), \
54         mm2mils100(y2), \
55         mm2mils100(thickness), \
56         mm2mils100(Clearance), \
57         mm2mils100(mask),\
58         '"%s"' % name, '"%s"' % num, '"square"]'
59     
60 def line(x1, y1, x2, y2):
61     print '    ElementLine[',\
62         mm2mils100(x1), \
63         mm2mils100(y1), \
64         mm2mils100(x2), \
65         mm2mils100(y2), \
66         '500]'
67     
68 def rect(x, y, w, h):
69     line(x,y,x+w,y)
70     line(x+w,y,x+w,y+h)
71     line(x+w,y+h,x,y+h)
72     line(x,y+h,x,y)
73
74 def padx(p):
75     x = (p-1) / NumY
76     return (x - (NumX - 1)/2.0) * PadSpacingX
77
78 def pady(p):
79     y = 0
80     if (p <= NumY):
81         y = p - 1
82     else:
83         y = NumPad - p
84     return (y - (NumY - 1)/2.0) * PadSpacingY
85
86 for p in range(1,NumPad+1):
87     pad(padx(p), pady(p), PadWidth, PadHeight, 'pin%i' % p, '%i' % p)
88
89 pad(0, 0, GroundWidth, GroundHeight, 'GND', 'GND')
90
91 rect(-PkgWidth / 2, -PkgHeight / 2, PkgWidth, PkgHeight)
92
93 print '    )'    
94         # 11000 2000
95 #       ElementLine[-11000 -1000 -3600 -1000 100]
96 #       ElementLine[  3600 -1000 11000 -1000 100]
97 #
98 #       ElementLine[11000 -1000 11000 17000 100]
99 #       ElementLine[11000 17000 6000 17000 100]
100 #       ElementLine[ 6000 17000 4000 15000 100]
101 #       ElementLine[ 4000 15000 -4000 15000 100]
102 #       ElementLine[-4000 15000 -6000 17000 100]
103 #       ElementLine[-6000 17000 -11000 17000 100]
104 #       ElementLine[-11000 17000 -11000 -1000 100]
105 #       )
106 #