@@ -144,6 +144,12 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
144
144
let prev_len = prev. len [ 0 ]
145
145
+ prev. len [ 1 ] * AB :: Expr :: from_canonical_u32 ( 1 << ( 2 * MEMCPY_LOOP_LIMB_BITS ) ) ;
146
146
147
+ // write_data =
148
+ // (local.data_1[shift..4], prev.data_4[0..shift]),
149
+ // (local.data_2[shift..4], local.data_1[0..shift]),
150
+ // (local.data_3[shift..4], local.data_2[0..shift]),
151
+ // (local.data_4[shift..4], local.data_3[0..shift])
152
+ // local.data-1 = tracing_read data
147
153
let write_data_pairs = [
148
154
( prev. data_4 , local. data_1 ) ,
149
155
( local. data_1 , local. data_2 ) ,
@@ -302,15 +308,11 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
302
308
// Read data from memory
303
309
let read_data = [ local. data_1 , local. data_2 , local. data_3 , local. data_4 ] ;
304
310
305
- // eprintln!(
306
- // "starting timestamp: {:?}",
307
- // timestamp * AB::Expr::from_canonical_u32(1)
308
- // );
309
311
read_data. iter ( ) . enumerate ( ) . for_each ( |( idx, data) | {
310
312
// is valid read of entire 16 block chunk?
311
313
let is_valid_read = if idx == 3 {
312
314
// will always be a valid read
313
- AB :: Expr :: ONE * ( local. is_valid )
315
+ AB :: Expr :: ONE * ( local. is_shift_non_zero_or_not_start )
314
316
} else {
315
317
// if idx < 3, its not an entire block read, if its the first block
316
318
AB :: Expr :: ONE * ( local. is_valid_not_start )
@@ -326,14 +328,12 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
326
328
& local. read_aux [ idx] ,
327
329
)
328
330
. eval ( builder, is_valid_read. clone ( ) ) ;
329
- // eprintln!(
330
- // "local.source: {:?}, data: {:?}, local.source - AB::Expr::from_canonical_usize(16 - idx * 4): {:?}, timestamp_pp: {:?}, is_valid_read: {:?}",
331
- // local.source * AB::Expr::from_canonical_u32(1),
332
- // data.clone().map(|x| x * (AB::Expr::from_canonical_u32(1))),
333
- // local.source - AB::Expr::from_canonical_usize(16 - idx * 4) * AB::Expr::from_canonical_u32(1),
334
- // timestamp_pp(AB::Expr::ZERO),
335
- // is_valid_read.clone()
336
- // );
331
+ eprintln ! (
332
+ "local.source: {:?}, data: {:?}, local.source - AB::Expr::from_canonical_usize(16 - idx * 4): {:?}" ,
333
+ local. source * AB :: Expr :: from_canonical_u32( 1 ) ,
334
+ data. clone( ) . map( |x| x * ( AB :: Expr :: from_canonical_u32( 1 ) ) ) ,
335
+ local. source - AB :: Expr :: from_canonical_usize( 16 - idx * 4 ) * AB :: Expr :: from_canonical_u32( 1 )
336
+ ) ;
337
337
} ) ;
338
338
339
339
write_data. iter ( ) . enumerate ( ) . for_each ( |( idx, data) | {
@@ -379,7 +379,63 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
379
379
// error seems to be off by one for timestamp again, or off by 17 or 21??
380
380
// timestamps are inconsistent everywhere...
381
381
382
- // is timestamping off, is it pointer is off, for small source values
382
+ /*
383
+ heres the plan:
384
+ identify everywhere where timeststamps are used; where theyre written to (tracing_read) etc.
385
+ walk through each component, and take notes about how timestamp is incrementing in each portion
386
+ */
387
+
388
+ /*
389
+ off by one:
390
+ between memcpyiter Air and itself
391
+
392
+ off by 16:
393
+ memcpyiter air and itself
394
+ off by 17:
395
+ between memoryDummyAir and accessAdapterAir
396
+
397
+ off by 21:
398
+ memcpyiterAir and itself
399
+ memory dummy and access adapter air
400
+
401
+ bruh, seems that everything is wrong... WHATS WRONG WITH THE TIMESTAMPS MAN
402
+ */
403
+
404
+ // eprintln!(
405
+ // "memory bridge data write_data: {:?}",
406
+ // write_data
407
+ // .iter()
408
+ // .map(|x| x.clone().map(|y| y * (AB::Expr::from_canonical_u32(1))))
409
+ // .collect::<Vec<_>>()
410
+ // );
411
+ // Write final data to registers
412
+ // write_data_pairs.iter().for_each(|(prev_data, next_data)| {
413
+ // eprintln!(
414
+ // "prev_data: {:?}, next_data: {:?}",
415
+ // prev_data.map(|x| x * (AB::Expr::from_canonical_u32(1))),
416
+ // next_data.map(|x| x * (AB::Expr::from_canonical_u32(1))),
417
+ // );
418
+ // });
419
+
420
+ // is timestamping off, is it pointer is off?
421
+ write_data. iter ( ) . enumerate ( ) . for_each ( |( idx, data) | {
422
+ self . memory_bridge
423
+ . write (
424
+ MemoryAddress :: new (
425
+ AB :: Expr :: from_canonical_u32 ( RV32_MEMORY_AS ) ,
426
+ local. dest - AB :: Expr :: from_canonical_usize ( 16 - idx * 4 ) ,
427
+ ) ,
428
+ data. clone ( ) ,
429
+ timestamp_pp ( AB :: Expr :: ONE * ( local. is_valid_not_start ) ) ,
430
+ & local. write_aux [ idx] ,
431
+ )
432
+ . eval ( builder, local. is_valid_not_start ) ;
433
+ // eprintln!(
434
+ // "Eval: write_data: {:?}, timestamp_pp: {:?}",
435
+ // data.clone().map(|x| x * (AB::Expr::from_canonical_u32(1))),
436
+ // timestamp_pp(AB::Expr::ZERO * (local.is_valid_not_start))
437
+ // );
438
+ } ) ;
383
439
384
440
// Range check len
385
441
let len_bits_limit = [
@@ -595,25 +651,25 @@ where
595
651
// we have saturating sub, which isnt a perfect sub,
596
652
// 0, 4, 20
597
653
// source is tOO SMALL, SO READING SAME DATA TWICE??
598
-
599
- record. var [ 0 ] . data [ 3 ] = tracing_read (
600
- state. memory ,
601
- RV32_MEMORY_AS ,
602
- source - 4 * ( source >= 4 ) as u32 ,
603
- & mut record. var [ 0 ] . read_aux [ 3 ] . prev_timestamp ,
604
- ) ;
605
- if source < 4 {
606
- eprintln ! ( "preflight shift: {:?}" , shift) ;
607
- eprintln ! ( "preflight, before saturating sub source: {:?}" , source) ;
608
- eprintln ! ( "preflight, after saturating sub source: {:?}" , source) ;
609
- }
610
- if record. var [ 0 ] . read_aux [ 3 ] . prev_timestamp == 0 {
611
- eprintln ! (
612
- "preflight, record.var[0].read_aux[3].prev_timestamp: {:?}" ,
613
- record. var[ 0 ] . read_aux[ 3 ] . prev_timestamp
654
+ if shift != 0 {
655
+ record. var [ 0 ] . data [ 3 ] = tracing_read (
656
+ state. memory ,
657
+ RV32_MEMORY_AS ,
658
+ source - 4 * ( source >= 4 ) as u32 ,
659
+ & mut record. var [ 0 ] . read_aux [ 3 ] . prev_timestamp ,
660
+ ) ;
661
+ } else {
662
+ record. var [ 0 ] . data [ 3 ] = tracing_read (
663
+ state. memory ,
664
+ RV32_MEMORY_AS ,
665
+ source - 4 * ( source >= 4 ) as u32 , // what happens when we read same memory twice? is it bc not constraining properly? since its the same piece of memory; this error will still happen, if source < 4? since no "previous" word
666
+ & mut record. var [ 0 ] . read_aux [ 3 ] . prev_timestamp ,
614
667
) ;
615
- eprintln ! ( "source: {:?}, dest: {:?}, shift: {:?}" , source, dest, shift) ;
616
668
}
669
+ eprintln ! (
670
+ "record.var[0].read_aux[3].prev_timestamp: {:?}" ,
671
+ record. var[ 0 ] . read_aux[ 3 ] . prev_timestamp
672
+ ) ;
617
673
618
674
// Fill record.var for the rest of the rows of iteration trace
619
675
let mut idx = 1 ;
0 commit comments