feat: Sign extension - #33
Open
osmanyasar05 wants to merge 13 commits into
Open
Conversation
cowardsa
reviewed
Sep 7, 2026
cowardsa
left a comment
There was a problem hiding this comment.
LGTM - I got pretty lost in the section that handles how sext operations are parsed at the front-end of datapath-cli but I think that is something we can revisit later on to define a more rigorous interface.
Otherwise just a few comment requests -but imagine the interface is changing in a follow-up PR anyway - as per latest benchmark resutls
| | .add args => (args.map (denote ρ)).foldl (· + ·) 0 | ||
| | .mul l r => denote ρ l * denote ρ r | ||
| | .zext i b _ => ((ρ i).setWidth b).setWidth w | ||
| | .sext i b _ _ => ((ρ i).setWidth b).signExtend w |
There was a problem hiding this comment.
This is just the Lean bv.signExtend right? If so that's very pleasing :)
Comment on lines
+130
to
+131
| theorem signFillNat_lt (x : BitVec n) (bits k w : Nat) (hbits : 0 < bits) (hk : bits + k ≤ w) : | ||
| signFillNat x bits k < 2 ^ w := by |
There was a problem hiding this comment.
Non-blocking but a comment would be helpful to describe this theorem?
| set a := x.toNat % 2 ^ bits | ||
| split <;> omega | ||
|
|
||
| theorem signFillNat_succ (x : BitVec n) (bits k : Nat) (hbits : 0 < bits) : |
Comment on lines
+135
to
+137
| /-- Render an operand spec as its protocol token: `<live>` or `<live>s`. -/ | ||
| def specToken (live : Nat) (signed : Bool) : String := | ||
| toString live ++ (if signed then "s" else "") |
cowardsa
approved these changes
Sep 7, 2026
cowardsa
left a comment
There was a problem hiding this comment.
Sorry meant to approve - comments above still apply
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces sign-extension to our framework. The proof will be cleaned up.