Add RTLIL::Const::is_fully_ones()
authorClifford Wolf <clifford@clifford.at>
Thu, 14 Dec 2017 01:06:39 +0000 (02:06 +0100)
committerClifford Wolf <clifford@clifford.at>
Thu, 14 Dec 2017 01:06:39 +0000 (02:06 +0100)
kernel/rtlil.cc
kernel/rtlil.h

index 7dc7107c1ee4cc4b1b662dd459d60a20d9225d09..3e873054f13b7b5d61f3ad50d5ecb3f4ff4bef65 100644 (file)
@@ -172,6 +172,17 @@ bool RTLIL::Const::is_fully_zero() const
        return true;
 }
 
+bool RTLIL::Const::is_fully_ones() const
+{
+       cover("kernel.rtlil.const.is_fully_ones");
+
+       for (auto bit : bits)
+               if (bit != RTLIL::State::S1)
+                       return false;
+
+       return true;
+}
+
 bool RTLIL::Const::is_fully_def() const
 {
        cover("kernel.rtlil.const.is_fully_def");
index b33cb53a3c316280b7233e964f5fc8245ba08272..fc29e1e6515fd72448fb56177ff89e6383559539 100644 (file)
@@ -480,6 +480,7 @@ struct RTLIL::Const
        inline const RTLIL::State &operator[](int index) const { return bits.at(index); }
 
        bool is_fully_zero() const;
+       bool is_fully_ones() const;
        bool is_fully_def() const;
        bool is_fully_undef() const;