From 4c426b36f3d342a3e89a8e6ad01ccf4e8b18f388 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 27 May 2014 00:17:34 +0200 Subject: [PATCH] fifo: add support for depth=2 --- migen/genlib/fifo.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/migen/genlib/fifo.py b/migen/genlib/fifo.py index 5059694c..27d3c679 100644 --- a/migen/genlib/fifo.py +++ b/migen/genlib/fifo.py @@ -217,12 +217,16 @@ class AsyncFIFO(Module, _FIFOInterface): NoRetiming(consume.q), MultiReg(consume.q, consume_wdomain, "write") ] - self.comb += [ - self.writable.eq((produce.q[-1] == consume_wdomain[-1]) - | (produce.q[-2] == consume_wdomain[-2]) - | (produce.q[:-2] != consume_wdomain[:-2])), - self.readable.eq(consume.q != produce_rdomain) - ] + if depth_bits == 1: + self.comb += self.writable.eq((produce.q[-1] == consume_wdomain[-1]) + | (produce.q[-2] == consume_wdomain[-2])) + else: + self.comb += [ + self.writable.eq((produce.q[-1] == consume_wdomain[-1]) + | (produce.q[-2] == consume_wdomain[-2]) + | (produce.q[:-2] != consume_wdomain[:-2])) + ] + self.comb += self.readable.eq(consume.q != produce_rdomain) storage = Memory(self.width, depth) self.specials += storage -- 2.30.2