Implement receiver
authorCesar Strauss <cestrauss@gmail.com>
Sun, 5 Jul 2020 22:30:45 +0000 (19:30 -0300)
committerCesar Strauss <cestrauss@gmail.com>
Mon, 6 Jul 2020 08:35:40 +0000 (05:35 -0300)
src/soc/experiment/alu_hier.py

index c4d5305be9d807ca6106aa6f6ece13f527d4a36e..074d18f7086cfa6c0b262c3886fffc741efaed40 100644 (file)
@@ -484,18 +484,30 @@ def test_alu_parallel():
         yield dut.op.insn_type.eq(op)
         yield dut.op.invert_a.eq(inv_a)
         yield dut.p.valid_i.eq(1)
-        yield Settle()
         while True:
+            yield
             rdy = yield dut.p.ready_o
             if rdy:
                 break
+        yield dut.p.valid_i.eq(0)
+
+    def receive():
+        yield dut.n.ready_i.eq(1)
+        while True:
+            valid = yield dut.n.valid_o
+            if valid:
+                break
             yield
+        result = yield dut.o
+        yield dut.n.ready_i.eq(0)
+        return result
 
     def producer():
         yield from send(5, 3, InternalOp.OP_ADD)
 
     def consumer():
-        yield dut.n.ready_i.eq(1)
+        result = yield from receive()
+        assert (result == 8)
 
     sim.add_sync_process(producer)
     sim.add_sync_process(consumer)