fix bug in setting up count
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 17 Apr 2019 06:39:50 +0000 (07:39 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Wed, 17 Apr 2019 06:39:50 +0000 (07:39 +0100)
src/add/queue.py

index 543aaaf278a16cf48b430c30200637f2c5253e15..f1ad3a2e2887f329c0688e5f7041ba859d55723c 100644 (file)
@@ -137,10 +137,10 @@ class Queue(FIFOInterface):
             with m.If(n_i_ready):
                 m.d.comb += p_o_ready.eq(1)
 
-        if self.depth == 1 << len(self.count):  # is depth a power of 2
+        # set the count (available free space), optimise on power-of-two
+        if self.depth == 1 << ptr_width:  # is depth a power of 2
             m.d.comb += self.count.eq(
-                Mux(self.maybe_full & ptr_match, self.depth, 0)
-                | self.ptr_diff)
+                Mux(maybe_full & ptr_match, self.depth, 0) | ptr_diff)
         else:
             m.d.comb += self.count.eq(Mux(ptr_match,
                                           Mux(maybe_full, self.depth, 0),