-
Notifications
You must be signed in to change notification settings - Fork 0
64-bit ALU Verification, Part I #70
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
Conversation
* import RV64IM * revert to regidx from SailM after BitVec instance fix
SP1Chips/SubChip.lean
Outdated
| (cstrs : (constraints Main).allHold) | ||
| (h_is_real : Main[32] = 1) | ||
|
|
||
| def spec_add (rs2 rs1 rd : regidx) : SailM Unit := do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spec_sub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
SP1Chips/SubChip.lean
Outdated
|
|
||
| open Sail | ||
|
|
||
| theorem correct_add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct_sub
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
SP1Chips/ShiftRightChip.lean
Outdated
| let op_a := sp1_op_a Main cstrs (srl_real Main srl) | ||
| -- TODO(gzgz): we can obtain this from the constraint compiler | ||
| -- This comes from the Interaction.state in CPUState | ||
| Sail.writeReg Register.nextPC (Word.toBitVec64 #v[Main[3], Main[4], Main[5], 0] + 4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value that's actually being written is Word.toBitVec64 #v[Main[3] + 4, Main[4], Main[5], 0]. Could you please update all of your chip proof to use this instead? The equivalence holds using something like this:
have : (↑(Main[3]$ + 4) + ↑Main[4]$ <<< 16 + ↑Main[5]$ <<< 32 : ℕ) = ↑Main[3]$ + ↑Main[4]$ <<< 16 + ↑Main[5]$ <<< 32 + 4 := by
simp [Fin.add_def]
rw [Nat.mod_eq_of_lt (by clear * - h_pc0; linarith)]
ring_nf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean here. Actually being written by whom? The Rust code of the reader?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any case, done.
This PR introduces the following specifications and proofs:
IsEqualWord,IsZero,IsZeroWord,LtOperationSigned,LtOperationUnsigned,U16Compare,Add,Addw,Sub,Subw,U16MSB, andU16toU8Unsafeoperations;ALUType,CpuState,IType, andRTypereaders; andDiv- andRem-related ones.It also provides the proof of the axiom previously introduced in
LtOperationSigned.I would suggest that the proofs for other operations, readers, and opcodes that have appeared in the meantime be revisited in the style of the ones I've proven. In particular, the shift-right operation has the most streamlined structure that simplifies chip proofs greatly.