@@ -447,9 +447,30 @@ void Connect::makeVia(odb::dbSWire* wire,
447447{
448448 const odb::Rect& lower_rect = lower->getRect ();
449449 const odb::Rect& upper_rect = upper->getRect ();
450- const odb::Rect intersection = lower_rect.intersect (upper_rect);
450+ odb::Rect intersection = lower_rect.intersect (upper_rect);
451451
452452 auto * tech = layer0_->getTech ();
453+
454+ // Attempt to snap to grid
455+ if (tech->hasManufacturingGrid ()) {
456+ const odb::Rect new_intersection (
457+ TechLayer::snapToManufacturingGrid (tech, intersection.xMin (), true , 2 ),
458+ TechLayer::snapToManufacturingGrid (tech, intersection.yMin (), true , 2 ),
459+ TechLayer::snapToManufacturingGrid (tech, intersection.xMax (), false , 2 ),
460+ TechLayer::snapToManufacturingGrid (
461+ tech, intersection.yMax (), false , 2 ));
462+ if (intersection != new_intersection) {
463+ debugPrint (grid_->getLogger (),
464+ utl::PDN,
465+ " Via" ,
466+ 2 ,
467+ " intersection changed: {} -> {}" ,
468+ Shape::getRectText (intersection, tech->getLefUnits ()),
469+ Shape::getRectText (new_intersection, tech->getLefUnits ()));
470+ intersection = new_intersection;
471+ }
472+ }
473+
453474 const int x = std::round (0.5 * (intersection.xMin () + intersection.xMax ()));
454475 const int y = std::round (0.5 * (intersection.yMin () + intersection.yMax ()));
455476
0 commit comments