Scalar operations and variable shifts on multiword banks #
Scalar operations assemble both operands before writing the destination, so the destination may coincide with either source. Their inputs and result must fit the physical word width. Variable right shifts assemble only the shift amount; the shifted input remains multiword.
Main definitions #
Bank.scalar: a checked physical binary operation between bank entries.Bank.shift: a variable right shift into a distinct bank entry.
Main results #
Bank.exec_scalar: exact execution in 133 instructions, preserving other entries and memory.Bank.exec_shift: execution within 123 instructions, preserving other entries and memory.
References #
def Cslib.WordRAM.Multiword.Bank.scalar {n : ℕ} (f : BinOp) (a b d : Fin n) :
Code Basis.standard (capacity n + 4)
Assemble into physical registers four and five, compute in register six, and split the checked result into the destination. Both inputs are read before any bank entry is written.
Instances For
theorem Cslib.WordRAM.Multiword.Bank.exec_scalar {n w : ℕ} (hw : 2 ≤ w) (f : BinOp) (a b d : Fin n) (x : Data (capacity n + 4)) {v : Fin n → ℕ} (hx : Encodes w x v) (hfa : Fits w (v a)) (hfb : Fits w (v b)) (hresult : Fits w (f.eval (v a) (v b))) :
Checked scalar arithmetic permits either source to coincide with the destination.
def Cslib.WordRAM.Multiword.Bank.shift {n : ℕ} (w : ℕ) (a b d : Fin n) :
Code Basis.standard (capacity n + 4)
Assemble the scalar shift amount in physical register four, then shift the multiword input. The destination must be distinct from the input, but may contain the original shift amount.