39 std::set<RTLIL::Cell*, RTLIL::sort_by_name_id<RTLIL::Cell>>
merged_set;
40 std::set<RTLIL::Cell*, RTLIL::sort_by_name_id<RTLIL::Cell>>
current_set;
48 if (cell->
type ==
"$mux" || cell->
type ==
"$pmux")
68 if (new_signals.
size() > 3)
79 if (new_signals.
size() > 2)
87 std::vector<RTLIL::Cell*> cell_list;
90 cell_list.push_back(c);
93 cell_list.push_back(c);
96 for (
auto c : cell_list)
100 for (
auto &p : c->connections()) {
101 if (p.first !=
"\\A" && p.first !=
"\\B" && p.first !=
"\\S" && p.first !=
"\\Y")
121 log(
" grown transition table to %d entries -> optimize.\n", trans_num);
126 log(
" transition table size after optimizaton: %d\n", trans_num);
149 std::vector<RTLIL::Const> truth_tab;
151 for (
int i = 0; i < (1 << input_sig.
size()); i++) {
166 truth_tab.push_back(
ct.
eval(cell, A.as_const(), B.as_const(), S.as_const()));
174 new_ctrl_in.
append(input_sig);
179 new_ctrl_out.
append(output_sig);
182 std::vector<FsmData::transition_t> new_transition_table;
184 for (
int i = 0; i < (1 << input_sig.
size()); i++) {
194 new_transition_table.push_back(new_tr);
198 new_transition_table.clear();
242 log(
" merged %d cells into FSM.\n",
GetSize(merged_set));
252 log(
" fsm_expand [selection]\n");
254 log(
"The fsm_extract pass is conservative about the cells that belong to a finite\n");
255 log(
"state machine. This pass can be used to merge additional auxiliary gates into\n");
256 log(
"the finate state machine.\n");
261 log_header(
"Executing FSM_EXPAND pass (merging auxiliary logic into FSMs).\n");
264 for (
auto &mod_it : design->
modules_) {
265 if (!design->
selected(mod_it.second))
267 std::vector<RTLIL::Cell*> fsm_cells;
268 for (
auto &cell_it : mod_it.second->cells_)
269 if (cell_it.second->type ==
"$fsm" && design->
selected(mod_it.second, cell_it.second))
270 fsm_cells.push_back(cell_it.second);
271 for (
auto c : fsm_cells) {
272 FsmExpand fsm_expand(c, design, mod_it.second);
const char * c_str() const
bool selected(T1 *module) const
std::vector< transition_t > transition_table
void merge_cell_into_fsm(RTLIL::Cell *cell)
FsmExpandPass FsmExpandPass
void log_header(const char *format,...)
RTLIL::Const as_const() const
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal)
void copy_to_cell(RTLIL::Cell *cell)
std::map< RTLIL::IdString, RTLIL::Const > parameters
void remove(const RTLIL::SigSpec &pattern)
void create_current_set()
std::set< RTLIL::Cell *, RTLIL::sort_by_name_id< RTLIL::Cell > > no_candidate_set
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
static void optimize_fsm(RTLIL::Cell *cell, RTLIL::Module *module)
SigSet< RTLIL::Cell *, RTLIL::sort_by_name_id< RTLIL::Cell > > sig2user
void set(RTLIL::Module *module)
bool cell_known(RTLIL::IdString type)
SigSet< RTLIL::Cell *, RTLIL::sort_by_name_id< RTLIL::Cell > > sig2driver
#define PRIVATE_NAMESPACE_BEGIN
RTLIL_ATTRIBUTE_MEMBERS bool hasPort(RTLIL::IdString portname) const
bool cell_output(RTLIL::IdString type, RTLIL::IdString port)
const RTLIL::SigSpec & getPort(RTLIL::IdString portname) const
bool is_cell_merge_candidate(RTLIL::Cell *cell)
int GetSize(RTLIL::Wire *wire)
static RTLIL::Const eval(RTLIL::IdString type, const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
#define log_assert(_assert_expr_)
#define PRIVATE_NAMESPACE_END
#define USING_YOSYS_NAMESPACE
std::map< RTLIL::IdString, RTLIL::Module * > modules_
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
void remove(const std::set< RTLIL::Wire * > &wires)
void log(const char *format,...)
std::set< RTLIL::Cell *, RTLIL::sort_by_name_id< RTLIL::Cell > > current_set
void copy_from_cell(RTLIL::Cell *cell)
void append(const RTLIL::SigSpec &signal)
std::set< RTLIL::Cell *, RTLIL::sort_by_name_id< RTLIL::Cell > > merged_set
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
FsmExpand(RTLIL::Cell *cell, RTLIL::Design *design, RTLIL::Module *mod)
const std::map< RTLIL::IdString, RTLIL::SigSpec > & connections() const
void find(RTLIL::SigSpec sig, std::set< T > &result)
void insert(RTLIL::SigSpec sig, T data)