diff options
author | Clifford Wolf <clifford@clifford.at> | 2013-11-08 04:44:09 +0100 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2013-11-08 04:44:09 +0100 |
commit | 4abc8e695ad0b3b11ae687d776856dd98b56101d (patch) | |
tree | 4be3de49238ba12be945a756de5de0f18897cb31 /frontends | |
parent | 81b8f3292e997cc2fda5f3da63cbca2707936c35 (diff) | |
download | yosys-4abc8e695ad0b3b11ae687d776856dd98b56101d.tar.gz yosys-4abc8e695ad0b3b11ae687d776856dd98b56101d.tar.bz2 yosys-4abc8e695ad0b3b11ae687d776856dd98b56101d.zip |
Implemented const folding of ternary op with undef select
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/ast/simplify.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/frontends/ast/simplify.cc b/frontends/ast/simplify.cc index 5c0130d42..9fa7f558b 100644 --- a/frontends/ast/simplify.cc +++ b/frontends/ast/simplify.cc @@ -1074,6 +1074,14 @@ skip_dynamic_range_lvalue_expansion:; if (choice != NULL && choice->type == AST_CONSTANT) { RTLIL::Const y = choice->bitsAsConst(width_hint, sign_hint); newNode = mkconst_bits(y.bits, sign_hint); + } else if (children[1]->type == AST_CONSTANT && children[2]->type == AST_CONSTANT) { + RTLIL::Const a = children[1]->bitsAsConst(width_hint, sign_hint); + RTLIL::Const b = children[2]->bitsAsConst(width_hint, sign_hint); + assert(a.bits.size() == b.bits.size()); + for (size_t i = 0; i < a.bits.size(); i++) + if (a.bits[i] != b.bits[i]) + a.bits[i] = RTLIL::State::Sx; + newNode = mkconst_bits(a.bits, sign_hint); } } break; |