Add SigSpec::is_fully_ones()
authorClifford Wolf <clifford@clifford.at>
Tue, 12 Dec 2017 20:48:31 +0000 (21:48 +0100)
committerClifford Wolf <clifford@clifford.at>
Tue, 12 Dec 2017 20:48:31 +0000 (21:48 +0100)
kernel/rtlil.cc
kernel/rtlil.h

index 8c3d2962cb856752bfd6ba449d43a9ff32911d18..7dc7107c1ee4cc4b1b662dd459d60a20d9225d09 100644 (file)
@@ -3353,6 +3353,21 @@ bool RTLIL::SigSpec::is_fully_zero() const
        return true;
 }
 
+bool RTLIL::SigSpec::is_fully_ones() const
+{
+       cover("kernel.rtlil.sigspec.is_fully_ones");
+
+       pack();
+       for (auto it = chunks_.begin(); it != chunks_.end(); it++) {
+               if (it->width > 0 && it->wire != NULL)
+                       return false;
+               for (size_t i = 0; i < it->data.size(); i++)
+                       if (it->data[i] != RTLIL::State::S1)
+                               return false;
+       }
+       return true;
+}
+
 bool RTLIL::SigSpec::is_fully_def() const
 {
        cover("kernel.rtlil.sigspec.is_fully_def");
index 6ce9b6748b51d1cfd8a0297f1266473971334584..b33cb53a3c316280b7233e964f5fc8245ba08272 100644 (file)
@@ -704,6 +704,7 @@ public:
 
        bool is_fully_const() const;
        bool is_fully_zero() const;
+       bool is_fully_ones() const;
        bool is_fully_def() const;
        bool is_fully_undef() const;
        bool has_const() const;