Skip to content

feat: Sign extension - #33

Open
osmanyasar05 wants to merge 13 commits into
mainfrom
sign_extension
Open

feat: Sign extension#33
osmanyasar05 wants to merge 13 commits into
mainfrom
sign_extension

Conversation

@osmanyasar05

Copy link
Copy Markdown
Collaborator

This PR introduces sign-extension to our framework. The proof will be cleaned up.

@cowardsa cowardsa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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) :

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As above

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 "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What on earth does this mean?

@cowardsa cowardsa left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry meant to approve - comments above still apply

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