Skip to content

Commit

Permalink
[Examples] Update FullAdder test
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardt committed Mar 11, 2024
1 parent 3d1fb5d commit a4c02e0
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions examples/tests/test_full_adder.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from ..full_adder import FullAdder
import fault as f
from hwtypes import BitVector


def test_full_adder():
tester = f.Tester(FullAdder)
for _ in range(4):
tester.circuit.a = a = BitVector.random(1)
tester.circuit.b = b = BitVector.random(1)

tester.circuit.cin = cin = BitVector.random(1)
tester.eval()
tester.circuit.sum_.expect(a ^ b ^ cin)
tester.circuit.cout.expect((a & b) | (b & cin) | (a & cin))
for a in range(2):
for b in range(2):
for cin in range(2):
tester.circuit.a = a
tester.circuit.b = b
tester.circuit.cin = cin
tester.eval()
tester.circuit.sum_.expect((a + b + cin) % 2)
tester.circuit.cout.expect((a + b + cin) >= 2)

tester.compile_and_run("verilator", magma_output="mlir-verilog")

0 comments on commit a4c02e0

Please sign in to comment.