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

[HWToBTOR2] Fix slice lowering argument meanings #7842

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

TaoBi22
Copy link
Contributor

@TaoBi22 TaoBi22 commented Nov 19, 2024

Seems like HWToBTOR2 currently implements the wrong semantics for slice in BTOR2 - we assume that BTOR2's slice operation takes the same arguments as our extract (the lowbit and the width) but it actually requires the upper and lower bits of the slice.

For example:

hw.module @Top() {
    %c0_i8 = hw.constant 0 : i8
    %extract = comb.extract %c0_i8 from 4 : (i8) -> i4
}

currently lowers to

1 sort bitvec 8
2 constd 1 0
3 sort bitvec 1
4 slice 3 2 0 4

which when given to Btor-mc throws

btormc: parse error in 'breaking.btor2' line 4: lower has to be less than or equal to upper

as it's expecting the 3rd argument of the slice to be the upper bit so it should be greater than the 4th.

@TaoBi22 TaoBi22 requested a review from dobios November 19, 2024 15:54
Copy link
Member

@dobios dobios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I can't believe no one ever ran into this before ^^"

@TaoBi22 TaoBi22 merged commit 9c3bbcf into llvm:main Nov 20, 2024
4 checks passed
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 this pull request may close these issues.

2 participants