Skip to content

Commit 5cb7e07

Browse files
committed
csa chain
1 parent 5e69314 commit 5cb7e07

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

DatapathVerification/CSA.lean

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,25 @@ theorem mul4_correct (a b : BitVec 4) : a * b = mul4 a b := by
5959
simp only [mul4, carrySave]
6060
bv_decide
6161

62+
def csaChain (a : Fin (n + 2) → BitVec w)
63+
: (i : ℕ) → (i ≤ n) → BitVec w × BitVec w
64+
| 0, _ => (a ⟨0, by omega⟩, a ⟨1, by omega⟩)
65+
| i + 1, h =>
66+
let (sum_prev, carry_prev) := csaChain a i (by omega)
67+
let ⟨s, t⟩ := carrySave w sum_prev carry_prev (a ⟨i + 2, by omega⟩)
68+
(s, t <<< 1)
69+
70+
def finSum (a : Fin n → BitVec w) : BitVec w :=
71+
Finset.univ.sum a
72+
73+
theorem csaChain_correct (a : Fin (n + 2) → BitVec w)
74+
(h : n > 0) :
75+
let (carry, sum) := csaChain a n (le_refl n)
76+
carry + sum = finSum a := by
77+
induction n with
78+
| zero => omega
79+
| succ k ih =>
80+
sorry
81+
82+
6283
end CSA

0 commit comments

Comments
 (0)