@@ -282,7 +282,7 @@ endmodule\n"
282
282
assert ! ( module. is_ok( ) ) ;
283
283
let module = module. unwrap ( ) ;
284
284
assert_eq ! (
285
- module. to_single_expr ( ) . unwrap( ) . to_string( ) ,
285
+ module. to_single_lut_expr ( ) . unwrap( ) . to_string( ) ,
286
286
"d" . to_string( )
287
287
) ;
288
288
}
@@ -328,7 +328,7 @@ endmodule\n"
328
328
assert ! ( module. is_ok( ) ) ;
329
329
let module = module. unwrap ( ) ;
330
330
assert_eq ! (
331
- module. to_single_expr ( ) . unwrap( ) . to_string( ) ,
331
+ module. to_single_lut_expr ( ) . unwrap( ) . to_string( ) ,
332
332
"(LUT 17361601744336890538 true false b a c d)" . to_string( )
333
333
) ;
334
334
}
@@ -387,7 +387,7 @@ endmodule\n"
387
387
. unwrap ( )
388
388
. with_fname ( "mux_4_1" . to_string ( ) ) ;
389
389
assert ! ( module. get_name( ) == "mux_4_1" ) ;
390
- let expr = module. to_expr ( ) . unwrap ( ) ;
390
+ let expr: RecExpr < LutLang > = module. to_expr ( ) . unwrap ( ) ;
391
391
assert_eq ! (
392
392
expr. to_string( ) ,
393
393
"(LUT 17361601744336890538 s0 s1 b a c d)" . to_string( )
@@ -402,7 +402,7 @@ endmodule\n"
402
402
assert ! ( module. is_ok( ) ) ;
403
403
let module = module. unwrap ( ) ;
404
404
assert_eq ! (
405
- module. to_single_expr ( ) . unwrap( ) . to_string( ) ,
405
+ module. to_single_lut_expr ( ) . unwrap( ) . to_string( ) ,
406
406
"(REG d)" . to_string( )
407
407
) ;
408
408
let output = module. to_string ( ) ;
@@ -456,11 +456,45 @@ endmodule\n"
456
456
assert ! ( module. is_ok( ) ) ;
457
457
let module = module. unwrap ( ) ;
458
458
assert_eq ! (
459
- module. to_single_expr ( ) . unwrap( ) . to_string( ) ,
459
+ module. to_single_lut_expr ( ) . unwrap( ) . to_string( ) ,
460
460
"(AND a b)" . to_string( )
461
461
) ;
462
462
}
463
463
464
+ #[ test]
465
+ fn test_cell_parse ( ) {
466
+ let module = "module my_cell (
467
+ a,
468
+ b,
469
+ c,
470
+ y
471
+ );
472
+ input a;
473
+ wire a;
474
+ input b;
475
+ wire b;
476
+ input c;
477
+ wire c;
478
+ output y;
479
+ wire y;
480
+ AOI21_X1 _0_ (
481
+ .A(a),
482
+ .B1(b),
483
+ .B2(c),
484
+ .Y(y)
485
+ );
486
+ endmodule"
487
+ . to_string ( ) ;
488
+ let ast = sv_parse_wrapper ( & module, None ) . unwrap ( ) ;
489
+ let module = SVModule :: from_ast ( & ast) ;
490
+ assert ! ( module. is_ok( ) ) ;
491
+ let module = module. unwrap ( ) ;
492
+ assert_eq ! (
493
+ module. to_expr:: <CellLang >( ) . unwrap( ) . to_string( ) ,
494
+ "(AOI21_X1 a b c)" . to_string( )
495
+ ) ;
496
+ }
497
+
464
498
#[ test]
465
499
fn test_constant_parse ( ) {
466
500
let module = "module my_gates (
@@ -496,7 +530,7 @@ endmodule\n"
496
530
assert ! ( module. is_ok( ) ) ;
497
531
let module = module. unwrap ( ) ;
498
532
assert_eq ! (
499
- module. to_single_expr ( ) . unwrap( ) . to_string( ) ,
533
+ module. to_single_lut_expr ( ) . unwrap( ) . to_string( ) ,
500
534
"(AND (AND true true) (AND false false))" . to_string( )
501
535
) ;
502
536
}
@@ -531,7 +565,7 @@ endmodule\n"
531
565
assert ! ( module. is_ok( ) ) ;
532
566
let module = module. unwrap ( ) ;
533
567
assert_eq ! (
534
- module. to_single_expr ( ) . unwrap( ) . to_string( ) ,
568
+ module. to_single_lut_expr ( ) . unwrap( ) . to_string( ) ,
535
569
"(NOT (NOT d))" . to_string( )
536
570
) ;
537
571
}
@@ -901,9 +935,10 @@ endmodule\n"
901
935
PrimitiveType :: AOI22 . get_input_list( ) ,
902
936
vec![ "A1" , "A2" , "B1" , "B2" ]
903
937
) ;
938
+ // LUT input list is backwards relative to the IR
904
939
assert_eq ! (
905
940
PrimitiveType :: LUT6 . get_input_list( ) ,
906
- vec![ "I0 " , "I1 " , "I2 " , "I3 " , "I4 " , "I5 " ]
941
+ vec![ "I5 " , "I4 " , "I3 " , "I2 " , "I1 " , "I0 " ]
907
942
) ;
908
943
}
909
944
0 commit comments