@@ -42,8 +42,9 @@ std::unique_ptr<CellInfo> create_generic_cell(Context *ctx, IdString type, std::
42
42
}
43
43
new_cell->type = type;
44
44
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 ;
46
46
new_cell->params [ctx->id (" INIT" )] = 0 ;
47
+ new_cell->params [ctx->id (" FF_USED" )] = 0 ;
47
48
48
49
for (int i = 0 ; i < ctx->args .K ; i++)
49
50
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)
80
81
}
81
82
82
83
if (no_dff) {
84
+ lc->params [ctx->id (" FF_USED" )] = 0 ;
83
85
replace_port (lut, ctx->id (" Q" ), lc, ctx->id (" F" ));
84
86
}
85
87
}
86
88
87
89
void dff_to_lc (const Context *ctx, CellInfo *dff, CellInfo *lc, bool pass_thru_lut)
88
90
{
91
+ lc->params [ctx->id (" FF_USED" )] = 1 ;
89
92
replace_port (dff, ctx->id (" CLK" ), lc, ctx->id (" CLK" ));
90
93
91
94
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
+
93
103
replace_port (dff, ctx->id (" D" ), lc, ctx->id (" I[0]" ));
94
104
}
95
105
0 commit comments