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

Python list slicing translation #177

Open
wizard97 opened this issue Jan 28, 2019 · 0 comments
Open

Python list slicing translation #177

wizard97 opened this issue Jan 28, 2019 · 0 comments

Comments

@wizard97
Copy link

wizard97 commented Jan 28, 2019

Translation does not work for ranges involving negative indices. The pythonic way to get the last element in a list is x[-1]. This translates fine. However, the semantics of list slicing involving negative indices are not translated properly and you get a verilator error about backwards bit ordering:

For example, both of these fail to translate:

  • x[:-1] (get everything up to the last element)
  • x[0:-1]

[-2:0] Range extract has backward bit ordering, perhaps you wanted [0:-2]

A common example of where you would want to do list slicing such as this is dealing with signed numbers, where you want to extract the sign bit x[-1] as well as everything else x[:-1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant