Skip to content

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

Description

@WillGreen

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)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions