WIP: introducing grids in vias

This commit is contained in:
Matthias Koefferlein 2025-08-22 23:46:24 +02:00
parent d77eb32db4
commit 3068c1da29
5 changed files with 34 additions and 8 deletions

View File

@ -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;
}
// ---------------------------------------------------------------------------------------

View File

@ -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
*

View File

@ -136,6 +136,12 @@ Class<db::ViaType> 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<db::ViaType, double, &db::ViaType::bottom_grid> ("bottom_grid",
"@brief If non-zero, the bottom layer's dimensions will be rounded to this grid.\n"
) +
make_getter_setter<db::ViaType, double, &db::ViaType::top_grid> ("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 "

View File

@ -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<std::string, tl::Variant> params;

View File

@ -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);