vast icon indicating copy to clipboard operation
vast copied to clipboard

Order of operations incorrect for addition and bit shift

Open nathanielnrn opened this issue 2 years ago • 0 comments

@rachitnigam Currently vast produces the wrong output when a bit shift is part of an add expression. The output does not respect verilog order of operations.

Here is a test that fails:

#[test]
fn test_bit_shift_order_of_operations() {
    let bin1 = Expr::new_ulit_bin(4, "1000");
    let bin2 = Expr::new_ulit_bin(4, "0100");
    let shift_by :i32 = 2;
    let shift = Expr::new_shift_left(bin1, shift_by);
    let add = Expr::new_add(bin2, shift);
    let exp = "4'b0100 + (4'b1000 << 2)".to_string();
    let res = add.to_string();
    check!(res, exp);
}

with a result of 4'b0100 + 4'b1000 << 2 instead of 4'b0100 + (4'b1000 << 2)

If this is a more general issue I'd be happy to look into it more.

nathanielnrn avatar Jul 11 '22 15:07 nathanielnrn