Skip to content

Commit

Permalink
Merge pull request #5 from COLVERTYETY/Nicolas-tests
Browse files Browse the repository at this point in the history
full coverage tests
  • Loading branch information
COLVERTYETY authored Jul 20, 2024
2 parents 772845d + 3d7c622 commit 101de91
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 12 deletions.
196 changes: 196 additions & 0 deletions test/fails.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
2
oxxxo
xooox
oooxo
ooxoo
oxxxx

2
oxooo
xoxoo
ooxoo
oxooo
xxxoo

2
xxxoo
ooxoo
xxxoo
xoooo
xxxoo

2
oxxxo
oooox
oxxxo
xoooo
oxxxo

2
xxxxo
oooxo
xxxxo
xoooo
xxxxo

2
xxxxx
oooox
xxxxx
xoooo
xxxxx

2
xxxxo
oooox
oxxxo
xoooo
oxxxx

2
oxxxo
xooox
ooxxo
oxooo
oxxxx

2
xxooo
ooxoo
oxooo
xoooo
xxxoo

3
xxxoo
oooxo
xxxoo
oooxo
xxxoo

3
xxxoo
ooxoo
oxooo
ooxoo
xxxoo

3
xxooo
oxooo
xoooo
oxooo
xxooo

3
xxxxo
oooxo
xxxxo
oooxo
xxxxo

3
xxxxo
oooox
xxxxo
oooox
xxxxo

3
xxxoo
ooxoo
xxxoo
ooxoo
xxxoo

3
xxooo
oxooo
xxooo
oxooo
xxooo

3
xoooo
oxooo
xxooo
oxooo
xoooo

3
oxxxo
xooox
ooxxo
xooox
oxxxo

3
xxxxo
oooxo
oxxxo
oooxo
xxxxo

3
xxooo
ooxoo
oxooo
ooxoo
xxooo

3
oxooo
xoxoo
oxxoo
xoxoo
oxooo

3
xxxoo
oooxo
ooxoo
oooxo
xxxoo

8
oxxxo
xooox
oxxxo
xooox
oxxxo

8
oxooo
xoxoo
oxooo
xoxoo
oxooo

8
oxxoo
xooxo
oxxoo
xooxo
oxxoo

8
oxxxo
xxoxx
oxxxo
xxoxx
oxxxo

9
oxxxo
xxoxx
xxxxx
oooxx
oxxxo

9
oxooo
xoxoo
xxxoo
ooxoo
oxooo

39 changes: 27 additions & 12 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ async def test_project(dut):
"""Test the project."""

dataset = get_dataset()
print(dataset)
fails = []
# print(dataset)


# Initialize the dut
Expand All @@ -67,17 +68,31 @@ async def test_project(dut):
dut.rst_n.value = 1

dut._log.info("Test project behavior")

# Set the input values you want to test
dut.ui_in.value = 20
dut.uio_in.value = 30
correct = 0
for i, (l,v) in enumerate(dataset):
test = shape_input(v)
dut._log.info(f"Test {i} with label {l} and values {v}")
dut._log.info("Reset")
dut.ena.value = 1
dut.ui_in.value = 0
dut.uio_in.value = 0
dut.rst_n.value = 0
await ClockCycles(dut.clk, 3)
dut.rst_n.value = 1
await ClockCycles(dut.clk, 3)
for x, j in test:
dut.ui_in.value = j*2**3 + x
await ClockCycles(dut.clk, 1)
correct += 1 if int(dut.uo_out.value) == l else 0
# dut._log.info(f"Output: {int(dut.uo_out.value)} Expected: {l}")
if int(dut.uo_out.value) != l:
dut._log.error(f"Output: {int(dut.uo_out.value)} Expected: {l} at {i}")
fails.append(i)
dut._log.info(f"Correct: {correct}/{len(dataset)}")
assert correct >= len(dataset)*0.6, "too many errors"

# Wait for one clock cycle to see the output values
await ClockCycles(dut.clk, 1)

# The following assersion is just an example of how to check the output values.
# Change it to match the actual expected output of your module:
# assert dut.uo_out.value == 50

# Keep testing the module by changing the input values, waiting for
# one or more clock cycles, and asserting the expected output values.
dut._log.info("End")
# save the fails
print(fails)

0 comments on commit 101de91

Please sign in to comment.