Skip to content

Deprecate the use of Signal.attrs mapping to specify platform-specific attributes #1498

Not planned
@whitequark

Description

@whitequark

Amaranth has a goal of not performing any platform-specific decisions until the moment when elaborate is called, and keeping the object tree intact (not mutated) during/after elaborate. However, the current design of attrs makes this impossible: anything that goes inside is by necessity platform-specific, and so it must be mutated within elaborate.

Amaranth's platform code is one of the worst offenders here, since add_clock_constraint usually adds a (platform-specific!) keep attribute to the clock.

Instead, I propose that attributes are added to signals using an API like:

platform.add_attribute(sig, "keep")
platform.add_attribute(sig, "dont_touch", "TRUE")

This way, the platform-specific attributes are kept inside the platform, and applied late in the compilation pipeline (during NIR generation or NIR to RTLIL/Verilog conversion, probably).

This also opens the opportunity to make signals almost entirely immutable, finishing the work started in #1067.

Activity

whitequark

whitequark commented on Aug 28, 2024

@whitequark
MemberAuthor

Oh, I forgot that #1466 already exists, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @whitequark

        Issue actions

          Deprecate the use of `Signal.attrs` mapping to specify platform-specific attributes · Issue #1498 · amaranth-lang/amaranth