mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-17 08:42:16 +00:00
More fixes for bugs found using xsthammer
This commit is contained in:
parent
b1d39aa865
commit
0c6ffc4c65
5 changed files with 24 additions and 16 deletions
|
@ -752,7 +752,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint)
|
|||
RTLIL::SigSpec arg = children[0]->genRTLIL(width_hint);
|
||||
is_signed = type == AST_NEG || (type == AST_POS && children[0]->is_signed);
|
||||
int width = type == AST_NEG && arg.width < width_hint ? arg.width+1 : arg.width;
|
||||
if (width > width_hint && width_hint > 0)
|
||||
if (width_hint > 0)
|
||||
width = width_hint;
|
||||
return uniop2rtlil(this, type_name, width, arg);
|
||||
}
|
||||
|
@ -766,9 +766,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint)
|
|||
RTLIL::SigSpec left = children[0]->genRTLIL(width_hint);
|
||||
RTLIL::SigSpec right = children[1]->genRTLIL(width_hint);
|
||||
int width = std::max(left.width, right.width);
|
||||
if (width > width_hint && width_hint > 0)
|
||||
width = width_hint;
|
||||
if (width < width_hint)
|
||||
if (width_hint > 0)
|
||||
width = width_hint;
|
||||
return binop2rtlil(this, type_name, width, left, right);
|
||||
}
|
||||
|
|
|
@ -236,8 +236,8 @@ supply1 { return TOK_SUPPLY1; }
|
|||
"===" { return OP_EQ; }
|
||||
"!==" { return OP_NE; }
|
||||
|
||||
/* "~&" { return OP_NAND; } */
|
||||
/* "~|" { return OP_NOR; } */
|
||||
"~&" { return OP_NAND; }
|
||||
"~|" { return OP_NOR; }
|
||||
"~^" { return OP_XNOR; }
|
||||
"^~" { return OP_XNOR; }
|
||||
|
||||
|
|
|
@ -113,9 +113,9 @@ static void free_attr(std::map<std::string, AstNode*> *al)
|
|||
// operator precedence from low to high
|
||||
%left OP_LOR
|
||||
%left OP_LAND
|
||||
%left '|'
|
||||
%left '|' OP_NOR
|
||||
%left '^' OP_XNOR
|
||||
%left '&'
|
||||
%left '&' OP_NAND
|
||||
%left OP_EQ OP_NE
|
||||
%left '<' OP_LE OP_GE '>'
|
||||
%left OP_SHL OP_SHR OP_SSHL OP_SSHR
|
||||
|
@ -982,10 +982,20 @@ basic_expr:
|
|||
$$ = new AstNode(AST_REDUCE_AND, $3);
|
||||
append_attr($$, $2);
|
||||
} |
|
||||
OP_NAND attr basic_expr %prec UNARY_OPS {
|
||||
$$ = new AstNode(AST_REDUCE_AND, $3);
|
||||
append_attr($$, $2);
|
||||
$$ = new AstNode(AST_LOGIC_NOT, $$);
|
||||
} |
|
||||
'|' attr basic_expr %prec UNARY_OPS {
|
||||
$$ = new AstNode(AST_REDUCE_OR, $3);
|
||||
append_attr($$, $2);
|
||||
} |
|
||||
OP_NOR attr basic_expr %prec UNARY_OPS {
|
||||
$$ = new AstNode(AST_REDUCE_OR, $3);
|
||||
append_attr($$, $2);
|
||||
$$ = new AstNode(AST_LOGIC_NOT, $$);
|
||||
} |
|
||||
'^' attr basic_expr %prec UNARY_OPS {
|
||||
$$ = new AstNode(AST_REDUCE_XOR, $3);
|
||||
append_attr($$, $2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue