91 if (cell->
type ==
"$lcu")
101 if (!
eval(sig_p, undef, cell))
104 if (!
eval(sig_g, undef, cell))
107 if (!
eval(sig_ci, undef, cell))
115 for (
int i = 0; i <
GetSize(coval); i++) {
132 if (sig_y.is_fully_const())
137 if (!
eval(sig_s, undef, cell))
147 if (cell->
type ==
"$mux" || cell->
type ==
"$pmux" || cell->
type ==
"$_MUX_")
149 std::vector<RTLIL::SigSpec> y_candidates;
150 int count_maybe_set_s_bits = 0;
151 int count_set_s_bits = 0;
153 for (
int i = 0; i < sig_s.
size(); i++)
159 y_candidates.push_back(b_slice);
162 count_maybe_set_s_bits++;
168 if (count_set_s_bits == 0)
169 y_candidates.push_back(sig_a);
171 std::vector<RTLIL::Const> y_values;
174 for (
auto &yc : y_candidates) {
175 if (!
eval(yc, undef, cell))
177 y_values.push_back(yc.as_const());
180 if (y_values.size() > 1)
182 std::vector<RTLIL::State> master_bits = y_values.at(0).bits;
184 for (
size_t i = 1; i < y_values.size(); i++) {
185 std::vector<RTLIL::State> &slave_bits = y_values.at(i).bits;
186 log_assert(master_bits.size() == slave_bits.size());
187 for (
size_t j = 0; j < master_bits.size(); j++)
188 if (master_bits[j] != slave_bits[j])
195 set(sig_y, y_values.front());
197 else if (cell->
type ==
"$fa")
203 if (!
eval(sig_a, undef, cell))
206 if (!
eval(sig_b, undef, cell))
209 if (!
eval(sig_c, undef, cell))
219 for (
int i = 0; i <
GetSize(val_y); i++)
226 else if (cell->
type ==
"$alu")
228 bool signed_a = cell->
parameters.count(
"\\A_SIGNED") > 0 && cell->
parameters[
"\\A_SIGNED"].as_bool();
229 bool signed_b = cell->
parameters.count(
"\\B_SIGNED") > 0 && cell->
parameters[
"\\B_SIGNED"].as_bool();
234 if (!
eval(sig_a, undef, cell))
237 if (!
eval(sig_b, undef, cell))
240 if (!
eval(sig_ci, undef, cell))
243 if (!
eval(sig_bi, undef, cell))
256 for (
int i = 0; i <
GetSize(sig_y); i++)
264 bool bit_b = (sig_b[i] ==
RTLIL::S1) != b_inv;
265 bool bit_x = bit_a != bit_b;
269 if (any_input_undef) {
274 bool bit_b = (sig_b[i] ==
RTLIL::S1) != b_inv;
275 bool bit_y = (bit_a != bit_b) != carry;
276 carry = (bit_a && bit_b) || (bit_a && carry) || (bit_b && carry);
282 else if (cell->
type ==
"$macc")
290 for (
auto &port : macc.
ports) {
291 if (!
eval(port.in_a, undef, cell))
293 if (!
eval(port.in_b, undef, cell))
298 if (!macc.
eval(result))
307 if (cell->
type.
in(
"$_AOI3_",
"$_OAI3_",
"$_AOI4_",
"$_OAI4_")) {
314 if (sig_a.
size() > 0 && !
eval(sig_a, undef, cell))
316 if (sig_b.
size() > 0 && !
eval(sig_b, undef, cell))
318 if (sig_c.
size() > 0 && !
eval(sig_c, undef, cell))
320 if (sig_d.
size() > 0 && !
eval(sig_d, undef, cell))
bool is_fully_def() const
RTLIL::Const const_xor(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL::Const as_const() const
bool eval(RTLIL::Const &result) const
bool eval(RTLIL::Cell *cell, RTLIL::SigSpec &undef)
std::vector< port_t > ports
std::map< RTLIL::IdString, RTLIL::Const > parameters
void extend_u0(int width, bool is_signed=false)
RTLIL::Const const_or(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
bool in(T first, Args...rest)
RTLIL::Const const_and(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
RTLIL_ATTRIBUTE_MEMBERS bool hasPort(RTLIL::IdString portname) const
const RTLIL::SigSpec & getPort(RTLIL::IdString portname) const
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_)
bool is_fully_const() const
void from_cell(RTLIL::Cell *cell)
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
std::vector< RTLIL::State > bits
void set(RTLIL::SigSpec sig, RTLIL::Const value)