mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-24 01:25:33 +00:00
Merge branch 'main' into make_excl
This commit is contained in:
commit
99afdfa2bf
8 changed files with 87 additions and 16 deletions
|
@ -47,6 +47,8 @@ struct ReconstructBusses : public ScriptPass {
|
|||
log("Running reconstructbusses pass\n");
|
||||
log_flush();
|
||||
for (auto module : design->modules()) {
|
||||
if (module->get_bool_attribute("\\blackbox"))
|
||||
continue;
|
||||
log("Creating bus groups for module %s\n", module->name.str().c_str());
|
||||
log_flush();
|
||||
// Collect all wires with a common prefix
|
||||
|
@ -104,7 +106,7 @@ struct ReconstructBusses : public ScriptPass {
|
|||
}
|
||||
log("Found %ld groups\n", wire_groups.size());
|
||||
if (wire_groups.size() == 0) {
|
||||
std::cout << "No busses to reconstruct. Done." << std::endl;
|
||||
log("No busses to reconstruct. Done.\n");
|
||||
continue;
|
||||
}
|
||||
log("Creating busses\n");
|
||||
|
|
|
@ -136,7 +136,7 @@ struct SplitfanoutWorker
|
|||
// Configure the driver cell
|
||||
IdString new_name;
|
||||
Cell *new_cell;
|
||||
if (bit_user_i-- != 0) { // create a new cell
|
||||
if (bit_user_i != 0) { // create a new cell
|
||||
new_name = module->uniquify(stringf("%s_splfo%d", cell->name.c_str(), bit_user_i));
|
||||
new_cell = module->addCell(new_name, cell);
|
||||
// Add new cell to the bit_users_db
|
||||
|
@ -173,6 +173,9 @@ struct SplitfanoutWorker
|
|||
new_cell->setPort(outport, new_wire);
|
||||
}
|
||||
|
||||
// Decrement bit user index
|
||||
bit_user_i--;
|
||||
|
||||
// Log the new cell
|
||||
log_debug(" slice %d: %s => %s\n", foi++, log_id(new_name), log_signal(new_cell->getPort(outport)));
|
||||
}
|
||||
|
|
|
@ -263,6 +263,19 @@ struct WreduceWorker
|
|||
}
|
||||
}
|
||||
|
||||
int reduced_opsize(const SigSpec &inp, bool signed_)
|
||||
{
|
||||
int size = GetSize(inp);
|
||||
if (signed_) {
|
||||
while (size >= 2 && inp[size - 1] == inp[size - 2])
|
||||
size--;
|
||||
} else {
|
||||
while (size >= 1 && inp[size - 1] == State::S0)
|
||||
size--;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void run_cell(Cell *cell)
|
||||
{
|
||||
bool did_something = false;
|
||||
|
@ -295,6 +308,45 @@ struct WreduceWorker
|
|||
bool port_a_signed = false;
|
||||
bool port_b_signed = false;
|
||||
|
||||
// For some operations if the output is no wider than either of the inputs
|
||||
// we are free to choose the signedness of the operands
|
||||
if (cell->type.in(ID($mul), ID($add), ID($sub)) &&
|
||||
max_port_a_size == GetSize(sig) &&
|
||||
max_port_b_size == GetSize(sig)) {
|
||||
SigSpec sig_a = mi.sigmap(cell->getPort(ID::A)), sig_b = mi.sigmap(cell->getPort(ID::B));
|
||||
|
||||
// Remove top bits from sig_a and sig_b which are not visible on the output
|
||||
sig_a.extend_u0(max_port_a_size);
|
||||
sig_b.extend_u0(max_port_b_size);
|
||||
|
||||
int signed_cost, unsigned_cost;
|
||||
if (cell->type == ID($mul)) {
|
||||
signed_cost = reduced_opsize(sig_a, true) * reduced_opsize(sig_b, true);
|
||||
unsigned_cost = reduced_opsize(sig_a, false) * reduced_opsize(sig_b, false);
|
||||
} else {
|
||||
signed_cost = max(reduced_opsize(sig_a, true), reduced_opsize(sig_b, true));
|
||||
unsigned_cost = max(reduced_opsize(sig_a, false), reduced_opsize(sig_b, false));
|
||||
}
|
||||
|
||||
if (!port_a_signed && !port_b_signed && signed_cost < unsigned_cost) {
|
||||
log("Converting cell %s.%s (%s) from unsigned to signed.\n",
|
||||
log_id(module), log_id(cell), log_id(cell->type));
|
||||
cell->setParam(ID::A_SIGNED, 1);
|
||||
cell->setParam(ID::B_SIGNED, 1);
|
||||
port_a_signed = true;
|
||||
port_b_signed = true;
|
||||
did_something = true;
|
||||
} else if (port_a_signed && port_b_signed && unsigned_cost < signed_cost) {
|
||||
log("Converting cell %s.%s (%s) from signed to unsigned.\n",
|
||||
log_id(module), log_id(cell), log_id(cell->type));
|
||||
cell->setParam(ID::A_SIGNED, 0);
|
||||
cell->setParam(ID::B_SIGNED, 0);
|
||||
port_a_signed = false;
|
||||
port_b_signed = false;
|
||||
did_something = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_port_a_size >= 0 && cell->type != ID($shiftx))
|
||||
run_reduce_inport(cell, 'A', max_port_a_size, port_a_signed, did_something);
|
||||
|
||||
|
|
|
@ -391,7 +391,7 @@ struct BufnormPass : public Pass {
|
|||
}
|
||||
|
||||
if (w->name.isPublic())
|
||||
log(" directly driven by cell %s port %s: %s\n",
|
||||
log_debug(" directly driven by cell %s port %s: %s\n",
|
||||
log_id(cell), log_id(conn.first), log_id(w));
|
||||
|
||||
for (auto bit : SigSpec(w))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue