Skip to content

Commit

Permalink
chore: write alternative for read/write_bytes called read/write_bytes…
Browse files Browse the repository at this point in the history
…' that takes bitvec as argument
  • Loading branch information
bollu committed Oct 3, 2024
1 parent 6deed7e commit 421619e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Arm/State.lean
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,9 @@ def read_bytes (n : Nat) (addr : BitVec 64) (m : Memory) : BitVec (n * 8) :=
have h : n' * 8 + 8 = (n' + 1) * 8 := by simp_arith
BitVec.cast h (rest ++ byte)

def read_bytes' (n : BitVec 64) (addr : BitVec 64) (m : Memory) : BitVec (n.toNat * 8) :=
read_bytes n.toNat addr m

@[memory_rules]
theorem State.read_mem_bytes_eq_mem_read_bytes (s : ArmState) :
read_mem_bytes n addr s = s.mem.read_bytes n addr := by
Expand Down Expand Up @@ -967,6 +970,10 @@ def write_bytes (n : Nat) (addr : BitVec 64)
let val_rest := BitVec.zeroExtend (n' * 8) (val >>> 8)
m.write_bytes n' (addr + 1#64) val_rest

def write_bytes' (n : BitVec 64) (addr : BitVec 64)
(val : BitVec (n.toNat * 8)) (m : Memory) : Memory :=
write_bytes n.toNat addr val m

/-- Writing zero bytes does not change memory. -/
@[memory_rules]
theorem write_bytes_zero {m : Memory} : m.write_bytes 0 addr val = m := rfl
Expand Down

0 comments on commit 421619e

Please sign in to comment.