mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-06 14:13:23 +00:00
macc: Rename 'ports' to 'terms' throughout codebase
This commit is contained in:
parent
05cd1e2942
commit
91cd382f8b
8 changed files with 121 additions and 121 deletions
|
@ -142,7 +142,7 @@ struct AlumaccWorker
|
|||
log(" creating $macc model for %s (%s).\n", log_id(cell), log_id(cell->type));
|
||||
|
||||
maccnode_t *n = new maccnode_t;
|
||||
Macc::port_t new_port;
|
||||
Macc::term_t new_term;
|
||||
|
||||
n->cell = cell;
|
||||
n->y = sigmap(cell->getPort(ID::Y));
|
||||
|
@ -153,32 +153,32 @@ struct AlumaccWorker
|
|||
|
||||
if (cell->type.in(ID($pos), ID($neg)))
|
||||
{
|
||||
new_port.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_port.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_port.do_subtract = cell->type == ID($neg);
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_term.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_term.do_subtract = cell->type == ID($neg);
|
||||
n->macc.terms.push_back(new_term);
|
||||
}
|
||||
|
||||
if (cell->type.in(ID($add), ID($sub)))
|
||||
{
|
||||
new_port.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_port.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_port.do_subtract = false;
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_term.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_term.do_subtract = false;
|
||||
n->macc.terms.push_back(new_term);
|
||||
|
||||
new_port.in_a = sigmap(cell->getPort(ID::B));
|
||||
new_port.is_signed = cell->getParam(ID::B_SIGNED).as_bool();
|
||||
new_port.do_subtract = cell->type == ID($sub);
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::B));
|
||||
new_term.is_signed = cell->getParam(ID::B_SIGNED).as_bool();
|
||||
new_term.do_subtract = cell->type == ID($sub);
|
||||
n->macc.terms.push_back(new_term);
|
||||
}
|
||||
|
||||
if (cell->type.in(ID($mul)))
|
||||
{
|
||||
new_port.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_port.in_b = sigmap(cell->getPort(ID::B));
|
||||
new_port.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_port.do_subtract = false;
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_term.in_b = sigmap(cell->getPort(ID::B));
|
||||
new_term.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_term.do_subtract = false;
|
||||
n->macc.terms.push_back(new_term);
|
||||
}
|
||||
|
||||
log_assert(sig_macc.count(n->y) == 0);
|
||||
|
@ -190,7 +190,7 @@ struct AlumaccWorker
|
|||
{
|
||||
std::vector<int> port_sizes;
|
||||
|
||||
for (auto &port : macc.ports) {
|
||||
for (auto &port : macc.terms) {
|
||||
if (port.is_signed != is_signed)
|
||||
return true;
|
||||
if (!port.is_signed && port.do_subtract)
|
||||
|
@ -235,9 +235,9 @@ struct AlumaccWorker
|
|||
if (delete_nodes.count(n))
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < GetSize(n->macc.ports); i++)
|
||||
for (int i = 0; i < GetSize(n->macc.terms); i++)
|
||||
{
|
||||
auto &port = n->macc.ports[i];
|
||||
auto &port = n->macc.terms[i];
|
||||
|
||||
if (GetSize(port.in_b) > 0 || sig_macc.count(port.in_a) == 0)
|
||||
continue;
|
||||
|
@ -253,13 +253,13 @@ struct AlumaccWorker
|
|||
log(" merging $macc model for %s into %s.\n", log_id(other_n->cell), log_id(n->cell));
|
||||
|
||||
bool do_subtract = port.do_subtract;
|
||||
for (int j = 0; j < GetSize(other_n->macc.ports); j++) {
|
||||
for (int j = 0; j < GetSize(other_n->macc.terms); j++) {
|
||||
if (do_subtract)
|
||||
other_n->macc.ports[j].do_subtract = !other_n->macc.ports[j].do_subtract;
|
||||
other_n->macc.terms[j].do_subtract = !other_n->macc.terms[j].do_subtract;
|
||||
if (j == 0)
|
||||
n->macc.ports[i--] = other_n->macc.ports[j];
|
||||
n->macc.terms[i--] = other_n->macc.terms[j];
|
||||
else
|
||||
n->macc.ports.push_back(other_n->macc.ports[j]);
|
||||
n->macc.terms.push_back(other_n->macc.terms[j]);
|
||||
}
|
||||
|
||||
delete_nodes.insert(other_n);
|
||||
|
@ -288,7 +288,7 @@ struct AlumaccWorker
|
|||
bool subtract_b = false;
|
||||
alunode_t *alunode;
|
||||
|
||||
for (auto &port : n->macc.ports)
|
||||
for (auto &port : n->macc.terms)
|
||||
if (GetSize(port.in_b) > 0) {
|
||||
goto next_macc;
|
||||
} else if (GetSize(port.in_a) == 1 && !port.is_signed && !port.do_subtract) {
|
||||
|
|
|
@ -227,9 +227,9 @@ struct BoothPassWorker {
|
|||
continue;
|
||||
}
|
||||
|
||||
A = macc.ports[0].in_a;
|
||||
B = macc.ports[0].in_b;
|
||||
is_signed = macc.ports[0].is_signed;
|
||||
A = macc.terms[0].in_a;
|
||||
B = macc.terms[0].in_b;
|
||||
is_signed = macc.terms[0].is_signed;
|
||||
Y = cell->getPort(ID::Y);
|
||||
} else {
|
||||
continue;
|
||||
|
|
|
@ -278,42 +278,42 @@ void maccmap(RTLIL::Module *module, RTLIL::Cell *cell, bool unmap)
|
|||
return;
|
||||
}
|
||||
|
||||
for (auto &port : macc.ports)
|
||||
if (GetSize(port.in_b) == 0)
|
||||
log(" %s %s (%d bits, %s)\n", port.do_subtract ? "sub" : "add", log_signal(port.in_a),
|
||||
GetSize(port.in_a), port.is_signed ? "signed" : "unsigned");
|
||||
for (auto &term : macc.terms)
|
||||
if (GetSize(term.in_b) == 0)
|
||||
log(" %s %s (%d bits, %s)\n", term.do_subtract ? "sub" : "add", log_signal(term.in_a),
|
||||
GetSize(term.in_a), term.is_signed ? "signed" : "unsigned");
|
||||
else
|
||||
log(" %s %s * %s (%dx%d bits, %s)\n", port.do_subtract ? "sub" : "add", log_signal(port.in_a), log_signal(port.in_b),
|
||||
GetSize(port.in_a), GetSize(port.in_b), port.is_signed ? "signed" : "unsigned");
|
||||
log(" %s %s * %s (%dx%d bits, %s)\n", term.do_subtract ? "sub" : "add", log_signal(term.in_a), log_signal(term.in_b),
|
||||
GetSize(term.in_a), GetSize(term.in_b), term.is_signed ? "signed" : "unsigned");
|
||||
|
||||
if (unmap)
|
||||
{
|
||||
typedef std::pair<RTLIL::SigSpec, bool> summand_t;
|
||||
std::vector<summand_t> summands;
|
||||
|
||||
RTLIL::SigSpec bit_ports;
|
||||
RTLIL::SigSpec bit_terms;
|
||||
|
||||
for (auto &port : macc.ports) {
|
||||
for (auto &term : macc.terms) {
|
||||
summand_t this_summand;
|
||||
if (GetSize(port.in_b)) {
|
||||
if (GetSize(term.in_b)) {
|
||||
this_summand.first = module->addWire(NEW_ID, width);
|
||||
module->addMul(NEW_ID, port.in_a, port.in_b, this_summand.first, port.is_signed);
|
||||
} else if (GetSize(port.in_a) == 1 && GetSize(port.in_b) == 0 && !port.is_signed && !port.do_subtract) {
|
||||
// Mimic old 'bit_ports' treatment in case it's relevant for performance,
|
||||
module->addMul(NEW_ID, term.in_a, term.in_b, this_summand.first, term.is_signed);
|
||||
} else if (GetSize(term.in_a) == 1 && GetSize(term.in_b) == 0 && !term.is_signed && !term.do_subtract) {
|
||||
// Mimic old 'bit_terms' treatment in case it's relevant for performance,
|
||||
// i.e. defer single-bit summands to be the last ones
|
||||
bit_ports.append(port.in_a);
|
||||
bit_terms.append(term.in_a);
|
||||
continue;
|
||||
} else if (GetSize(port.in_a) != width) {
|
||||
} else if (GetSize(term.in_a) != width) {
|
||||
this_summand.first = module->addWire(NEW_ID, width);
|
||||
module->addPos(NEW_ID, port.in_a, this_summand.first, port.is_signed);
|
||||
module->addPos(NEW_ID, term.in_a, this_summand.first, term.is_signed);
|
||||
} else {
|
||||
this_summand.first = port.in_a;
|
||||
this_summand.first = term.in_a;
|
||||
}
|
||||
this_summand.second = port.do_subtract;
|
||||
this_summand.second = term.do_subtract;
|
||||
summands.push_back(this_summand);
|
||||
}
|
||||
|
||||
for (auto &bit : bit_ports)
|
||||
for (auto &bit : bit_terms)
|
||||
summands.push_back(summand_t(bit, false));
|
||||
|
||||
if (GetSize(summands) == 0)
|
||||
|
@ -350,20 +350,20 @@ void maccmap(RTLIL::Module *module, RTLIL::Cell *cell, bool unmap)
|
|||
else
|
||||
{
|
||||
MaccmapWorker worker(module, width);
|
||||
RTLIL::SigSpec bit_ports;
|
||||
RTLIL::SigSpec bit_terms;
|
||||
|
||||
for (auto &port : macc.ports) {
|
||||
// Mimic old 'bit_ports' treatment in case it's relevant for performance,
|
||||
for (auto &term : macc.terms) {
|
||||
// Mimic old 'bit_terms' treatment in case it's relevant for performance,
|
||||
// i.e. defer single-bit summands to be the last ones
|
||||
if (GetSize(port.in_a) == 1 && GetSize(port.in_b) == 0 && !port.is_signed && !port.do_subtract)
|
||||
bit_ports.append(port.in_a);
|
||||
else if (GetSize(port.in_b) == 0)
|
||||
worker.add(port.in_a, port.is_signed, port.do_subtract);
|
||||
if (GetSize(term.in_a) == 1 && GetSize(term.in_b) == 0 && !term.is_signed && !term.do_subtract)
|
||||
bit_terms.append(term.in_a);
|
||||
else if (GetSize(term.in_b) == 0)
|
||||
worker.add(term.in_a, term.is_signed, term.do_subtract);
|
||||
else
|
||||
worker.add(port.in_a, port.in_b, port.is_signed, port.do_subtract);
|
||||
worker.add(term.in_a, term.in_b, term.is_signed, term.do_subtract);
|
||||
}
|
||||
|
||||
for (auto bit : bit_ports)
|
||||
for (auto bit : bit_terms)
|
||||
worker.add(bit, 0);
|
||||
|
||||
module->connect(cell->getPort(ID::Y), worker.synth());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue