From c4f435569f6c8d3649ed82d5d2e2588f94b0b6c5 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Wed, 3 Sep 2025 15:29:08 +0200 Subject: [PATCH] kernel: Add known_driver method to Wire/SigSpec --- kernel/rtlil.cc | 9 +++++++++ kernel/rtlil.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 4e94b8cc1..5f8e6ad66 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -5534,6 +5534,15 @@ bool RTLIL::SigSpec::is_chunk() const return GetSize(chunks_) == 1; } +bool RTLIL::SigSpec::known_driver() const +{ + pack(); + for (auto &chunk : chunks_) + if (chunk.is_wire() && !chunk.wire->known_driver()) + return false; + return true; +} + bool RTLIL::SigSpec::is_fully_const() const { cover("kernel.rtlil.sigspec.is_fully_const"); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 4c3e2182e..15154eb64 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -1329,6 +1329,8 @@ public: bool is_chunk() const; inline bool is_bit() const { return width_ == 1; } + bool known_driver() const; + bool is_fully_const() const; bool is_fully_zero() const; bool is_fully_ones() const; @@ -2059,6 +2061,8 @@ public: int width, start_offset, port_id; bool port_input, port_output, upto, is_signed; + bool known_driver() const { return driverCell_ != nullptr; } + RTLIL::Cell *driverCell() const { log_assert(driverCell_); return driverCell_; }; RTLIL::IdString driverPort() const { log_assert(driverCell_); return driverPort_; };