From f483dce7c231f83937b5944ed0166a70594a0e8b Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Wed, 29 Apr 2015 07:28:15 +0200 Subject: Added $eq/$neq -> $logic_not/$reduce_bool optimization --- kernel/rtlil.cc | 15 +++++++++++++++ kernel/rtlil.h | 1 + 2 files changed, 16 insertions(+) (limited to 'kernel') diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 8c0b41d09..bf0fd1c89 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -3000,6 +3000,21 @@ bool RTLIL::SigSpec::is_fully_const() const return true; } +bool RTLIL::SigSpec::is_fully_zero() const +{ + cover("kernel.rtlil.sigspec.is_fully_zero"); + + 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::S0) + return false; + } + return true; +} + bool RTLIL::SigSpec::is_fully_def() const { cover("kernel.rtlil.sigspec.is_fully_def"); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 956b303fd..e9deb1d5f 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -692,6 +692,7 @@ public: bool is_chunk() const; bool is_fully_const() const; + bool is_fully_zero() const; bool is_fully_def() const; bool is_fully_undef() const; bool has_const() const; -- cgit v1.2.3