From cb9bfed1699bd5c1ee0eed475e501c56383f62e7 Mon Sep 17 00:00:00 2001 From: nella Date: Thu, 25 Jun 2026 11:14:46 +0200 Subject: [PATCH] Tighten sig2bits. --- kernel/bitpattern.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/bitpattern.h b/kernel/bitpattern.h index e2071436c..76c008b89 100644 --- a/kernel/bitpattern.h +++ b/kernel/bitpattern.h @@ -102,11 +102,19 @@ struct BitPatternPool bits_t bits; bits.bitdata = sig.as_const().to_bits(); for (auto &b : bits.bitdata) - if (b > RTLIL::State::S1) + if (b > RTLIL::State::S1 && b != RTLIL::State::Sx && b != RTLIL::State::Sz) b = RTLIL::State::Sa; return bits; } + static bool covers_nothing(const bits_t &bits) + { + for (auto &b : bits.bitdata) + if (b == RTLIL::State::Sx || b == RTLIL::State::Sz) + return true; + return false; + } + /** * Two cubes match if their intersection is non-empty. */ @@ -132,6 +140,8 @@ struct BitPatternPool bool has_any(RTLIL::SigSpec sig) { bits_t bits = sig2bits(sig); + if (covers_nothing(bits)) + return false; for (auto &it : database) if (match(it, bits)) return true; @@ -150,6 +160,8 @@ struct BitPatternPool bool has_all(RTLIL::SigSpec sig) { bits_t bits = sig2bits(sig); + if (covers_nothing(bits)) + return true; for (auto &it : database) if (match(it, bits)) { for (int i = 0; i < width; i++) @@ -171,6 +183,8 @@ struct BitPatternPool { bool status = false; bits_t bits = sig2bits(sig); + if (covers_nothing(bits)) + return false; for (auto it = database.begin(); it != database.end();) if (match(*it, bits)) { for (int i = 0; i < width; i++) {