From: Zachary Snow Date: Wed, 24 Mar 2021 15:23:23 +0000 (-0400) Subject: rtlil: add const accessors for modules, wires, and cells X-Git-Tag: yosys-0.10~230 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d6d5c2ef342240bd8adb925055667d140cb8dd29;p=yosys.git rtlil: add const accessors for modules, wires, and cells --- diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 87cbaa0d5..770405720 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -580,6 +580,11 @@ RTLIL::Module *RTLIL::Design::module(RTLIL::IdString name) return modules_.count(name) ? modules_.at(name) : NULL; } +const RTLIL::Module *RTLIL::Design::module(RTLIL::IdString name) const +{ + return modules_.count(name) ? modules_.at(name) : NULL; +} + RTLIL::Module *RTLIL::Design::top_module() { RTLIL::Module *module = nullptr; diff --git a/kernel/rtlil.h b/kernel/rtlil.h index bbdf355fa..3137deb00 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -1043,6 +1043,7 @@ struct RTLIL::Design RTLIL::ObjRange modules(); RTLIL::Module *module(RTLIL::IdString name); + const RTLIL::Module *module(RTLIL::IdString name) const; RTLIL::Module *top_module(); bool has(RTLIL::IdString id) const { @@ -1191,6 +1192,15 @@ public: return it == cells_.end() ? nullptr : it->second; } + const RTLIL::Wire* wire(RTLIL::IdString id) const{ + auto it = wires_.find(id); + return it == wires_.end() ? nullptr : it->second; + } + const RTLIL::Cell* cell(RTLIL::IdString id) const { + auto it = cells_.find(id); + return it == cells_.end() ? nullptr : it->second; + } + RTLIL::ObjRange wires() { return RTLIL::ObjRange(&wires_, &refcount_wires_); } RTLIL::ObjRange cells() { return RTLIL::ObjRange(&cells_, &refcount_cells_); }