@@ -32,38 +32,39 @@ struct QlIoffPass : public Pass {
3232 pool<RTLIL::Cell *> cells_to_replace;
3333 for (auto cell : module ->selected_cells ()) {
3434 if (cell->type .in (ID (dffsre), ID (sdffsre))) {
35+ log_debug (" Checking cell %s.\n " , cell->name .c_str ());
3536 bool e_const = cell->getPort (ID::E).is_fully_ones ();
3637 bool r_const = cell->getPort (ID::R).is_fully_ones ();
3738 bool s_const = cell->getPort (ID::S).is_fully_ones ();
3839
39- if (!(e_const && r_const && s_const))
40+ if (!(e_const && r_const && s_const)) {
41+ log_debug (" not promoting: E, R, or S is used\n " );
4042 continue ;
43+ }
4144
4245 SigSpec d = cell->getPort (ID::D);
43- if (GetSize (d) != 1 ) continue ;
44- SigBit d_sig = modwalker.sigmap (d[0 ]);
45- if (d_sig.is_wire () && d_sig.wire ->port_input ) {
46+ log_assert (GetSize (d) == 1 );
47+ if (modwalker.has_inputs (d)) {
4648 log_debug (" Cell %s is potentially eligible for promotion to input IOFF.\n " , cell->name .c_str ());
4749 // check that d_sig has no other consumers
4850 pool<ModWalker::PortBit> portbits;
49- modwalker.get_consumers (portbits, d_sig );
51+ modwalker.get_consumers (portbits, d );
5052 if (GetSize (portbits) > 1 ) {
51- log_debug (" not promoting: d_sig has other consumers\n " );
53+ log_debug (" not promoting: D has other consumers\n " );
5254 continue ;
5355 }
5456 cells_to_replace.insert (cell);
5557 continue ; // no need to check Q if we already put it on the list
5658 }
5759 SigSpec q = cell->getPort (ID::Q);
58- if (GetSize (q) != 1 ) continue ;
59- SigBit q_sig = modwalker.sigmap (q[0 ]);
60- if (q_sig.is_wire () && q_sig.wire ->port_output ) {
60+ log_assert (GetSize (q) == 1 );
61+ if (modwalker.has_outputs (q)) {
6162 log_debug (" Cell %s is potentially eligible for promotion to output IOFF.\n " , cell->name .c_str ());
6263 // check that q_sig has no other consumers
6364 pool<ModWalker::PortBit> portbits;
64- modwalker.get_consumers (portbits, q_sig );
65+ modwalker.get_consumers (portbits, q );
6566 if (GetSize (portbits) > 0 ) {
66- log_debug (" not promoting: q_sig has other consumers\n " );
67+ log_debug (" not promoting: Q has other consumers\n " );
6768 continue ;
6869 }
6970 cells_to_replace.insert (cell);
0 commit comments