From 4883c503a882a3168f23cdb50dec289908a54666 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Fri, 21 Feb 2025 16:10:51 +1300 Subject: [PATCH] celltypes: get_cell() helper Add `CellTypes::get_cell()` which takes a 'type' `IdString` and returns the corresponding `CellType` if it is in the `cell_types` dict, otherwise returns `nullptr`. Useful for getting a cell type by name and then checking its attributes. --- kernel/celltypes.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/celltypes.h b/kernel/celltypes.h index 08773b4eb..441fc1d10 100644 --- a/kernel/celltypes.h +++ b/kernel/celltypes.h @@ -331,6 +331,15 @@ struct CellTypes cell_types.clear(); } + const CellType* get_cell(RTLIL::IdString type) const + { + auto it = cell_types.find(type); + if (it == cell_types.end()) + return nullptr; + else + return &(it->second); + } + bool cell_known(RTLIL::IdString type) const { return cell_types.count(type) != 0;