Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Wel15 authored Dec 3, 2024
1 parent 91ced06 commit fec5641
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions crates/core/machine/src/syscall/precompiles/memcpy.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

pub fn memory_copy_32<F: PrimeField32>(
local_chip: &MemoryLocalChip,
src: *const Fr,
dst: *mut Fr
) {

let event = MemoryLocalEvent {
addr: src as u32,
initial_mem_access: MemoryRecord {
shard: current_shard,
timestamp: current_clk,
value: unsafe { *src }
},
final_mem_access: MemoryRecord {
shard: current_shard,
timestamp: current_clk + 1,
value: unsafe { *src }
}
};

local_chip.process_memory_event(event);
}


pub fn memory_copy_64<F: PrimeField32>(
local_chip: &MemoryLocalChip,
src: *const Fr,
dst: *mut Fr
) {

let low_event = MemoryLocalEvent {
addr: src as u32,
initial_mem_access: MemoryRecord {
shard: current_shard,
timestamp: current_clk,
value: unsafe { *src }
},
final_mem_access: MemoryRecord {
shard: current_shard,
timestamp: current_clk + 1,
value: unsafe { *src }
}
};

let high_event = MemoryLocalEvent {
addr: (src as u32) + 4,
initial_mem_access: MemoryRecord {
shard: current_shard,
timestamp: current_clk,
value: unsafe { *src.offset(1) }
},
final_mem_access: MemoryRecord {
shard: current_shard,
timestamp: current_clk + 1,
value: unsafe { *src.offset(1) }
}
};

local_chip.process_memory_event(low_event);
local_chip.process_memory_event(high_event);
}

0 comments on commit fec5641

Please sign in to comment.