39 std::vector<port_t> new_ports;
43 for (
auto &port :
ports)
49 std::swap(port.in_a, port.in_b);
51 if (
GetSize(port.in_a) == 1 &&
GetSize(port.in_b) == 0 && !port.is_signed && !port.do_subtract) {
56 if (port.in_a.is_fully_const() && port.in_b.is_fully_const()) {
59 v =
const_mul(v, port.in_b.as_const(), port.is_signed, port.is_signed, width);
61 off =
const_sub(off, v, port.is_signed, port.is_signed, width);
63 off =
const_add(off, v, port.is_signed, port.is_signed, width);
69 port.in_a.remove(
GetSize(port.in_a)-1);
71 port.in_b.remove(
GetSize(port.in_b)-1);
74 port.in_a.remove(
GetSize(port.in_a)-1);
76 port.in_b.remove(
GetSize(port.in_b)-1);
79 new_ports.push_back(port);
91 port.is_signed =
false;
92 port.do_subtract =
false;
93 new_ports.push_back(port);
96 new_ports.swap(ports);
97 bit_ports = new_bit_ports;
RTLIL::Const const_sub(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
std::vector< port_t > ports
RTLIL::Const const_mul(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)
int GetSize(RTLIL::Wire *wire)
void append(const RTLIL::SigSpec &signal)
RTLIL::Const const_add(const RTLIL::Const &arg1, const RTLIL::Const &arg2, bool signed1, bool signed2, int result_len)