Skip to content

Commit

Permalink
AsyncFIFO: disable read from dual-port Memory when FIFO empty
Browse files Browse the repository at this point in the history
Avoids CDC hazard described in issue amaranth-lang#217.
  • Loading branch information
awygle committed Apr 24, 2020
1 parent ba79b0c commit 75e87f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nmigen/lib/fifo.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,12 @@ def elaborate(self, platform):
w_port.en.eq(do_write),
self.w_rdy.eq(~w_full),
]
# There is a CDC hazard associated with simultaneous read and write from a dual port BRAM.
# We avoid this by disabling `r_port.en` when `r_empty` is true.
m.d.comb += [
r_port.addr.eq(consume_r_nxt[:-1]),
self.r_data.eq(r_port.data),
r_port.en.eq(1),
r_port.en.eq(~r_empty),
self.r_rdy.eq(~r_empty),
]

Expand Down

0 comments on commit 75e87f6

Please sign in to comment.