39 if (sig_at_port.
check_any(assign_map(sig)))
46 log_warning(
"logic loop in mux tree at signal %s in module %s.\n",
51 recursion_monitor.
add(sig);
53 std::set<sig2driver_entry_t> cellport_list;
54 sig2driver.
find(sig, cellport_list);
55 for (
auto &cellport : cellport_list) {
56 if ((cellport.first->type !=
"$mux" && cellport.first->type !=
"$pmux") || cellport.second !=
"\\Y")
62 for (
int i = 0; i < sig_b.size(); i += sig_a.
size())
68 recursion_monitor.
del(sig);
75 if (sig_at_port.
check_any(assign_map(sig)))
78 std::set<sig2driver_entry_t> cellport_list;
79 sig2user.
find(sig, cellport_list);
80 for (
auto &cellport : cellport_list) {
84 if (cellport.second !=
"\\A" && cellport.second !=
"\\B")
89 if (port_it.first !=
"\\A" && port_it.first !=
"\\B" && port_it.first !=
"\\Y")
103 if (wire->attributes.count(
"\\fsm_encoding") > 0 || wire->
width <= 1)
108 std::set<sig2driver_entry_t> cellport_list;
110 for (
auto &cellport : cellport_list) {
111 if ((cellport.first->type !=
"$dff" && cellport.first->type !=
"$adff") || cellport.second !=
"\\Q")
119 wire->attributes[
"\\fsm_encoding"] =
RTLIL::Const(
"auto");
131 log(
" fsm_detect [selection]\n");
133 log(
"This pass detects finite state machines by identifying the state signal.\n");
134 log(
"The state signal is then marked by setting the attribute 'fsm_encoding'\n");
135 log(
"on the state signal to \"auto\".\n");
137 log(
"Existing 'fsm_encoding' attributes are not changed by this pass.\n");
139 log(
"Signals can be protected from being detected by this pass by setting the\n");
140 log(
"'fsm_encoding' attribute to \"none\".\n");
145 log_header(
"Executing FSM_DETECT pass (finding FSMs in design).\n");
154 for (
auto &mod_it : design->
modules_)
156 if (!design->
selected(mod_it.second))
159 module = mod_it.second;
160 assign_map.
set(module);
165 for (
auto &cell_it : module->
cells_)
166 for (
auto &conn_it : cell_it.second->connections()) {
169 assign_map.
apply(sig);
172 if (!ct.
cell_known(cell_it.second->type) || ct.
cell_input(cell_it.second->type, conn_it.first)) {
174 assign_map.
apply(sig);
179 for (
auto &wire_it : module->
wires_)
180 if (wire_it.second->port_id != 0)
183 for (
auto &wire_it : module->
wires_)
184 if (design->
selected(module, wire_it.second))
const char * c_str() const
FsmDetectPass FsmDetectPass
bool selected(T1 *module) const
void log_warning(const char *format,...)
void setup_internals_mem()
void log_header(const char *format,...)
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
static SigPool sig_at_port
std::pair< RTLIL::Cell *, RTLIL::IdString > sig2driver_entry_t
void apply(RTLIL::SigBit &bit) const
static bool check_state_users(RTLIL::SigSpec sig)
void set(RTLIL::Module *module)
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
bool cell_known(RTLIL::IdString type)
bool check_any(RTLIL::SigSpec sig)
#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_fully_const() const
static void detect_fsm(RTLIL::Wire *wire)
#define PRIVATE_NAMESPACE_END
static const char * id2cstr(const RTLIL::IdString &str)
void add(RTLIL::SigSpec sig)
#define USING_YOSYS_NAMESPACE
std::map< RTLIL::IdString, RTLIL::Module * > modules_
std::map< RTLIL::IdString, RTLIL::Cell * > cells_
void log(const char *format,...)
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
void setup_stdcells_mem()
static SigSet< sig2driver_entry_t > sig2driver
static SigSet< sig2driver_entry_t > sig2user
static std::set< RTLIL::Cell * > muxtree_cells
bool cell_input(RTLIL::IdString type, RTLIL::IdString port)
void del(RTLIL::SigSpec sig)
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)
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)
static bool check_state_mux_tree(RTLIL::SigSpec old_sig, RTLIL::SigSpec sig, SigPool &recursion_monitor)
USING_YOSYS_NAMESPACE static PRIVATE_NAMESPACE_BEGIN RTLIL::Module * module