Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between Verilog Maths and Python Fixed-Point Model #167

Open
WillGreen opened this issue Jun 27, 2023 · 0 comments
Open

Inconsistency between Verilog Maths and Python Fixed-Point Model #167

WillGreen opened this issue Jun 27, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@WillGreen
Copy link
Contributor

WillGreen commented Jun 27, 2023

The current Verilog maths and Python fixed-point test modules choose different values in some cases where the inputs can't be precisely represented in binary.

We should output the model a and b values and investigate the difference.

Fixing this issue would allow us to run random tests against the maths modules.

Two new tests show this problem:

# test fails - model and DUT choose different sides of true value
@cocotb.test(expect_fail=True)
async def nonbin_4(dut):
    """Test 3.6/0.6"""
    await test_dut_divide(dut=dut, a=3.6, b=0.6)

# test fails - model and DUT choose different sides of true value
@cocotb.test(expect_fail=True)
async def nonbin_5(dut):
    """Test 0.4/0.1"""
    await test_dut_divide(dut=dut, a=0.4, b=0.1)
   666.03ns INFO     cocotb.regression                  running nonbin_4 (30/37)
                                                          Test 3.6/0.6
   688.03ns INFO     cocotb.div                         dut a:     000111001
   688.03ns INFO     cocotb.div                         dut b:     000001001
   688.03ns INFO     cocotb.div                         dut val:   001100101
   688.03ns INFO     cocotb.div                                    6.3125
   688.03ns INFO     cocotb.div                         model val: 000101.1101
   688.03ns INFO     cocotb.div                                    5.8125
   688.03ns INFO     cocotb.regression                  nonbin_4 passed: failed as expected (result was AssertionError)
   688.03ns INFO     cocotb.regression                  running nonbin_5 (31/37)
                                                          Test 0.4/0.1
   710.03ns INFO     cocotb.div                         dut a:     000000110
   710.03ns INFO     cocotb.div                         dut b:     000000001
   710.03ns INFO     cocotb.div                         dut val:   001100000
   710.03ns INFO     cocotb.div                                    6
   710.03ns INFO     cocotb.div                         model val: 000011.0000
   710.03ns INFO     cocotb.div                                    3
   710.03ns INFO     cocotb.regression                  nonbin_5 passed: failed as expected (result was AssertionError)
@WillGreen WillGreen added the bug Something isn't working label Jun 27, 2023
@WillGreen WillGreen self-assigned this Jun 27, 2023
WillGreen added a commit that referenced this issue Jun 27, 2023
* Add test with small divisor 1/0.2 (issue #164).
* Use fixed-point for GTKWave display.
* Improve model division.
* Add tests for values that can't be precisely represented in binary. See issue #167.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant