From 4ba5bd12c612cbe27422cf86fe317d0723b11f30 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Fri, 18 Aug 2017 11:40:08 +0200 Subject: Add Const methods is_fully_zero(), is_fully_def(), and is_fully_undef() --- kernel/rtlil.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'kernel/rtlil.cc') diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 93cfef80e..4427303cc 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -161,6 +161,39 @@ std::string RTLIL::Const::decode_string() const return string; } +bool RTLIL::Const::is_fully_zero() const +{ + cover("kernel.rtlil.const.is_fully_zero"); + + for (auto bit : bits) + if (bit != RTLIL::State::S0) + return false; + + return true; +} + +bool RTLIL::Const::is_fully_def() const +{ + cover("kernel.rtlil.const.is_fully_def"); + + for (auto bit : bits) + if (bit != RTLIL::State::S0 && bit != RTLIL::State::S1) + return false; + + return true; +} + +bool RTLIL::Const::is_fully_undef() const +{ + cover("kernel.rtlil.const.is_fully_undef"); + + for (auto bit : bits) + if (bit != RTLIL::State::Sx && bit != RTLIL::State::Sz) + return false; + + return true; +} + void RTLIL::AttrObject::set_bool_attribute(RTLIL::IdString id) { attributes[id] = RTLIL::Const(1); -- cgit v1.2.3