aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelina Koƛcielnicka <mwk@0x04.net>2021-05-25 22:39:50 +0200
committerMarcelina Koƛcielnicka <mwk@0x04.net>2021-05-25 23:42:31 +0200
commitd99fce3bc77a42563e1e270172e08ec25d58c7ab (patch)
tree6e7f5cd961356735acfd5fe987a9f4ae3b88b5c6
parent18806f1ef653f29654533ee47fd8a1b0cf1d645a (diff)
downloadyosys-d99fce3bc77a42563e1e270172e08ec25d58c7ab.tar.gz
yosys-d99fce3bc77a42563e1e270172e08ec25d58c7ab.tar.bz2
yosys-d99fce3bc77a42563e1e270172e08ec25d58c7ab.zip
mem/extract_rdff: Fix "no FF made" edge case.
When converting a sync transparent read port with const address to async read port, nothing at all needs to be done other than clk_enable change, and thus we have no FF cell to return. Handle this case correctly in the helper and in its users.
-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();