@@ -61,6 +61,7 @@ const gate_subst = new Map([
6161 [ '$pmux' , 'Mux1Hot' ] ,
6262 [ '$mem' , 'Memory' ] ,
6363 [ '$mem_v2' , 'Memory' ] ,
64+ [ '$lut' , 'Memory' ] ,
6465 [ '$fsm' , 'FSM' ] ,
6566 [ '$clock' , 'Clock' ] ,
6667 [ '$button' , 'Button' ] ,
@@ -1030,6 +1031,24 @@ function yosys_to_digitaljs_mod(name: string, mod: Yosys.Module, portmaps: Portm
10301031 }
10311032 break ;
10321033 }
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 ;
10331052 default :
10341053 }
10351054 if ( dev . type == 'Dff' ) {
@@ -1048,6 +1067,7 @@ function yosys_to_digitaljs_mod(name: string, mod: Yosys.Module, portmaps: Portm
10481067 else if ( cell . type == '$pmux' ) connect_pmux ( dname , cell ) ;
10491068 else if ( cell . type == '$mem' ) connect_mem ( dname , cell , dev ) ;
10501069 else if ( cell . type == '$mem_v2' ) connect_mem ( dname , cell , dev ) ;
1070+ else if ( cell . type == '$lut' ) connect_mem ( dname , cell , dev ) ;
10511071 else throw Error ( 'Invalid cell type: ' + cell . type ) ;
10521072 }
10531073 // Group bits into nets for complex sources
0 commit comments