Present the ALU result only when valid_o is active
authorCesar Strauss <cestrauss@gmail.com>
Thu, 2 Jul 2020 08:55:59 +0000 (05:55 -0300)
committerCesar Strauss <cestrauss@gmail.com>
Thu, 2 Jul 2020 08:59:43 +0000 (05:59 -0300)
This should help to catch latching of invalid data.
Also, better demonstrates the valid / ready protocol.

src/soc/experiment/alu_hier.py

index 581fd11324d50a0fccf7814c0895a22ad53d5bbc..5dcf958ce320e05051b92fd6a0d9baf55d1d097c 100644 (file)
@@ -268,7 +268,8 @@ class ALU(Elaboratable):
         # choose between zero-delay output, or registered
         with m.If(go_now):
             m.d.comb += self.o.eq(sub.o)
-        with m.Else():
+        # only present the result at the last computation cycle
+        with m.Elif(alu_done):
             m.d.comb += self.o.eq(alu_r)
 
         return m