@@ -42,8 +42,9 @@ std::unique_ptr<CellInfo> create_generic_cell(Context *ctx, IdString type, std::
4242 }
4343 new_cell->type = type;
4444 if (type == ctx->id (" GENERIC_SLICE" )) {
45- new_cell->params [ctx->id (" K" )] = std::to_string ( ctx->args .K ) ;
45+ new_cell->params [ctx->id (" K" )] = ctx->args .K ;
4646 new_cell->params [ctx->id (" INIT" )] = 0 ;
47+ new_cell->params [ctx->id (" FF_USED" )] = 0 ;
4748
4849 for (int i = 0 ; i < ctx->args .K ; i++)
4950 add_port (ctx, new_cell.get (), " I[" + std::to_string (i) + " ]" , PORT_IN);
@@ -80,16 +81,25 @@ void lut_to_lc(const Context *ctx, CellInfo *lut, CellInfo *lc, bool no_dff)
8081 }
8182
8283 if (no_dff) {
84+ lc->params [ctx->id (" FF_USED" )] = 0 ;
8385 replace_port (lut, ctx->id (" Q" ), lc, ctx->id (" F" ));
8486 }
8587}
8688
8789void dff_to_lc (const Context *ctx, CellInfo *dff, CellInfo *lc, bool pass_thru_lut)
8890{
91+ lc->params [ctx->id (" FF_USED" )] = 1 ;
8992 replace_port (dff, ctx->id (" CLK" ), lc, ctx->id (" CLK" ));
9093
9194 if (pass_thru_lut) {
92- lc->params [ctx->id (" INIT" )] = 0xAAAA ;
95+ // Fill LUT with alternating 10
96+ const int init_size = 1 << lc->params [ctx->id (" K" )].as_int64 ();
97+ std::string init;
98+ init.reserve (init_size);
99+ for (int i = 0 ; i < init_size; i+=2 )
100+ init.append (" 10" );
101+ lc->params [ctx->id (" INIT" )] = Property::from_string (init);
102+
93103 replace_port (dff, ctx->id (" D" ), lc, ctx->id (" I[0]" ));
94104 }
95105
0 commit comments