From 93a24fe275509c5a69f3fc94b29306afe3593cf1 Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Mon, 29 Sep 2025 20:56:58 -0700 Subject: [PATCH] Put back is_mostly_const --- kernel/rtlil.cc | 12 ++++++++++++ kernel/rtlil.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index c5ecf1573..1be54dca1 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -5437,6 +5437,18 @@ bool RTLIL::SigSpec::is_chunk() const return GetSize(chunks_) == 1; } +bool RTLIL::SigSpec::is_mostly_const() const +{ + cover("kernel.rtlil.sigspec.is_mostly_const"); + + pack(); + int constbits = 0; + for (auto it = chunks_.begin(); it != chunks_.end(); it++) + if (it->width > 0 && it->wire == NULL) + constbits += it->width; + return (constbits > width_/2); +} + bool RTLIL::SigSpec::known_driver() const { pack(); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index d12a33080..a9d2accdf 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -1347,7 +1347,8 @@ public: inline bool is_bit() const { return width_ == 1; } bool known_driver() const; - + + bool is_mostly_const() const; bool is_fully_const() const; bool is_fully_zero() const; bool is_fully_ones() const;