aboutsummaryrefslogtreecommitdiffstats
path: root/passes/memory/memory_dff.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-10-31 22:01:41 +0100
committerClifford Wolf <clifford@clifford.at>2015-10-31 22:01:41 +0100
commitddf3e2dc657da5e441bd9315bf1a86959a07cab9 (patch)
tree0bb35e45f34214a2b898a4d3c028ec4f52b5760a /passes/memory/memory_dff.cc
parentccdbf41be60f78df9f8f2347026aaaf03693bd35 (diff)
downloadyosys-ddf3e2dc657da5e441bd9315bf1a86959a07cab9.tar.gz
yosys-ddf3e2dc657da5e441bd9315bf1a86959a07cab9.tar.bz2
yosys-ddf3e2dc657da5e441bd9315bf1a86959a07cab9.zip
Bugfix in memory_dff
Diffstat (limited to 'passes/memory/memory_dff.cc')
-rw-r--r--passes/memory/memory_dff.cc13
1 files changed, 12 insertions, 1 deletions
diff --git a/passes/memory/memory_dff.cc b/passes/memory/memory_dff.cc
index 3373369f6..2eec0207b 100644
--- a/passes/memory/memory_dff.cc
+++ b/passes/memory/memory_dff.cc
@@ -32,6 +32,7 @@ struct MemoryDffWorker
dict<SigBit, SigBit> invbits;
dict<SigBit, int> sigbit_users_count;
dict<SigSpec, Cell*> mux_cells_a, mux_cells_b;
+ pool<Cell*> forward_merged_dffs, candidate_dffs;
MemoryDffWorker(Module *module) : module(module), sigmap(module) { }
@@ -46,6 +47,9 @@ struct MemoryDffWorker
for (auto cell : dff_cells)
{
+ if (after && forward_merged_dffs.count(cell))
+ continue;
+
SigSpec this_clk = cell->getPort("\\CLK");
bool this_clk_polarity = cell->parameters["\\CLK_POLARITY"].as_bool();
@@ -71,6 +75,7 @@ struct MemoryDffWorker
bit = d;
clk = this_clk;
clk_polarity = this_clk_polarity;
+ candidate_dffs.insert(cell);
goto replaced_this_bit;
}
@@ -87,6 +92,7 @@ struct MemoryDffWorker
RTLIL::SigSpec clk = RTLIL::SigSpec(RTLIL::State::Sx);
bool clk_polarity = 0;
+ candidate_dffs.clear();
RTLIL::SigSpec sig_addr = cell->getPort("\\ADDR");
if (!find_sig_before_dff(sig_addr, clk, clk_polarity)) {
@@ -106,13 +112,18 @@ struct MemoryDffWorker
return;
}
- if (clk != RTLIL::SigSpec(RTLIL::State::Sx)) {
+ if (clk != RTLIL::SigSpec(RTLIL::State::Sx))
+ {
+ for (auto cell : candidate_dffs)
+ forward_merged_dffs.insert(cell);
+
cell->setPort("\\CLK", clk);
cell->setPort("\\ADDR", sig_addr);
cell->setPort("\\DATA", sig_data);
cell->setPort("\\EN", sig_en);
cell->parameters["\\CLK_ENABLE"] = RTLIL::Const(1);
cell->parameters["\\CLK_POLARITY"] = RTLIL::Const(clk_polarity);
+
log("merged $dff to cell.\n");
return;
}