File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ use std::{
4
4
} ;
5
5
6
6
use clap:: Parser ;
7
- use lut_synth:: verilog:: { sv_parse_wrapper, SVModule } ;
7
+ use lut_synth:: {
8
+ lut:: verify_expr,
9
+ verilog:: { sv_parse_wrapper, SVModule } ,
10
+ } ;
8
11
/// Parse structural verilog into a LutLang Expression
9
12
#[ derive( Parser , Debug ) ]
10
13
#[ command( version, about, long_about = None ) ]
@@ -62,13 +65,16 @@ fn main() -> std::io::Result<()> {
62
65
. get_exprs ( )
63
66
. map_err ( |s| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , s) ) ?;
64
67
for ( y, expr) in exprs {
68
+ verify_expr ( & expr)
69
+ . map_err ( |s| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , s) ) ?;
65
70
eprintln ! ( "{}: {}" , y, expr) ;
66
71
println ! ( "{}" , expr) ;
67
72
}
68
73
} else {
69
74
let expr = f
70
75
. to_single_expr ( )
71
76
. map_err ( |s| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , s) ) ?;
77
+ verify_expr ( & expr) . map_err ( |s| std:: io:: Error :: new ( std:: io:: ErrorKind :: Other , s) ) ?;
72
78
eprintln ! ( "{:?}" , f. get_outputs( ) ) ;
73
79
println ! ( "{}" , expr) ;
74
80
}
Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ define_language! {
22
22
pub enum LutLang {
23
23
Const ( bool ) ,
24
24
Program ( u64 ) , // The only node type that is not a net
25
- Var ( Symbol ) ,
26
25
"x" = DC ,
26
+ Var ( Symbol ) ,
27
27
"NOR" = Nor ( [ Id ; 2 ] ) ,
28
28
"MUX" = Mux ( [ Id ; 3 ] ) , // s, a, b
29
29
"AND" = And ( [ Id ; 2 ] ) ,
@@ -61,9 +61,10 @@ impl LutLang {
61
61
}
62
62
LutLang :: Var ( f) => match f. as_str ( ) {
63
63
"NOR" | "LUT" | "MUX" | "AND" | "XOR" | "NOT" | "BUS" | "DC" | "x" | "REG"
64
- | "CYCLE" | "ARG" => Err (
65
- "Variable name is already reserved. Check for missing parentheses." . to_string ( ) ,
66
- ) ,
64
+ | "CYCLE" | "ARG" => Err ( format ! (
65
+ "Variable name '{}' is already reserved. Check for missing parentheses." ,
66
+ f. as_str( )
67
+ ) ) ,
67
68
_ => Ok ( ( ) ) ,
68
69
} ,
69
70
_ => Ok ( ( ) ) ,
Original file line number Diff line number Diff line change @@ -524,7 +524,7 @@ impl Applier<lut::LutLang, LutAnalysis> for ShannonCondense {
524
524
}
525
525
let k = operands. len ( ) ;
526
526
assert ! ( k <= 5 ) ;
527
- let new_prog = p << ( 1 << k) | q;
527
+ let new_prog = ( p << ( 1 << k) ) | q;
528
528
let new_prog_id = egraph. add ( lut:: LutLang :: Program ( new_prog) ) ;
529
529
let sel = subst[ self . sel ] ;
530
530
let mut c = Vec :: from ( & [ new_prog_id, sel] ) ;
You can’t perform that action at this time.
0 commit comments