@@ -61,6 +61,7 @@ const gate_subst = new Map([
61
61
[ '$pmux' , 'Mux1Hot' ] ,
62
62
[ '$mem' , 'Memory' ] ,
63
63
[ '$mem_v2' , 'Memory' ] ,
64
+ [ '$lut' , 'Memory' ] ,
64
65
[ '$fsm' , 'FSM' ] ,
65
66
[ '$clock' , 'Clock' ] ,
66
67
[ '$button' , 'Button' ] ,
@@ -1030,6 +1031,24 @@ function yosys_to_digitaljs_mod(name: string, mod: Yosys.Module, portmaps: Portm
1030
1031
}
1031
1032
break ;
1032
1033
}
1034
+ case '$lut ':
1035
+ assert ( cell . connections . A . length == decode_json_number ( cell . parameters . WIDTH ) ) ;
1036
+ assert ( cell . connections . Y . length == 1 ) ;
1037
+ assert ( cell . port_directions . A == 'input' ) ;
1038
+ assert ( cell . port_directions . Y == 'output' ) ;
1039
+ dev . abits = cell . connections . A . length ;
1040
+ dev . bits = cell . connections . Y . length ;
1041
+ dev . rdports = [ { } ] ;
1042
+ dev . wrports = [ ] ;
1043
+ dev . memdata = cell . parameters . LUT . split ( '' ) . reverse ( ) ;
1044
+ assert ( dev . memdata . length == Math . pow ( 2 , dev . abits ) ) ;
1045
+
1046
+ // Rewrite cell connections to be $mem compatible for port mapping
1047
+ cell . connections . RD_ADDR = cell . connections . A ;
1048
+ cell . connections . RD_DATA = cell . connections . Y ;
1049
+ delete cell . connections . A ;
1050
+ delete cell . connections . Y ;
1051
+ break ;
1033
1052
default :
1034
1053
}
1035
1054
if ( dev . type == 'Dff' ) {
@@ -1048,6 +1067,7 @@ function yosys_to_digitaljs_mod(name: string, mod: Yosys.Module, portmaps: Portm
1048
1067
else if ( cell . type == '$pmux' ) connect_pmux ( dname , cell ) ;
1049
1068
else if ( cell . type == '$mem' ) connect_mem ( dname , cell , dev ) ;
1050
1069
else if ( cell . type == '$mem_v2' ) connect_mem ( dname , cell , dev ) ;
1070
+ else if ( cell . type == '$lut' ) connect_mem ( dname , cell , dev ) ;
1051
1071
else throw Error ( 'Invalid cell type: ' + cell . type ) ;
1052
1072
}
1053
1073
// Group bits into nets for complex sources
0 commit comments