if (SIZE(C) > 1)
goto next_macc;
- if (!subtract_b && B < A)
+ if (!subtract_b && B < A && SIZE(B))
std::swap(A, B);
log(" creating $alu model for $macc %s.\n", log_id(n->cell));
void replace_macc()
{
- macc_counter += SIZE(sig_macc);
-
for (auto &it : sig_macc)
{
auto n = it.second;
auto cell = module->addCell(NEW_ID, "$macc");
+ macc_counter++;
+
log(" creating $macc cell for %s: %s\n", log_id(n->cell), log_id(cell));
+
n->macc.to_cell(cell);
cell->setPort("\\Y", n->y);
cell->fixup_parameters();
RTLIL::SigSpec B = sigmap(cell->getPort("\\B"));
RTLIL::SigSpec Y = sigmap(cell->getPort("\\Y"));
- if (B < A) {
+ if (B < A && SIZE(B)) {
cmp_less = !cmp_less;
std::swap(A, B);
}
RTLIL::SigSpec B = sigmap(cell->getPort("\\B"));
RTLIL::SigSpec Y = sigmap(cell->getPort("\\Y"));
- if (B < A)
+ if (B < A && SIZE(B))
std::swap(A, B);
alunode_t *n = nullptr;
void replace_alu()
{
- alu_counter += SIZE(sig_alu);
-
for (auto &it1 : sig_alu)
for (auto n : it1.second)
{
+ if (SIZE(n->b) == 0 && SIZE(n->c) == 0 && SIZE(n->cmp) == 0)
+ {
+ n->alu_cell = module->addPos(NEW_ID, n->a, n->y, n->is_signed);
+
+ log(" creating $pos cell for ");
+ for (int i = 0; i < SIZE(n->cells); i++)
+ log("%s%s", i ? ", ": "", log_id(n->cells[i]));
+ log(": %s\n", log_id(n->alu_cell));
+
+ goto delete_node;
+ }
+
n->alu_cell = module->addCell(NEW_ID, "$alu");
+ alu_counter++;
log(" creating $alu cell for ");
for (int i = 0; i < SIZE(n->cells); i++)
log("%s%s", i ? ", ": "", log_id(n->cells[i]));
log(": %s\n", log_id(n->alu_cell));
- RTLIL::Wire *x = module->addWire(NEW_ID, SIZE(n->y));
- RTLIL::Wire *co = module->addWire(NEW_ID, SIZE(n->y));
-
n->alu_cell->setPort("\\A", n->a);
n->alu_cell->setPort("\\B", n->b);
n->alu_cell->setPort("\\CI", SIZE(n->c) ? n->c : RTLIL::S0);
n->alu_cell->setPort("\\BI", n->invert_b ? RTLIL::S1 : RTLIL::S0);
n->alu_cell->setPort("\\Y", n->y);
- n->alu_cell->setPort("\\X", x);
- n->alu_cell->setPort("\\CO", co);
- n->alu_cell->fixup_parameters();
+ n->alu_cell->setPort("\\X", module->addWire(NEW_ID, SIZE(n->y)));
+ n->alu_cell->setPort("\\CO", module->addWire(NEW_ID, SIZE(n->y)));
+ n->alu_cell->fixup_parameters(n->is_signed, n->is_signed);
+ log_cell(n->alu_cell);
for (auto &it : n->cmp)
{
module->connect(cmp_y, sig);
}
+ delete_node:
for (auto c : n->cells)
module->remove(c);
delete n;