mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Disable memory_dff for initialized FFs
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
74efafc1cf
commit
cee4b1e6bc
|
@ -33,8 +33,20 @@ struct MemoryDffWorker
|
||||||
dict<SigBit, int> sigbit_users_count;
|
dict<SigBit, int> sigbit_users_count;
|
||||||
dict<SigSpec, Cell*> mux_cells_a, mux_cells_b;
|
dict<SigSpec, Cell*> mux_cells_a, mux_cells_b;
|
||||||
pool<Cell*> forward_merged_dffs, candidate_dffs;
|
pool<Cell*> forward_merged_dffs, candidate_dffs;
|
||||||
|
pool<SigBit> init_bits;
|
||||||
|
|
||||||
MemoryDffWorker(Module *module) : module(module), sigmap(module) { }
|
MemoryDffWorker(Module *module) : module(module), sigmap(module)
|
||||||
|
{
|
||||||
|
for (auto wire : module->wires()) {
|
||||||
|
if (wire->attributes.count("\\init") == 0)
|
||||||
|
continue;
|
||||||
|
SigSpec sig = sigmap(wire);
|
||||||
|
Const initval = wire->attributes.count("\\init");
|
||||||
|
for (int i = 0; i < GetSize(sig) && i < GetSize(initval); i++)
|
||||||
|
if (initval[i] == State::S0 || initval[i] == State::S1)
|
||||||
|
init_bits.insert(sig[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool find_sig_before_dff(RTLIL::SigSpec &sig, RTLIL::SigSpec &clk, bool &clk_polarity, bool after = false)
|
bool find_sig_before_dff(RTLIL::SigSpec &sig, RTLIL::SigSpec &clk, bool &clk_polarity, bool after = false)
|
||||||
{
|
{
|
||||||
|
@ -45,6 +57,9 @@ struct MemoryDffWorker
|
||||||
if (bit.wire == NULL)
|
if (bit.wire == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (!after && init_bits.count(sigmap(bit)))
|
||||||
|
return false;
|
||||||
|
|
||||||
for (auto cell : dff_cells)
|
for (auto cell : dff_cells)
|
||||||
{
|
{
|
||||||
if (after && forward_merged_dffs.count(cell))
|
if (after && forward_merged_dffs.count(cell))
|
||||||
|
@ -72,6 +87,9 @@ struct MemoryDffWorker
|
||||||
if (d.size() != 1)
|
if (d.size() != 1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (after && init_bits.count(d))
|
||||||
|
return false;
|
||||||
|
|
||||||
bit = d;
|
bit = d;
|
||||||
clk = this_clk;
|
clk = this_clk;
|
||||||
clk_polarity = this_clk_polarity;
|
clk_polarity = this_clk_polarity;
|
||||||
|
|
Loading…
Reference in a new issue