Skip to content

can't process std_logic_vector(xx downto 0) if xx starts with a 0 or a space  #12

Description

@sylvainhuard

the "xx" is not identified as an integer. here are the 3 form of the same:
(3 downto 0) -- passes
(03 downto 0) -- fails
( 3 downto 0) -- fails.
it returns that error:
Cannot use str_expression on
The function
`
def str_expression(item):
'''
Returns a string representation of the mathematical equation.

>>> str_expression(Addition([Term(number=3, expression='fish'), Term(number=1, expression='bear')]))
'(3*fish+bear)'
'''
if isinstance(item, str):
    o = item
elif isinstance(item, int):
    o = str(item)
elif isinstance(item, float):
    if int(item) == item:
        o = str(int(item))
    else:
        o = str(item)
elif hasattr(item, 'str_expression'):
    o = item.str_expression()
else:
    raise MathParsingError('Cannot use str_expression on {}'.format(item))
return o

`
is in "math_parser.py"

when I write my own code, it's not an issue. I can workaround the limitation. When using open source IPs that uses the two failing form, it forces to modifiy the original source code and rework it every time we fetch from the source. I found the bug parsing
https://github.com/stnolting/neorv32/blob/main/rtl/core/neorv32_package.vhd
Even with this bug, slvcodec advantages outway by far the little maintenance after a fetch from origin. Thanks for this great utility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions