mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-23 06:13:41 +00:00
Allow extract_reduce to operate on xnors and single-bit word-wide operators
This commit is contained in:
parent
cefce37e59
commit
610d4cc716
1 changed files with 23 additions and 5 deletions
|
@ -29,7 +29,8 @@ struct ExtractReducePass : public Pass
|
||||||
enum GateType {
|
enum GateType {
|
||||||
And,
|
And,
|
||||||
Or,
|
Or,
|
||||||
Xor
|
Xor,
|
||||||
|
Xnor
|
||||||
};
|
};
|
||||||
|
|
||||||
ExtractReducePass() : Pass("extract_reduce", "converts gate chains into $reduce_* cells") { }
|
ExtractReducePass() : Pass("extract_reduce", "converts gate chains into $reduce_* cells") { }
|
||||||
|
@ -60,7 +61,12 @@ struct ExtractReducePass : public Pass
|
||||||
{
|
{
|
||||||
return (cell->type == ID($_AND_) && gt == GateType::And) ||
|
return (cell->type == ID($_AND_) && gt == GateType::And) ||
|
||||||
(cell->type == ID($_OR_) && gt == GateType::Or) ||
|
(cell->type == ID($_OR_) && gt == GateType::Or) ||
|
||||||
(cell->type == ID($_XOR_) && gt == GateType::Xor);
|
(cell->type == ID($_XOR_) && gt == GateType::Xor) ||
|
||||||
|
(cell->type == ID($_XNOR_) && gt == GateType::Xnor) ||
|
||||||
|
(cell->type == ID($and) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1 && gt == GateType::And) ||
|
||||||
|
(cell->type == ID($or) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1 && gt == GateType::Or) ||
|
||||||
|
(cell->type == ID($xor) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1 && gt == GateType::Xor) ||
|
||||||
|
(cell->type == ID($xnor) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1 && gt == GateType::Xnor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||||
|
@ -130,6 +136,16 @@ struct ExtractReducePass : public Pass
|
||||||
gt = GateType::Or;
|
gt = GateType::Or;
|
||||||
else if (cell->type == ID($_XOR_))
|
else if (cell->type == ID($_XOR_))
|
||||||
gt = GateType::Xor;
|
gt = GateType::Xor;
|
||||||
|
else if (cell->type == ID($_XNOR_))
|
||||||
|
gt = GateType::Xnor;
|
||||||
|
else if (cell->type == ID($and) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1)
|
||||||
|
gt = GateType::And;
|
||||||
|
else if (cell->type == ID($or) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1)
|
||||||
|
gt = GateType::Or;
|
||||||
|
else if (cell->type == ID($xor) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1)
|
||||||
|
gt = GateType::Xor;
|
||||||
|
else if (cell->type == ID($xnor) && cell->getParam(ID::A_WIDTH).as_int() == 1 && cell->getParam(ID::B_WIDTH).as_int() == 1 && cell->getParam(ID::Y_WIDTH).as_int() == 1)
|
||||||
|
gt = GateType::Xnor;
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -269,12 +285,14 @@ struct ExtractReducePass : public Pass
|
||||||
input.append(it.first);
|
input.append(it.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (head_cell->type == ID($_AND_)) {
|
if (head_cell->type == ID($_AND_) || head_cell->type == ID($and)) {
|
||||||
module->addReduceAnd(NEW_ID2_SUFFIX("reduce_and"), input, output, false, cell->get_src_attribute()); // SILIMATE: Improve the naming
|
module->addReduceAnd(NEW_ID2_SUFFIX("reduce_and"), input, output, false, cell->get_src_attribute()); // SILIMATE: Improve the naming
|
||||||
} else if (head_cell->type == ID($_OR_)) {
|
} else if (head_cell->type == ID($_OR_) || head_cell->type == ID($or)) {
|
||||||
module->addReduceOr(NEW_ID2_SUFFIX("reduce_or"), input, output, false, cell->get_src_attribute()); // SILIMATE: Improve the naming
|
module->addReduceOr(NEW_ID2_SUFFIX("reduce_or"), input, output, false, cell->get_src_attribute()); // SILIMATE: Improve the naming
|
||||||
} else if (head_cell->type == ID($_XOR_)) {
|
} else if (head_cell->type == ID($_XOR_) || head_cell->type == ID($xor)) {
|
||||||
module->addReduceXor(NEW_ID2_SUFFIX("reduce_xor"), input, output, false, cell->get_src_attribute()); // SILIMATE: Improve the naming
|
module->addReduceXor(NEW_ID2_SUFFIX("reduce_xor"), input, output, false, cell->get_src_attribute()); // SILIMATE: Improve the naming
|
||||||
|
} else if (head_cell->type == ID($_XNOR_) || head_cell->type == ID($xnor)) {
|
||||||
|
module->addReduceXnor(NEW_ID2_SUFFIX("reduce_xnor"), input, output, false, cell->get_src_attribute()); // SILIMATE: Improve the naming
|
||||||
} else {
|
} else {
|
||||||
log_assert(false);
|
log_assert(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue