diff options
author | Claire Wolf <clifford@clifford.at> | 2020-04-15 16:01:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-15 16:01:19 +0200 |
commit | 4ee8fc1473a39d21ce765b09f43f327822519365 (patch) | |
tree | 33eecfdc523f4ec6949a63a597cf97f447ccfd4b /frontends/ast/genrtlil.cc | |
parent | 2e37e62e6b926ca1712b1636ef720748e382dc97 (diff) | |
parent | e7121cc15c33875b7da7bd54c246689f6cb25ea7 (diff) | |
download | yosys-4ee8fc1473a39d21ce765b09f43f327822519365.tar.gz yosys-4ee8fc1473a39d21ce765b09f43f327822519365.tar.bz2 yosys-4ee8fc1473a39d21ce765b09f43f327822519365.zip |
Merge pull request #1930 from YosysHQ/claire/fix1876
Fix handling of ternary with constant condition
Diffstat (limited to 'frontends/ast/genrtlil.cc')
-rw-r--r-- | frontends/ast/genrtlil.cc | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc index c0539252c..ab368fdb0 100644 --- a/frontends/ast/genrtlil.cc +++ b/frontends/ast/genrtlil.cc @@ -1326,20 +1326,25 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint) { if (width_hint < 0) detectSignWidth(width_hint, sign_hint); + is_signed = sign_hint; RTLIL::SigSpec cond = children[0]->genRTLIL(); RTLIL::SigSpec sig; - if (cond.is_fully_const()) { + + if (cond.is_fully_def()) + { if (cond.as_bool()) { sig = children[1]->genRTLIL(width_hint, sign_hint); - widthExtend(this, sig, sig.size(), children[1]->is_signed); - } - else { + log_assert(is_signed == children[1]->is_signed); + } else { sig = children[2]->genRTLIL(width_hint, sign_hint); - widthExtend(this, sig, sig.size(), children[2]->is_signed); + log_assert(is_signed == children[2]->is_signed); } + + widthExtend(this, sig, sig.size(), is_signed); } - else { + else + { RTLIL::SigSpec val1 = children[1]->genRTLIL(width_hint, sign_hint); RTLIL::SigSpec val2 = children[2]->genRTLIL(width_hint, sign_hint); @@ -1347,7 +1352,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint) cond = uniop2rtlil(this, ID($reduce_bool), 1, cond, false); int width = max(val1.size(), val2.size()); - is_signed = children[1]->is_signed && children[2]->is_signed; + log_assert(is_signed == children[1]->is_signed); + log_assert(is_signed == children[2]->is_signed); widthExtend(this, val1, width, is_signed); widthExtend(this, val2, width, is_signed); |