Skip to content

Commit fec5641

Browse files
authored
Add files via upload
1 parent 91ced06 commit fec5641

File tree

1 file changed

+62
-0
lines changed
  • crates/core/machine/src/syscall/precompiles

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
pub fn memory_copy_32<F: PrimeField32>(
3+
local_chip: &MemoryLocalChip,
4+
src: *const Fr,
5+
dst: *mut Fr
6+
) {
7+
8+
let event = MemoryLocalEvent {
9+
addr: src as u32,
10+
initial_mem_access: MemoryRecord {
11+
shard: current_shard,
12+
timestamp: current_clk,
13+
value: unsafe { *src }
14+
},
15+
final_mem_access: MemoryRecord {
16+
shard: current_shard,
17+
timestamp: current_clk + 1,
18+
value: unsafe { *src }
19+
}
20+
};
21+
22+
local_chip.process_memory_event(event);
23+
}
24+
25+
26+
pub fn memory_copy_64<F: PrimeField32>(
27+
local_chip: &MemoryLocalChip,
28+
src: *const Fr,
29+
dst: *mut Fr
30+
) {
31+
32+
let low_event = MemoryLocalEvent {
33+
addr: src as u32,
34+
initial_mem_access: MemoryRecord {
35+
shard: current_shard,
36+
timestamp: current_clk,
37+
value: unsafe { *src }
38+
},
39+
final_mem_access: MemoryRecord {
40+
shard: current_shard,
41+
timestamp: current_clk + 1,
42+
value: unsafe { *src }
43+
}
44+
};
45+
46+
let high_event = MemoryLocalEvent {
47+
addr: (src as u32) + 4,
48+
initial_mem_access: MemoryRecord {
49+
shard: current_shard,
50+
timestamp: current_clk,
51+
value: unsafe { *src.offset(1) }
52+
},
53+
final_mem_access: MemoryRecord {
54+
shard: current_shard,
55+
timestamp: current_clk + 1,
56+
value: unsafe { *src.offset(1) }
57+
}
58+
};
59+
60+
local_chip.process_memory_event(low_event);
61+
local_chip.process_memory_event(high_event);
62+
}

0 commit comments

Comments
 (0)