Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order of operations incorrect for addition and bit shift #12

Open
nathanielnrn opened this issue Jul 11, 2022 · 0 comments · May be fixed by #13
Open

Order of operations incorrect for addition and bit shift #12

nathanielnrn opened this issue Jul 11, 2022 · 0 comments · May be fixed by #13

Comments

@nathanielnrn
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant