tidy up i_valid_logic
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 5 Apr 2019 22:43:37 +0000 (23:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 5 Apr 2019 22:43:37 +0000 (23:43 +0100)
src/add/singlepipe.py

index 2cb7d1ab06bacdc11f95ac14848d0b2b70aed308..02b8235285e594b2a3042cafcec44b061ff8cc19 100644 (file)
@@ -195,15 +195,20 @@ class PrevControl:
 
     def i_valid_logic(self):
         vlen = len(self.i_valid)
-        if vlen > 1: # multi-bit case: valid only when i_valid is all 1s
+        if vlen > 1:
+            # multi-bit case: valid only when i_valid is all 1s
             all1s = Const(-1, (len(self.i_valid), False))
-            if self.stage_ctl:
-                return self.i_valid == all1s & self.s_o_ready
-            return self.i_valid == all1s
-        # single-bit i_valid case
+            i_valid = (self.i_valid == all1s)
+        else:
+            # single-bit i_valid case
+            i_valid = self.i_valid
+
+        # when stage indicates not ready, incoming data
+        # must "appear" to be not ready too
         if self.stage_ctl:
-            return self.i_valid & self.s_o_ready
-        return self.i_valid
+            i_valid = i_valid & self.s_o_ready
+
+        return i_valid
 
 
 class NextControl: