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

Fix constants generation with same c_name between register and field #44

Merged

Conversation

lorenzschmid
Copy link
Contributor

@lorenzschmid lorenzschmid commented Apr 19, 2024

Bug introduced in #43:

If there is a register containing a single field and both share the same name, both of their c_names will be equal. Hence, when the default separator _ is selected, pr_name() will return the same name for the register as well as for the field. Printing the address for the register and the field will therefore lead to the same constant printed twice.

E.g.

    - reg:
        name: foo_bar
        description: 'Foo Bar'
        width: 32
        access: rw
        children:
            - field:
                name: foo_bar
                description: 'Foo Bar'
                range: 31-0
    - reg:
        ...

will lead to the following VHDL constant generation (ADDR_REG_SET_FOO_BAR declared twice):

  constant ADDR_REG_SET_FOO_BAR : Natural := 16#c#;
  constant ADDR_REG_SET_FOO_BAR : Natural := 16#c#;
  constant REG_SET_FOO_BAR_OFFSET : Natural := 0;

Since before #43, the address constant was only printed for the register (but not for the field), the constant was previously printed only once.

This fix blocks the printing of the constant if a field and its register share the same c_name.

@tgingold-cern tgingold-cern merged commit a3dc38c into tgingold-cern:master Apr 19, 2024
2 checks passed
@tgingold-cern
Copy link
Owner

Maybe worth adding a test ?

@lorenzschmid
Copy link
Contributor Author

Maybe worth adding a test ?

I agree but think that this should be done a bit more thoroughly than only compare to golden files. Hence, I opened #45 to tackle it at a later moment.

@lorenzschmid lorenzschmid deleted the fix-gen-struct-matlab branch April 19, 2024 07:42
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

Successfully merging this pull request may close these issues.

2 participants