@@ -144,12 +144,6 @@ 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
153
147
let write_data_pairs = [
154
148
( prev. data_4 , local. data_1 ) ,
155
149
( local. data_1 , local. data_2 ) ,
@@ -308,11 +302,15 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
308
302
// Read data from memory
309
303
let read_data = [ local. data_1 , local. data_2 , local. data_3 , local. data_4 ] ;
310
304
305
+ eprintln ! (
306
+ "starting timestamp: {:?}" ,
307
+ timestamp * AB :: Expr :: from_canonical_u32( 1 )
308
+ ) ;
311
309
read_data. iter ( ) . enumerate ( ) . for_each ( |( idx, data) | {
312
310
// is valid read of entire 16 block chunk?
313
311
let is_valid_read = if idx == 3 {
314
312
// will always be a valid read
315
- AB :: Expr :: ONE * ( local. is_shift_non_zero_or_not_start )
313
+ AB :: Expr :: ONE * ( local. is_valid )
316
314
} else {
317
315
// if idx < 3, its not an entire block read, if its the first block
318
316
AB :: Expr :: ONE * ( local. is_valid_not_start )
@@ -329,10 +327,12 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
329
327
)
330
328
. eval ( builder, is_valid_read. clone ( ) ) ;
331
329
eprintln ! (
332
- "local.source: {:?}, data: {:?}, local.source - AB::Expr::from_canonical_usize(16 - idx * 4): {:?}" ,
330
+ "local.source: {:?}, data: {:?}, local.source - AB::Expr::from_canonical_usize(16 - idx * 4): {:?}, timestamp_pp: {:?}, is_valid_read: {:?} " ,
333
331
local. source * AB :: Expr :: from_canonical_u32( 1 ) ,
334
332
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 )
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
336
) ;
337
337
} ) ;
338
338
/*
@@ -359,45 +359,7 @@ impl<AB: InteractionBuilder> Air<AB> for MemcpyIterAir {
359
359
// error seems to be off by one for timestamp again, or off by 17 or 21??
360
360
// timestamps are inconsistent everywhere...
361
361
362
- /*
363
- heres the plan:
364
- identify everywhere where timeststamps are used; where theyre written to (tracing_read) etc.
365
- walk through each component, and take notes about how timestamp is incrementing in each portion
366
- */
367
-
368
- /*
369
- off by one:
370
- between memcpyiter Air and itself
371
-
372
- off by 16:
373
- memcpyiter air and itself
374
- off by 17:
375
- between memoryDummyAir and accessAdapterAir
376
-
377
- off by 21:
378
- memcpyiterAir and itself
379
- memory dummy and access adapter air
380
-
381
- bruh, seems that everything is wrong... WHATS WRONG WITH THE TIMESTAMPS MAN
382
- */
383
-
384
- // eprintln!(
385
- // "memory bridge data write_data: {:?}",
386
- // write_data
387
- // .iter()
388
- // .map(|x| x.clone().map(|y| y * (AB::Expr::from_canonical_u32(1))))
389
- // .collect::<Vec<_>>()
390
- // );
391
- // Write final data to registers
392
- // write_data_pairs.iter().for_each(|(prev_data, next_data)| {
393
- // eprintln!(
394
- // "prev_data: {:?}, next_data: {:?}",
395
- // prev_data.map(|x| x * (AB::Expr::from_canonical_u32(1))),
396
- // next_data.map(|x| x * (AB::Expr::from_canonical_u32(1))),
397
- // );
398
- // });
399
-
400
- // is timestamping off, is it pointer is off?
362
+ // is timestamping off, is it pointer is off, for small source values
401
363
write_data. iter ( ) . enumerate ( ) . for_each ( |( idx, data) | {
402
364
self . memory_bridge
403
365
. write (
@@ -609,6 +571,7 @@ where
609
571
record. inner . shift = shift;
610
572
record. inner . from_pc = * state. pc ;
611
573
record. inner . from_timestamp = state. memory . timestamp ;
574
+ eprintln ! ( "state.memory.timestamp: {:?}" , state. memory. timestamp) ;
612
575
record. inner . dest = dest;
613
576
record. inner . source = source;
614
577
record. inner . len = len;
@@ -631,24 +594,17 @@ where
631
594
// we have saturating sub, which isnt a perfect sub,
632
595
// 0, 4, 20
633
596
// source is tOO SMALL, SO READING SAME DATA TWICE??
634
- if shift != 0 {
635
- record. var [ 0 ] . data [ 3 ] = tracing_read (
636
- state. memory ,
637
- RV32_MEMORY_AS ,
638
- source - 4 * ( source >= 4 ) as u32 ,
639
- & mut record. var [ 0 ] . read_aux [ 3 ] . prev_timestamp ,
640
- ) ;
641
- } else {
642
- record. var [ 0 ] . data [ 3 ] = tracing_read (
643
- state. memory ,
644
- RV32_MEMORY_AS ,
645
- 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
646
- & mut record. var [ 0 ] . read_aux [ 3 ] . prev_timestamp ,
647
- ) ;
648
- }
597
+
598
+ record. var [ 0 ] . data [ 3 ] = tracing_read (
599
+ state. memory ,
600
+ RV32_MEMORY_AS ,
601
+ source - 4 * ( source >= 4 ) as u32 ,
602
+ & mut record. var [ 0 ] . read_aux [ 3 ] . prev_timestamp ,
603
+ ) ;
604
+
649
605
eprintln ! (
650
- "record.var[0].read_aux[3].prev_timestamp: {:?}" ,
651
- record. var[ 0 ] . read_aux[ 3 ] . prev_timestamp
606
+ "record.var[0].read_aux[3].prev_timestamp: {:?}, record.var[0].data[3]: {:?} " ,
607
+ record. var[ 0 ] . read_aux[ 3 ] . prev_timestamp, record . var [ 0 ] . data [ 3 ]
652
608
) ;
653
609
654
610
// Fill record.var for the rest of the rows of iteration trace
0 commit comments