Index: plugins/rt_topo/laa3_solve.c =================================================================== --- plugins/rt_topo/laa3_solve.c (revision 1466) +++ plugins/rt_topo/laa3_solve.c (revision 1467) @@ -29,6 +29,11 @@ /* LAA step III: find the optimal resolution of crossings by activating vias and detorus */ +/* bloat up via bboxes so via-via placement leaves enough room for a trace; also + make sure vias are not placed closer than this initially */ +#define VIA_SPACING_BLOAT ((rt_topo_cfg.wire_thick + rt_topo_cfg.wire_clr) * rt_topo_cfg.via_via_space) + + static double laa_cost_2net_update(rt_topo_laa_2net_t *tn) { double cost = 0; @@ -93,6 +98,33 @@ printf("initial board cost: %f\n", cost); } +/* Return 1 if layer assignment along a tn has 2 vias too close */ +static int laa3_vias_too_close(rt_topo_laa_2net_t *tn, double min_dist2) +{ + double lastx, lasty; + long bi; + + /* printf("VIAS-too-close: %f;%f to %f;%f:\n", tn->br.array[0].x, tn->br.array[0].y, tn->br.array[tn->br.used-1].x, tn->br.array[tn->br.used-1].y); */ + + lastx = tn->br.array[0].x; + lasty = tn->br.array[0].y; + for(bi = 1; bi < tn->br.used; bi++) { + if (tn->asg[bi] != tn->asg[bi-1]) { + double dx = tn->br.array[bi].x - lastx; + double dy = tn->br.array[bi].y - lasty; + double dist2 = dx*dx + dy*dy; + + /* printf(" dist2=%f (< %f) at %f;%f\n", dist2, min_dist2, tn->br.array[bi].x, tn->br.array[bi].y); */ + if (dist2 < min_dist2) + return 1; + lastx = tn->br.array[bi].x; + lasty = tn->br.array[bi].y; + } + } + + return 0; +} + static double laa3_solve_best(laa3_t *laa3) { htsp_entry_t *e; @@ -100,7 +132,10 @@ double best_gain = 0, gain, best_detcost, detcost, best_vialayercost, vialayercost; rt_topo_laa_2net_t *tn, *best_tn = NULL; int lid, ci, best_ci = -1, best_lid = -1, orig_lid; + double min_dist2 = VIA_SPACING_BLOAT + rt_topo_cfg.via_dia + rt_topo_cfg.via_clr; + min_dist2 = min_dist2 * min_dist2; + /* take each crossing... */ for(e = htsp_first(&ctx->board->nets); e != NULL; e = htsp_next(&ctx->board->nets, e)) { rtrnd_net_t *net = e->value; @@ -121,6 +156,7 @@ detcost = laa_cost_2net_calc_cross(laa3, tn, ci, 0); vialayercost = laa_cost_2net_calc_via_layer(laa3, tn, 0); gain = (cr->detcost + tn->cost_vialayer) - (detcost + vialayercost); + if (laa3_vias_too_close(tn, min_dist2)) gain = 0; if (gain > best_gain) { best_gain = gain; best_tn = tn; @@ -270,10 +306,8 @@ { rtrnd_t *ctx = laa3->ctx; long n; - double bloat; + double bloat = VIA_SPACING_BLOAT; - /* bloat up via bboxes so via-via placement leaves enough room for a trace */ - bloat = (rt_topo_cfg.wire_thick + rt_topo_cfg.wire_clr) * rt_topo_cfg.via_via_space; rtrnd_rtree_init(rtv); for(n = 0; n < vias->used; n++) {