Skip to content
New issue

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

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

Already on GitHub? # to your account

Slice on fields in bitstruct does not produce valid Verilog #179

Open
wizard97 opened this issue Feb 11, 2019 · 0 comments
Open

Slice on fields in bitstruct does not produce valid Verilog #179

wizard97 opened this issue Feb 11, 2019 · 0 comments

Comments

@wizard97
Copy link

wizard97 commented Feb 11, 2019

If you do

class Foo(BitStructDefinition):
    def __init__(s):
        s.dog = BitField(1)
        s.bar = BitField(8)
        s.cat = BitField(1)

Then somewhere in a model you try to do the following:

s.foo = Wire(Foo())
...
s.bob.v = s.foo.bar[:4]

This will translate to verilog as something along the lines of:

bob = foo[8:1][3:0]

Which is not valid, see:

According to this spec in 11.4.12, this should be bob = {foo[8:1]}[3:0]. However, I was having issues with this as well. I think there should be an AST pass that does slice propogation, to turn it into bob = foo[4:1]

As is the workaround for most of these bugs, you have to manually create a temporary wire of foo.bar

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

No branches or pull requests

1 participant