1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
| load("vias.ael");
defun grid_ceil2(input) { return ceil(100*input)/100.0; }
defun grid_floor2(input) { return floor(100*input)/100.0; }
defun adjust(l, xc, yc, x, y) { decl i = 0; decl len = listlen( l ); for( i = 0; i < len; i++ ) { decl t = list(l[i][0] * xc + x, l[i][1] * yc + y); repla(l, t, i); } }
defun create_crossing(context, layerM1, w, s, t, x, y, xc, yc) { e = grid_ceil2( w * (sqrt(2) - 1) ); decl x1 = (w + s - e) / 2.0; decl x2 = (w + s + e) / 2.0; decl coors = list( list(- t, 0), list(- x1 , 0), list(x2, w + s), list(t, w + s), list(t, 2 * w + s), list(x1, 2 * w + s), list(- x2, w), list(- t, w), list(- t, 0) ); adjust(coors, xc, yc, x, y); decl newPolygon = db_create_primitive_polygon(coors); db_create_polygon(context, layerM1, newPolygon); }
defun create_coil(context, layerM, Dw, Dh, Dd, w, t, x, y) { decl e = grid_ceil2( w * (sqrt(2) - 1) ); decl coors = list( list(t, Dh + Dd - w), list(Dw - e < Dw + Dd - w ? Dw - e : Dw + Dd - w, Dh + Dd - w), list(Dw + Dd - w, Dh - e < Dh + Dd - w ? Dh - e : Dh + Dd - w), list(Dw + Dd - w, -Dh + e > -Dh - Dd + w ? -Dh + e : -Dh - Dd + w), list(Dw - e < Dw + Dd - w ? Dw - e : Dw + Dd - w, - Dh - Dd + w), list(t, - Dh - Dd + w), list(t, - Dh - Dd), list(Dw, - Dh - Dd), list(Dw + Dd, - Dh), list(Dw + Dd, Dh), list(Dw, Dh + Dd), list(t, Dh + Dd), list(t, Dh + Dd - w) ); adjust(coors, 1, 1, x, y); decl newPolygon = db_create_primitive_polygon(coors); db_create_polygon(context, layerM, newPolygon);
adjust(coors, -1, 1, 0, 0); decl newPolygon2 = db_create_primitive_polygon(coors); db_create_polygon(context, layerM, newPolygon2); }
defun create_tj(context, layerM, w1, s1, t, w2, s2, e, x, y, dir) { decl d = s2 - s1; decl ar = grid_floor2( 0.5 * ( sqrt(2)/2 * (w1 + w2) - w1 +e - s2 + s1 ) ); decl al = e - ar - s2 + s1; decl coors = list( list(-t, 0), list(-s1, 0), list(-s1, -w1 - ar), list(-s2, -w1 - ar - (s2-s1)), list(-s2, -w1 - e), list(-s2 - w2, -w1 - e), list(-s2 - w2, -w1 - al - (w2+s2-w1-s1)), list(-s1 - w1, -w1 - al), list(-s1 - w1, -w1), list(-t, -w1), list(-t, 0) ); db_create_pin(context, x-s2-w2/2, pow(-1, dir)*(y+e+w1), pow(-1, dir)*90, layerM); db_create_pin(context, x+s2+w2/2, pow(-1, dir)*(y+e+w1), pow(-1, dir)*90, layerM);
adjust(coors, 1, pow(-1, dir+1), x, pow(-1, dir)*y); decl newPolygon = db_create_primitive_polygon(coors); db_create_polygon(context, layerM, newPolygon); adjust(coors, -1, 1, 0, 0); decl newPolygon2 = db_create_primitive_polygon(coors); db_create_polygon(context, layerM, newPolygon2); }
defun create_diff_inductor(context, MT, MB, D, W, S, C, RH, RD, s1, w2, s2, e, x, y, dir, combine) { decl AP = db_get_layerid(context, "AP", "drawing"); decl M9 = db_get_layerid(context, "M9", "drawing"); decl M8 = db_get_layerid(context, "M8", "drawing"); decl M7 = db_get_layerid(context, "M7", "drawing"); decl M6 = db_get_layerid(context, "M6", "drawing"); decl M5 = db_get_layerid(context, "M5", "drawing"); decl M4 = db_get_layerid(context, "M4", "drawing"); decl M3 = db_get_layerid(context, "M3", "drawing"); decl M2 = db_get_layerid(context, "M2", "drawing"); decl M1 = db_get_layerid(context, "M1", "drawing"); decl Metals = list(M1, M1, M2, M3, M4, M5, M6, M7, M8, M9, AP); decl via9 = db_get_layerid(context, "via9", "drawing"); decl via8 = db_get_layerid(context, "via8", "drawing"); decl via7 = db_get_layerid(context, "via7", "drawing"); decl via6 = db_get_layerid(context, "via6", "drawing"); decl via5 = db_get_layerid(context, "via5", "drawing"); decl via4 = db_get_layerid(context, "via4", "drawing"); decl via3 = db_get_layerid(context, "via3", "drawing"); decl via2 = db_get_layerid(context, "via2", "drawing"); decl via1 = db_get_layerid(context, "via1", "drawing"); decl Vias = list(via1, via1, via2, M3, M4, M5, M6, M7, M8, M9, AP);
decl layerM1 = Metals[MT]; decl layerM2 = Metals[MB]; decl i = 0; decl Dw = grid_ceil2( D / 2 ); decl Dh = grid_ceil2( D / 2 * RH ); decl Dd = grid_ceil2( D * RD / sqrt(2) ); decl ew = grid_ceil2( W * (sqrt(2) - 1) ); decl es = grid_ceil2( S * (sqrt(2) - 1) );
decl iDW = Dw; for(i = 0; i < C - 1; i++) iDW = grid_floor2( iDW - ew - es ); decl wv = grid_floor(iDW - (1 + (W + S + ew) / 2)); if(wv > 2 * W) wv = 2 * W; decl t = grid_floor( wv + 1 + (W + S + ew) / 2 ); create_tj(context, layerM1, W, s1, t, w2, s2, e, x, y+Dh+Dd-W, dir);
for(i = 0; i < C; i++) { create_coil(context, layerM1, Dw, Dh, Dd, W, t, x, y); decl newDw = grid_floor2( Dw - ew - es ); decl newDh = grid_floor2( Dh - ew - es ); decl newDd = grid_floor2( Dd - W - S + ew + es ); if(newDd < 0) { newDw = newDw + newDd; newDh = newDh + newDd; newDd = 0; } decl cs = Dh + Dd - newDh - newDd - W; if(i != C - 1) { if(dir == 0) { create_crossing(context, layerM1, W, cs, t, x, y-Dh-Dd, 1, 1); create_crossing(context, layerM2, W, cs, t, x, y-Dh-Dd, -1, 1); via_fill7to9(MB, MT, wv, W, 0.3, 0.3, 0.3, 0.3, x-t, y-(Dh+Dd)+W+cs, combine); via_fill7to9(MB, MT, wv, W, 0.3, 0.3, 0.3, 0.3, x+t-wv, y-(Dh+Dd), combine); } if(dir == 1) { create_crossing(context, layerM1, W, cs, t, x, y+Dh+Dd, 1, -1); create_crossing(context, layerM2, W, cs, t, x, y+Dh+Dd, -1, -1); via_fill7to9(MB, MT, wv, W, 0.3, 0.3, 0.3, 0.3, x-t, y+Dh+Dd-2*W-cs, combine); via_fill7to9(MB, MT, wv, W, 0.3, 0.3, 0.3, 0.3, x+t-wv, y+Dh+Dd-W, combine); } } else db_add_rectangle(context, layerM1, x-t, y+pow(-1, dir+1)*(Dh+Dd), x+t, y+pow(-1, dir+1)*(Dh+Dd-W)); Dw = newDw; Dh = newDh; Dd = newDd; dir = 1 - dir; } }
defun create_diff_inductor2(context, MT, MB, D, W, S, C, RH, RD, s1, w2, s2, e, x, y, dir, combine) { D = grid_ceil2( D * RH ); RH = 1 / RH; RD = RD * RH; create_diff_inductor(context, MT, MB, D, W, S, C, RH, RD, s1, w2, s2, e, x, y, dir, combine); }
defun diff_inductor(MT, MB, D, W, S, C, RH, RD, s1, w2, s2, e, dir, combine) { decl designContext = de_get_current_design_context(); decl mks2uu = db_get_mks_to_uu_factor(designContext);
D = D * mks2uu; W = W * mks2uu; S = S * mks2uu; C = floor(C); s1 = s1 * mks2uu; w2 = w2 * mks2uu; s2 = s2 * mks2uu; e = e * mks2uu; dir = floor(dir); combine = floor(combine);
create_diff_inductor2(designContext, MT, MB, D, W, S, C, RH, RD, s1, w2, s2, e, 0, 0, dir, combine); }
|