diff --git a/src/db/db/dbVia.cc b/src/db/db/dbVia.cc index 65e875568..78844b3f6 100644 --- a/src/db/db/dbVia.cc +++ b/src/db/db/dbVia.cc @@ -39,7 +39,9 @@ ViaType::init () htmin = 0.0; htmax = -1.0; bottom_wired = true; + bottom_grid = 0.0; top_wired = true; + top_grid = 0.0; } // --------------------------------------------------------------------------------------- diff --git a/src/db/db/dbVia.h b/src/db/db/dbVia.h index 78f24a304..492e1333e 100644 --- a/src/db/db/dbVia.h +++ b/src/db/db/dbVia.h @@ -128,6 +128,13 @@ public: */ bool bottom_wired; + /** + * @brief The grid of the bottom layer + * + * Via dimensions are rounded to this grid on the bottom layer, if non-zero. + */ + double bottom_grid; + /** * @brief The cut layer */ @@ -146,6 +153,13 @@ public: */ bool top_wired; + /** + * @brief The grid of the top layer + * + * Via dimensions are rounded to this grid on the top layer, if non-zero. + */ + double top_grid; + /** * @brief The name of the via * diff --git a/src/db/db/gsiDeclDbVia.cc b/src/db/db/gsiDeclDbVia.cc index 7ef8b9fb3..1090afef4 100644 --- a/src/db/db/gsiDeclDbVia.cc +++ b/src/db/db/gsiDeclDbVia.cc @@ -136,6 +136,12 @@ Class decl_dbViaType ("db", "ViaType", "If false, the bottom layer is assume to be a sheet layer, such as diffusion. " "In this case, changing the routing layer will not continue drawing a path. " "If true (the default), drawing will continue on the bottom layer as a path." + ) + + make_getter_setter ("bottom_grid", + "@brief If non-zero, the bottom layer's dimensions will be rounded to this grid.\n" + ) + + make_getter_setter ("top_grid", + "@brief If non-zero, the top layer's dimensions will be rounded to this grid.\n" ), "@brief Describes a via type\n" "These objects are used by PCellDeclaration#via_types to specify the via types a " diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index 11cd444f2..9defcd9bc 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -1652,7 +1652,7 @@ PathService::via_initial (int dir) } void -PathService::compute_via_wh (double &w, double &h, const db::DVector &dwire, double var_ext) +PathService::compute_via_wh (double &w, double &h, const db::DVector &dwire, double var_ext, double grid) { w = 0.0, h = 0.0; @@ -1734,10 +1734,14 @@ PathService::compute_via_wh (double &w, double &h, const db::DVector &dwire, dou } - // round down to DBU @@@ (grid) - double dbu = layout ().dbu (); - w = floor (w / dbu + db::epsilon) * dbu; - h = floor (h / dbu + db::epsilon) * dbu; + // round to grid or DBU + + if (grid < db::epsilon) { + grid = layout ().dbu (); + } + + w = floor (w / grid + db::epsilon) * grid; + h = floor (h / grid + db::epsilon) * grid; } void @@ -1765,7 +1769,7 @@ PathService::via_editing (int dir) db::DVector dwire = m_points.back () - m_points [m_points.size () - 2]; double w = 0.0, h = 0.0; - compute_via_wh (w, h, dwire, m_endext); + compute_via_wh (w, h, dwire, m_endext, is_bottom ? via_def.via_type.bottom_grid : via_def.via_type.top_grid); double w_bottom = 0.0, h_bottom = 0.0, w_top = 0.0, h_top = 0.0; (is_bottom ? w_bottom : w_top) = w; @@ -1820,7 +1824,7 @@ PathService::update_via () bool is_bottom = ps.via_type.bottom.log_equal (lp); double w = 0.0, h = 0.0; - compute_via_wh (w, h, m_points [1] - m_points [0], m_bgnext); + compute_via_wh (w, h, m_points [1] - m_points [0], m_bgnext, is_bottom ? ps.via_type.bottom_grid : ps.via_type.top_grid); std::map params; diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index 2a401d40f..a2daecd15 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -275,7 +275,7 @@ private: db::Path get_path () const; void set_last_point (const db::DPoint &p); void update_via (); - void compute_via_wh (double &w, double &h, const db::DVector &dwire, double var_ext); + void compute_via_wh (double &w, double &h, const db::DVector &dwire, double var_ext, double grid); db::Instance make_via (const db::SelectedViaDefinition &via_def, double w_bottom, double h_bottom, double w_top, double h_top, const db::DPoint &via_pos); void via_initial (int dir); void via_editing (int dir);