39 int state_num_log2 = 0;
42 state_num_log2 = std::max(state_num_log2, 1);
51 std::vector<RTLIL::State> &bits_table = cell->
parameters[
"\\STATE_TABLE"].bits;
52 std::vector<RTLIL::State> &bits_state =
state_table[i].bits;
53 bits_table.insert(bits_table.end(), bits_state.begin(), bits_state.end());
60 std::vector<RTLIL::State> &bits_table = cell->
parameters[
"\\TRANS_TABLE"].bits;
65 std::vector<RTLIL::State> &bits_state_in = const_state_in.
bits;
66 std::vector<RTLIL::State> &bits_state_out = const_state_out.
bits;
68 std::vector<RTLIL::State> &bits_ctrl_in = tr.
ctrl_in.
bits;
69 std::vector<RTLIL::State> &bits_ctrl_out = tr.
ctrl_out.
bits;
72 bits_table.insert(bits_table.end(), bits_ctrl_out.begin(), bits_ctrl_out.end());
73 bits_table.insert(bits_table.end(), bits_state_out.begin(), bits_state_out.end());
74 bits_table.insert(bits_table.end(), bits_ctrl_in.begin(), bits_ctrl_in.end());
75 bits_table.insert(bits_table.end(), bits_state_in.begin(), bits_state_in.end());
87 int state_num = cell->
parameters[
"\\STATE_NUM"].as_int();
88 int state_num_log2 = cell->
parameters[
"\\STATE_NUM_LOG2"].as_int();
89 int trans_num = cell->
parameters[
"\\TRANS_NUM"].as_int();
91 if (reset_state < 0 || reset_state >= state_num)
97 for (
int i = 0; i < state_num; i++) {
100 state_code.
bits.insert(state_code.
bits.begin(), state_table.
bits.begin()+off_begin, state_table.
bits.begin()+off_end);
101 this->state_table.push_back(state_code);
104 for (
int i = 0; i < trans_num; i++)
108 auto off_ctrl_in = off_state_out + state_num_log2;
110 auto off_end = off_state_in + state_num_log2;
113 ctrl_out.
bits.insert(state_in.
bits.begin(), off_ctrl_out, off_state_out);
114 state_out.
bits.insert(state_out.
bits.begin(), off_state_out, off_ctrl_in);
115 ctrl_in.
bits.insert(ctrl_in.
bits.begin(), off_ctrl_in, off_state_in);
116 state_in.
bits.insert(state_in.
bits.begin(), off_state_in, off_end);
135 log(
"-------------------------------------\n");
137 log(
" Information on FSM %s (%s):\n", cell->
name.
c_str(), cell->
parameters[
"\\NAME"].decode_string().c_str());
144 log(
" Input signals:\n");
146 for (
int i = 0; i <
GetSize(sig_in); i++)
150 log(
" Output signals:\n");
152 for (
int i = 0; i <
GetSize(sig_out); i++)
156 log(
" State encoding:\n");
162 log(
" Transition Table (state_in, ctrl_in, state_out, ctrl_out):\n");
169 log(
"-------------------------------------\n");
const char * c_str() const
std::vector< transition_t > transition_table
#define YOSYS_NAMESPACE_END
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
void copy_to_cell(RTLIL::Cell *cell)
std::map< RTLIL::IdString, RTLIL::Const > parameters
static void optimize_fsm(RTLIL::Cell *cell, RTLIL::Module *module)
const RTLIL::SigSpec & getPort(RTLIL::IdString portname) const
int GetSize(RTLIL::Wire *wire)
void log_info(RTLIL::Cell *cell)
int as_int(bool is_signed=false) const
#define YOSYS_NAMESPACE_BEGIN
std::vector< RTLIL::Const > state_table
void log(const char *format,...)
void copy_from_cell(RTLIL::Cell *cell)
std::vector< RTLIL::State > bits