mirror of https://github.com/YosysHQ/yosys.git
formalff: Set new replaced_by_gclk attribute on removed dff's clks
This attribute can be used by formal backends to indicate which clocks were mapped to the global clock. Update the btor and smt2 backend which already handle clock inputs to understand this attribute.
This commit is contained in:
parent
c0063288d6
commit
a5e1d3b997
|
@ -1112,6 +1112,16 @@ struct BtorWorker
|
||||||
|
|
||||||
btorf("%d input %d%s\n", nid, sid, getinfo(wire).c_str());
|
btorf("%d input %d%s\n", nid, sid, getinfo(wire).c_str());
|
||||||
add_nid_sig(nid, sig);
|
add_nid_sig(nid, sig);
|
||||||
|
|
||||||
|
if (!info_filename.empty()) {
|
||||||
|
auto gclk_attr = wire->attributes.find(ID::replaced_by_gclk);
|
||||||
|
if (gclk_attr != wire->attributes.end()) {
|
||||||
|
if (gclk_attr->second == State::S1)
|
||||||
|
info_clocks[nid] |= 1;
|
||||||
|
else if (gclk_attr->second == State::S0)
|
||||||
|
info_clocks[nid] |= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btorf_pop("inputs");
|
btorf_pop("inputs");
|
||||||
|
|
|
@ -239,6 +239,17 @@ struct Smt2Worker
|
||||||
clock_negedge.erase(bit);
|
clock_negedge.erase(bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto wire : module->wires())
|
||||||
|
{
|
||||||
|
auto gclk_attr = wire->attributes.find(ID::replaced_by_gclk);
|
||||||
|
if (gclk_attr != wire->attributes.end()) {
|
||||||
|
if (gclk_attr->second == State::S1)
|
||||||
|
clock_posedge.insert(sigmap(wire));
|
||||||
|
else if (gclk_attr->second == State::S0)
|
||||||
|
clock_negedge.insert(sigmap(wire));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto wire : module->wires())
|
for (auto wire : module->wires())
|
||||||
{
|
{
|
||||||
if (!wire->port_input || GetSize(wire) != 1)
|
if (!wire->port_input || GetSize(wire) != 1)
|
||||||
|
|
|
@ -171,6 +171,7 @@ X(RD_TRANSPARENCY_MASK)
|
||||||
X(RD_TRANSPARENT)
|
X(RD_TRANSPARENT)
|
||||||
X(RD_WIDE_CONTINUATION)
|
X(RD_WIDE_CONTINUATION)
|
||||||
X(reg)
|
X(reg)
|
||||||
|
X(replaced_by_gclk)
|
||||||
X(reprocess_after)
|
X(reprocess_after)
|
||||||
X(rom_block)
|
X(rom_block)
|
||||||
X(rom_style)
|
X(rom_style)
|
||||||
|
|
|
@ -145,6 +145,28 @@ struct FormalFfPass : public Pass {
|
||||||
log_error("Const CLK on %s (%s) from module %s, run async2sync first.\n",
|
log_error("Const CLK on %s (%s) from module %s, run async2sync first.\n",
|
||||||
log_id(cell), log_id(cell->type), log_id(module));
|
log_id(cell), log_id(cell->type), log_id(module));
|
||||||
|
|
||||||
|
auto clk_wire = ff.sig_clk.is_wire() ? ff.sig_clk.as_wire() : nullptr;
|
||||||
|
|
||||||
|
if (clk_wire == nullptr) {
|
||||||
|
clk_wire = module->addWire(NEW_ID);
|
||||||
|
module->connect(RTLIL::SigBit(clk_wire), ff.sig_clk);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto clk_polarity = ff.pol_clk ? State::S1 : State::S0;
|
||||||
|
|
||||||
|
std::string attribute = clk_wire->get_string_attribute(ID::replaced_by_gclk);
|
||||||
|
|
||||||
|
auto &attr = clk_wire->attributes[ID::replaced_by_gclk];
|
||||||
|
|
||||||
|
if (!attr.empty() && attr != clk_polarity)
|
||||||
|
log_error("CLK %s on %s (%s) from module %s also used with opposite polarity, run clk2fflogic instead.\n",
|
||||||
|
log_id(clk_wire), log_id(cell), log_id(cell->type), log_id(module));
|
||||||
|
|
||||||
|
attr = clk_polarity;
|
||||||
|
clk_wire->set_bool_attribute(ID::keep);
|
||||||
|
|
||||||
|
// TODO propagate the replaced_by_gclk attribute upwards throughout the hierarchy
|
||||||
|
|
||||||
ff.unmap_ce_srst();
|
ff.unmap_ce_srst();
|
||||||
ff.has_clk = false;
|
ff.has_clk = false;
|
||||||
ff.has_gclk = true;
|
ff.has_gclk = true;
|
||||||
|
|
Loading…
Reference in New Issue