159 std::map<patterns_t, std::set<int>> grouped_patterns;
160 std::set<int> remaining_indices;
162 for (
int i = 0 ; i <
GetSize(sig_d); i++) {
164 if (!patterns.empty()) {
166 grouped_patterns[patterns].insert(i);
168 remaining_indices.insert(i);
171 for (
auto &it : grouped_patterns) {
173 for (
int i : it.second) {
174 new_sig_d.
append(sig_d[i]);
175 new_sig_q.
append(sig_q[i]);
178 new_sig_d, new_sig_q, dff_cell->
getParam(
"\\CLK_POLARITY").
as_bool(),
true);
182 if (remaining_indices.empty()) {
183 log(
" removing now obsolete cell %s.\n",
log_id(dff_cell));
186 log(
" removing %d now obsolete bits from cell %s.\n",
GetSize(sig_d) -
GetSize(remaining_indices),
log_id(dff_cell));
188 for (
int i : remaining_indices) {
189 new_sig_d.
append(sig_d[i]);
190 new_sig_q.
append(sig_q[i]);
192 dff_cell->
setPort(
"\\D", new_sig_d);
193 dff_cell->
setPort(
"\\Q", new_sig_q);
void setParam(RTLIL::IdString paramname, RTLIL::Const value)
void simplify_patterns(patterns_t &)
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal)
std::map< RTLIL::SigBit, bool > pattern_t
std::set< pattern_t > patterns_t
const RTLIL::SigSpec & getPort(RTLIL::IdString portname) const
int GetSize(RTLIL::Wire *wire)
patterns_t find_muxtree_feedback_patterns(RTLIL::SigBit d, RTLIL::SigBit q, pattern_t path)
void remove(const std::set< RTLIL::Wire * > &wires)
void log(const char *format,...)
const RTLIL::Const & getParam(RTLIL::IdString paramname) const
void append(const RTLIL::SigSpec &signal)
RTLIL::SigSpec make_patterns_logic(patterns_t patterns)
RTLIL::Cell * addDffe(RTLIL::IdString name, RTLIL::SigSpec sig_clk, RTLIL::SigSpec sig_en, RTLIL::SigSpec sig_d, RTLIL::SigSpec sig_q, bool clk_polarity=true, bool en_polarity=true)
const char * log_id(RTLIL::IdString str)