Skip to content

Commit

Permalink
Merge pull request #4065 from daglem/fix-AST_SHIFT-AST_SHIFTX
Browse files Browse the repository at this point in the history
Respect the sign of the right operand of AST_SHIFT and AST_SHIFTX
  • Loading branch information
povik authored Dec 12, 2023
2 parents 7bded22 + cda470d commit 320e75a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion frontends/ast/genrtlil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
if (width_hint < 0)
detectSignWidth(width_hint, sign_hint);
RTLIL::SigSpec left = children[0]->genRTLIL(width_hint, sign_hint);
RTLIL::SigSpec right = children[1]->genRTLIL();
// for $shift and $shiftx, the second operand can be negative
RTLIL::SigSpec right = children[1]->genRTLIL(-1, type == AST_SHIFT || type == AST_SHIFTX);
int width = width_hint > 0 ? width_hint : left.size();
is_signed = children[0]->is_signed;
return binop2rtlil(this, type_name, width, left, right);
Expand Down

0 comments on commit 320e75a

Please sign in to comment.