mirror of https://github.com/YosysHQ/yosys.git
Merge remote-tracking branch 'origin/master' into xc7mux
This commit is contained in:
commit
bcc0a5d136
|
@ -2060,7 +2060,6 @@ namespace YOSYS_PYTHON {
|
||||||
Yosys::log_streams.push_back(&std::cout);
|
Yosys::log_streams.push_back(&std::cout);
|
||||||
Yosys::log_error_stderr = true;
|
Yosys::log_error_stderr = true;
|
||||||
Yosys::yosys_setup();
|
Yosys::yosys_setup();
|
||||||
Yosys::yosys_banner();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,44 +393,112 @@ struct SetundefPass : public Pass {
|
||||||
ffbits.insert(bit);
|
ffbits.insert(bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto wire : module->wires())
|
auto process_initwires = [&]()
|
||||||
{
|
{
|
||||||
if (!wire->attributes.count("\\init"))
|
dict<Wire*, int> wire_weights;
|
||||||
continue;
|
|
||||||
|
|
||||||
for (auto bit : sigmap(wire))
|
for (auto wire : initwires)
|
||||||
ffbits.erase(bit);
|
|
||||||
|
|
||||||
initwires.insert(wire);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int wire_types = 0; wire_types < 2; wire_types++)
|
|
||||||
for (auto wire : module->wires())
|
|
||||||
{
|
{
|
||||||
if (wire->name[0] == (wire_types ? '\\' : '$'))
|
int weight = 0;
|
||||||
next_wire:
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (auto bit : sigmap(wire))
|
for (auto bit : sigmap(wire))
|
||||||
if (!ffbits.count(bit))
|
weight += ffbits.count(bit) ? +1 : -1;
|
||||||
goto next_wire;
|
|
||||||
|
|
||||||
for (auto bit : sigmap(wire))
|
wire_weights[wire] = weight;
|
||||||
ffbits.erase(bit);
|
|
||||||
|
|
||||||
initwires.insert(wire);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto wire : initwires)
|
initwires.sort([&](Wire *a, Wire *b) { return wire_weights.at(a) > wire_weights.at(b); });
|
||||||
{
|
|
||||||
Const &initval = wire->attributes["\\init"];
|
|
||||||
|
|
||||||
for (int i = 0; i < GetSize(wire); i++)
|
for (auto wire : initwires)
|
||||||
if (GetSize(initval) <= i)
|
{
|
||||||
initval.bits.push_back(worker.next_bit());
|
Const &initval = wire->attributes["\\init"];
|
||||||
else if (initval.bits[i] == State::Sx)
|
initval.bits.resize(GetSize(wire), State::Sx);
|
||||||
initval.bits[i] = worker.next_bit();
|
|
||||||
|
for (int i = 0; i < GetSize(wire); i++) {
|
||||||
|
SigBit bit = sigmap(SigBit(wire, i));
|
||||||
|
if (initval[i] == State::Sx && ffbits.count(bit)) {
|
||||||
|
initval[i] = worker.next_bit();
|
||||||
|
ffbits.erase(bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initval.is_fully_undef())
|
||||||
|
wire->attributes.erase("\\init");
|
||||||
|
}
|
||||||
|
|
||||||
|
initwires.clear();
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int wire_types = 0; wire_types < 2; wire_types++)
|
||||||
|
{
|
||||||
|
// prioritize wires that already have an init attribute
|
||||||
|
if (!ffbits.empty())
|
||||||
|
{
|
||||||
|
for (auto wire : module->wires())
|
||||||
|
{
|
||||||
|
if (wire->name[0] == (wire_types ? '\\' : '$'))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!wire->attributes.count("\\init"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Const &initval = wire->attributes["\\init"];
|
||||||
|
initval.bits.resize(GetSize(wire), State::Sx);
|
||||||
|
|
||||||
|
if (initval.is_fully_undef()) {
|
||||||
|
wire->attributes.erase("\\init");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < GetSize(wire); i++)
|
||||||
|
if (initval[i] != State::Sx)
|
||||||
|
ffbits.erase(sigmap(SigBit(wire, i)));
|
||||||
|
|
||||||
|
initwires.insert(wire);
|
||||||
|
}
|
||||||
|
|
||||||
|
process_initwires();
|
||||||
|
}
|
||||||
|
|
||||||
|
// next consider wires that completely contain bits to be initialized
|
||||||
|
if (!ffbits.empty())
|
||||||
|
{
|
||||||
|
for (auto wire : module->wires())
|
||||||
|
{
|
||||||
|
if (wire->name[0] == (wire_types ? '\\' : '$'))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto bit : sigmap(wire))
|
||||||
|
if (!ffbits.count(bit))
|
||||||
|
goto next_wire;
|
||||||
|
|
||||||
|
initwires.insert(wire);
|
||||||
|
|
||||||
|
next_wire:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
process_initwires();
|
||||||
|
}
|
||||||
|
|
||||||
|
// finally use whatever wire we can find.
|
||||||
|
if (!ffbits.empty())
|
||||||
|
{
|
||||||
|
for (auto wire : module->wires())
|
||||||
|
{
|
||||||
|
if (wire->name[0] == (wire_types ? '\\' : '$'))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (auto bit : sigmap(wire))
|
||||||
|
if (ffbits.count(bit))
|
||||||
|
initwires.insert(wire);
|
||||||
|
}
|
||||||
|
|
||||||
|
process_initwires();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_assert(ffbits.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
module->rewrite_sigspecs(worker);
|
module->rewrite_sigspecs(worker);
|
||||||
|
|
|
@ -332,7 +332,7 @@ struct FmcombinePass : public Pass {
|
||||||
|
|
||||||
gate_cell = module->cell(gate_name);
|
gate_cell = module->cell(gate_name);
|
||||||
if (gate_cell == nullptr)
|
if (gate_cell == nullptr)
|
||||||
log_cmd_error("Gold cell %s not found in module %s.\n", log_id(gate_name), log_id(module));
|
log_cmd_error("Gate cell %s not found in module %s.\n", log_id(gate_name), log_id(module));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -351,7 +351,7 @@ struct FmcombinePass : public Pass {
|
||||||
if (!gold_cell->parameters.empty())
|
if (!gold_cell->parameters.empty())
|
||||||
log_cmd_error("Gold cell has unresolved instance parameters.\n");
|
log_cmd_error("Gold cell has unresolved instance parameters.\n");
|
||||||
if (!gate_cell->parameters.empty())
|
if (!gate_cell->parameters.empty())
|
||||||
log_cmd_error("Gold cell has unresolved instance parameters.\n");
|
log_cmd_error("Gate cell has unresolved instance parameters.\n");
|
||||||
|
|
||||||
FmcombineWorker worker(design, gold_cell->type, opts);
|
FmcombineWorker worker(design, gold_cell->type, opts);
|
||||||
worker.generate();
|
worker.generate();
|
||||||
|
|
Loading…
Reference in New Issue