diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index e0cdfeef1..b5bce6d9a 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -5477,6 +5477,21 @@ bool RTLIL::SigSpec::has_const() const return false; } +bool RTLIL::SigSpec::has_const(RTLIL::State state) const +{ + cover("kernel.rtlil.sigspec.has_const"); + + pack(); + for (auto it = chunks_.begin(); it != chunks_.end(); it++) + if (it->width > 0 && it->wire == NULL) { + for (size_t i = 0; i < it->data.size(); i++) + if (it->data[i] == state) + return true; + } + return false; +} + + bool RTLIL::SigSpec::has_marked_bits() const { cover("kernel.rtlil.sigspec.has_marked_bits"); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 54d3227e4..05c804ea7 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -1155,6 +1155,7 @@ public: bool is_fully_def() const; bool is_fully_undef() const; bool has_const() const; + bool has_const(RTLIL::State state) const; bool has_marked_bits() const; bool is_onehot(int *pos = nullptr) const;