@@ -311,11 +311,11 @@ impl<F: FieldElement> SubmachineTrace<F> {
311311}
312312
313313pub struct BinaryMachine ;
314- witness_cols ! { BinaryCols , A_byte , B_byte , C_byte , A , B , C , operation_id, operation_id_next }
314+ witness_cols ! { BinaryCols , A_byte0 , A_byte1 , A_byte2 , A_byte3 , B_byte0 , B_byte1 , B_byte2 , B_byte3 , C_byte0 , C_byte1 , C_byte2 , C_byte3 , A , B , C , operation_id}
315315
316316impl SubmachineKind for BinaryMachine {
317317 const SELECTORS : & ' static str = "sel" ;
318- const BLOCK_SIZE : u32 = 4 ;
318+ const BLOCK_SIZE : u32 = 1 ;
319319
320320 fn cols ( ) -> Vec < String > {
321321 BinaryCols :: all ( )
@@ -346,82 +346,24 @@ impl SubmachineKind for BinaryMachine {
346346 let ( c1, c2, c3, c4, _sign) =
347347 decompose_lower32 ( c. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) . into ( ) ) ;
348348
349- // set last row of the previous block
350- if trace. len ( ) > 0 {
351- trace. set_current_row ( BinaryCols :: A_byte as usize , ( a1 as u32 ) . into ( ) ) ;
352- trace. set_current_row ( BinaryCols :: B_byte as usize , ( b1 as u32 ) . into ( ) ) ;
353- trace. set_current_row ( BinaryCols :: C_byte as usize , ( c1 as u32 ) . into ( ) ) ;
354- trace. set_current_row ( BinaryCols :: operation_id_next as usize , op_id) ;
355- } else {
356- trace. set_final_row ( BinaryCols :: A_byte as usize , ( a1 as u32 ) . into ( ) ) ;
357- trace. set_final_row ( BinaryCols :: B_byte as usize , ( b1 as u32 ) . into ( ) ) ;
358- trace. set_final_row ( BinaryCols :: C_byte as usize , ( c1 as u32 ) . into ( ) ) ;
359- trace. set_final_row ( BinaryCols :: operation_id_next as usize , op_id) ;
360- }
361-
362- // 4 rows for each binary operation
349+ // 1 row for each binary operation
363350 trace. push_row ( ) ;
364- trace. set_current_row ( BinaryCols :: operation_id as usize , op_id) ;
365- trace. set_current_row ( BinaryCols :: operation_id_next as usize , op_id) ;
366- trace. set_current_row ( BinaryCols :: A_byte as usize , ( a2 as u32 ) . into ( ) ) ;
367- trace. set_current_row ( BinaryCols :: B_byte as usize , ( b2 as u32 ) . into ( ) ) ;
368- trace. set_current_row ( BinaryCols :: C_byte as usize , ( c2 as u32 ) . into ( ) ) ;
369- trace. set_current_row (
370- BinaryCols :: A as usize ,
371- ( a. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xff ) . into ( ) ,
372- ) ;
373- trace. set_current_row (
374- BinaryCols :: B as usize ,
375- ( b. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xff ) . into ( ) ,
376- ) ;
377- trace. set_current_row (
378- BinaryCols :: C as usize ,
379- ( c. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xff ) . into ( ) ,
380- ) ;
381-
382- trace. push_row ( ) ;
383- trace. set_current_row ( BinaryCols :: operation_id as usize , op_id) ;
384- trace. set_current_row ( BinaryCols :: operation_id_next as usize , op_id) ;
385- trace. set_current_row ( BinaryCols :: A_byte as usize , ( a3 as u32 ) . into ( ) ) ;
386- trace. set_current_row ( BinaryCols :: B_byte as usize , ( b3 as u32 ) . into ( ) ) ;
387- trace. set_current_row ( BinaryCols :: C_byte as usize , ( c3 as u32 ) . into ( ) ) ;
388- trace. set_current_row (
389- BinaryCols :: A as usize ,
390- ( a. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xffff ) . into ( ) ,
391- ) ;
392- trace. set_current_row (
393- BinaryCols :: B as usize ,
394- ( b. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xffff ) . into ( ) ,
395- ) ;
396- trace. set_current_row (
397- BinaryCols :: C as usize ,
398- ( c. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xffff ) . into ( ) ,
399- ) ;
400-
401- trace. push_row ( ) ;
402- trace. set_current_row ( BinaryCols :: operation_id as usize , op_id) ;
403- trace. set_current_row ( BinaryCols :: operation_id_next as usize , op_id) ;
404- trace. set_current_row ( BinaryCols :: A_byte as usize , ( a4 as u32 ) . into ( ) ) ;
405- trace. set_current_row ( BinaryCols :: B_byte as usize , ( b4 as u32 ) . into ( ) ) ;
406- trace. set_current_row ( BinaryCols :: C_byte as usize , ( c4 as u32 ) . into ( ) ) ;
407- trace. set_current_row (
408- BinaryCols :: A as usize ,
409- ( a. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xffffff ) . into ( ) ,
410- ) ;
411- trace. set_current_row (
412- BinaryCols :: B as usize ,
413- ( b. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xffffff ) . into ( ) ,
414- ) ;
415- trace. set_current_row (
416- BinaryCols :: C as usize ,
417- ( c. to_integer ( ) . try_into_u32 ( ) . unwrap ( ) & 0xffffff ) . into ( ) ,
418- ) ;
419-
420- trace. push_row ( ) ;
421- trace. set_current_row ( BinaryCols :: operation_id as usize , op_id) ;
351+ trace. set_current_row ( BinaryCols :: A_byte0 as usize , ( a1 as u32 ) . into ( ) ) ;
352+ trace. set_current_row ( BinaryCols :: A_byte1 as usize , ( a2 as u32 ) . into ( ) ) ;
353+ trace. set_current_row ( BinaryCols :: A_byte2 as usize , ( a3 as u32 ) . into ( ) ) ;
354+ trace. set_current_row ( BinaryCols :: A_byte3 as usize , ( a4 as u32 ) . into ( ) ) ;
355+ trace. set_current_row ( BinaryCols :: B_byte0 as usize , ( b1 as u32 ) . into ( ) ) ;
356+ trace. set_current_row ( BinaryCols :: B_byte1 as usize , ( b2 as u32 ) . into ( ) ) ;
357+ trace. set_current_row ( BinaryCols :: B_byte2 as usize , ( b3 as u32 ) . into ( ) ) ;
358+ trace. set_current_row ( BinaryCols :: B_byte3 as usize , ( b4 as u32 ) . into ( ) ) ;
359+ trace. set_current_row ( BinaryCols :: C_byte0 as usize , ( c1 as u32 ) . into ( ) ) ;
360+ trace. set_current_row ( BinaryCols :: C_byte1 as usize , ( c2 as u32 ) . into ( ) ) ;
361+ trace. set_current_row ( BinaryCols :: C_byte2 as usize , ( c3 as u32 ) . into ( ) ) ;
362+ trace. set_current_row ( BinaryCols :: C_byte3 as usize , ( c4 as u32 ) . into ( ) ) ;
422363 trace. set_current_row ( BinaryCols :: A as usize , a) ;
423364 trace. set_current_row ( BinaryCols :: B as usize , b) ;
424365 trace. set_current_row ( BinaryCols :: C as usize , c) ;
366+ trace. set_current_row ( BinaryCols :: operation_id as usize , op_id) ;
425367 // latch row: set selector
426368 trace. set_current_row_selector ( selector, 1 . into ( ) ) ;
427369 }
0 commit comments