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

Add component attributes to builder #1927

Merged
merged 5 commits into from
Feb 19, 2024
Merged

Add component attributes to builder #1927

merged 5 commits into from
Feb 19, 2024

Conversation

nathanielnrn
Copy link
Contributor

Allows to add attributes to components within the builder. This is needed as part of our AXI-wrapper generator #1733
Something like:

my_comp = prog.component("my_comp")
my_comp.attribute("my_attr", 1)

will produce a component signature that looks like:

component my_comp<"my_attr"=1>(...) -> (...)

I added note of this in the reference doc. Didn't think this warranted changing/adding any tests but can do that if we want.


I made sure this works with a little snippet of python uses this, but didn't think it was warranted to go into the repo, included here for completeness:

from calyx.builder import Builder
def add_attr_check(prog):
    my_comp = prog.component("my_component")
    my_comp.attribute("attr1", 7)
    my_comp.attribute("attr2", 1)


def build():
    prog = Builder()
    add_attr_check(prog)
    return prog.program

if __name__ == "__main__":
    build().emit()

emits:

component m_bresp_channel<"attr1"=7, "attr2"=1>() -> () {
  cells {

  }
  wires {

  }
  control {

  }
}

@nathanielnrn nathanielnrn added the C: calyx-py Items that have to do with the builder library label Feb 17, 2024
@rachitnigam
Copy link
Contributor

LGTM!

@nathanielnrn nathanielnrn merged commit 41bb3fe into main Feb 19, 2024
7 checks passed
@nathanielnrn nathanielnrn deleted the builder-attributes branch February 19, 2024 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: calyx-py Items that have to do with the builder library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants