@@ -107,6 +107,7 @@ struct WreduceWorker
107
107
log (" Removed cell %s.%s (%s).\n " , log_id (module ), log_id (cell), log_id (cell->type ));
108
108
module ->connect (sig_y, sig_removed);
109
109
module ->remove (cell);
110
+ mi.notify_blackout (module );
110
111
return ;
111
112
}
112
113
@@ -136,8 +137,12 @@ struct WreduceWorker
136
137
cell->setPort (ID::B, new_sig_b);
137
138
cell->setPort (ID::Y, new_sig_y);
138
139
cell->fixup_parameters ();
140
+ mi.notify_connect (cell, ID::A, sig_a, new_sig_a);
141
+ mi.notify_connect (cell, ID::B, sig_b, new_sig_b);
142
+ mi.notify_connect (cell, ID::Y, sig_y, new_sig_y);
139
143
140
144
module ->connect (sig_y.extract (n_kept, n_removed), sig_removed);
145
+ mi.notify_connect (module , SigSig (sig_y.extract (n_kept, n_removed), sig_removed));
141
146
}
142
147
143
148
void run_cell_dff (Cell *cell)
@@ -146,6 +151,8 @@ struct WreduceWorker
146
151
147
152
SigSpec sig_d = mi.sigmap (cell->getPort (ID::D));
148
153
SigSpec sig_q = mi.sigmap (cell->getPort (ID::Q));
154
+ SigSpec sig_d_orig = mi.sigmap (cell->getPort (ID::D));
155
+ SigSpec sig_q_orig = mi.sigmap (cell->getPort (ID::Q));
149
156
bool has_reset = false ;
150
157
Const initval = initvals (sig_q), rst_value;
151
158
@@ -170,6 +177,7 @@ struct WreduceWorker
170
177
if (zero_ext && sig_d[i] == State::S0 && (initval[i] == State::S0 || (!config->keepdc && initval[i] == State::Sx)) &&
171
178
(!has_reset || i >= GetSize (rst_value) || rst_value[i] == State::S0 || (!config->keepdc && rst_value[i] == State::Sx))) {
172
179
module ->connect (sig_q[i], State::S0);
180
+ mi.notify_connect (module , SigSig (sig_q[i], State::S0));
173
181
initvals.remove_init (sig_q[i]);
174
182
sig_d.remove (i);
175
183
sig_q.remove (i);
@@ -179,6 +187,7 @@ struct WreduceWorker
179
187
if (sign_ext && i > 0 && sig_d[i] == sig_d[i-1 ] && initval[i] == initval[i-1 ] && (!config->keepdc || initval[i] != State::Sx) &&
180
188
(!has_reset || i >= GetSize (rst_value) || (rst_value[i] == rst_value[i-1 ] && (!config->keepdc || rst_value[i] != State::Sx)))) {
181
189
module ->connect (sig_q[i], sig_q[i-1 ]);
190
+ mi.notify_connect (module , SigSig (sig_q[i], sig_q[i-1 ]));
182
191
initvals.remove_init (sig_q[i]);
183
192
sig_d.remove (i);
184
193
sig_q.remove (i);
@@ -206,6 +215,7 @@ struct WreduceWorker
206
215
if (GetSize (sig_q) == 0 ) {
207
216
log (" Removed cell %s.%s (%s).\n " , log_id (module ), log_id (cell), log_id (cell->type ));
208
217
module ->remove (cell);
218
+ mi.notify_blackout (module );
209
219
return ;
210
220
}
211
221
@@ -230,11 +240,14 @@ struct WreduceWorker
230
240
cell->setPort (ID::D, sig_d);
231
241
cell->setPort (ID::Q, sig_q);
232
242
cell->fixup_parameters ();
243
+ mi.notify_connect (cell, ID::D, sig_d_orig, sig_d);
244
+ mi.notify_connect (cell, ID::Q, sig_q_orig, sig_q);
233
245
}
234
246
235
247
void run_reduce_inport (Cell *cell, char port, int max_port_size, bool &port_signed, bool &did_something)
236
248
{
237
249
port_signed = cell->getParam (stringf (" \\ %c_SIGNED" , port)).as_bool ();
250
+ SigSpec sig_orig = mi.sigmap (cell->getPort (stringf (" \\ %c" , port)));
238
251
SigSpec sig = mi.sigmap (cell->getPort (stringf (" \\ %c" , port)));
239
252
240
253
if (port == ' B' && cell->type .in (ID ($shl), ID ($shr), ID ($sshl), ID ($sshr)))
@@ -260,6 +273,7 @@ struct WreduceWorker
260
273
log_debug (" Removed top %d bits (of %d) from port %c of cell %s.%s (%s).\n " ,
261
274
bits_removed, GetSize (sig) + bits_removed, port, log_id (module ), log_id (cell), log_id (cell->type ));
262
275
cell->setPort (stringf (" \\ %c" , port), sig);
276
+ mi.notify_connect (cell, stringf (" \\ %c" , port), sig_orig, sig);
263
277
did_something = true ;
264
278
}
265
279
}
@@ -291,6 +305,7 @@ struct WreduceWorker
291
305
return run_cell_dff (cell);
292
306
293
307
SigSpec sig = mi.sigmap (cell->getPort (ID::Y));
308
+ SigSpec sig_orig = mi.sigmap (cell->getPort (ID::Y));
294
309
295
310
if (sig.has_const ())
296
311
return ;
@@ -427,19 +442,22 @@ struct WreduceWorker
427
442
428
443
SigBit padbit = is_signed ? sig[GetSize (sig)-1 ] : State::S0;
429
444
module ->connect (extra_bits, SigSpec (padbit, GetSize (extra_bits)));
445
+ mi.notify_connect (module , SigSig (extra_bits, SigSpec (padbit, GetSize (extra_bits))));
430
446
}
431
447
}
432
448
433
449
if (GetSize (sig) == 0 ) {
434
450
log (" Removed cell %s.%s (%s).\n " , log_id (module ), log_id (cell), log_id (cell->type ));
435
451
module ->remove (cell);
452
+ mi.notify_blackout (module );
436
453
return ;
437
454
}
438
455
439
456
if (bits_removed) {
440
457
log_debug (" Removed top %d bits (of %d) from port Y of cell %s.%s (%s).\n " ,
441
458
bits_removed, GetSize (sig) + bits_removed, log_id (module ), log_id (cell), log_id (cell->type ));
442
459
cell->setPort (ID::Y, sig);
460
+ mi.notify_connect (cell, ID::Y, sig_orig, sig);
443
461
did_something = true ;
444
462
}
445
463
@@ -563,7 +581,7 @@ struct WreduceWorker
563
581
Wire *nw = module ->addWire (module ->uniquify (IdString (w->name .str () + " _wreduce" )), GetSize (w) - unused_top_bits);
564
582
module ->connect (nw, SigSpec (w).extract (0 , GetSize (nw)));
565
583
module ->swap_names (w, nw);
566
- mi.reload_module (); // TODO: SILIMATE: CAN WE SPEED THIS UP?
584
+ mi.notify_blackout ( module );
567
585
}
568
586
}
569
587
};
0 commit comments