aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/mem.cc5
-rw-r--r--passes/memory/memory_nordff.cc7
2 files changed, 9 insertions, 3 deletions
diff --git a/kernel/mem.cc b/kernel/mem.cc
index 5d0a01dd2..fe88be5d7 100644
--- a/kernel/mem.cc
+++ b/kernel/mem.cc
@@ -579,7 +579,8 @@ Cell *Mem::extract_rdff(int idx, FfInitVals *initvals) {
if (port.addr[i].wire)
width++;
- if (width) {
+ if (width)
+ {
SigSpec sig_q = module->addWire(stringf("$%s$rdreg[%d]$q", memid.c_str(), idx), width);
SigSpec sig_d;
@@ -591,6 +592,8 @@ Cell *Mem::extract_rdff(int idx, FfInitVals *initvals) {
}
c = module->addDff(stringf("$%s$rdreg[%d]", memid.c_str(), idx), port.clk, sig_d, sig_q, port.clk_polarity);
+ } else {
+ c = nullptr;
}
}
else
diff --git a/passes/memory/memory_nordff.cc b/passes/memory/memory_nordff.cc
index 665efceb2..80f78ca77 100644
--- a/passes/memory/memory_nordff.cc
+++ b/passes/memory/memory_nordff.cc
@@ -57,9 +57,12 @@ struct MemoryNordffPass : public Pass {
for (auto &mem : Mem::get_selected_memories(module))
{
bool changed = false;
- for (int i = 0; i < GetSize(mem.rd_ports); i++)
- if (mem.extract_rdff(i, &initvals))
+ for (int i = 0; i < GetSize(mem.rd_ports); i++) {
+ if (mem.rd_ports[i].clk_enable) {
+ mem.extract_rdff(i, &initvals);
changed = true;
+ }
+ }
if (changed)
mem.emit();