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][HW] hw.WireOp inner_sym is inconvenient to use #6954

Open
nickelpro opened this issue Apr 25, 2024 · 1 comment
Open

[Python][HW] hw.WireOp inner_sym is inconvenient to use #6954

nickelpro opened this issue Apr 25, 2024 · 1 comment

Comments

@nickelpro
Copy link
Contributor

nickelpro commented Apr 25, 2024

The move to using InnerSymAttr in #5703 broke a somewhat obscure usage of the Python API for creating hw.WireOps directly.

The old code used to look like this:

op = hw.ConstantOp(ir.BoolAttr.get(True))
wire_name = "Example"
wire = hw.WireOp(op, name=wire_name, inner_sym=wire_name)

Now we have:

op = hw.ConstantOp(ir.BoolAttr.get(True))
wire_name = "Example"
wire = hw.WireOp(op, name=wire_name,
                 inner_sym=hw.InnerSymAttr.get(ir.StringAttr.get(wire_name)))

Which doesn't seem better.

sv.WireOp() got a sym_name parameter that does the right thing:

if sym_name is not None:
  attributes["inner_sym"] = hw.InnerSymAttr.get(StringAttr.get(sym_name))

The same fix should probably be applied to WireOp, and maybe just generally to all hw operations

@nickelpro nickelpro changed the title [Python][HW] [Python][HW] hw.WireOp inner_sym is inconvenient to use Apr 25, 2024
@mikeurbach
Copy link
Contributor

Thanks for bringing it up. We generally have convenience helpers in the Python operation builder APIs that take, for example, a Python string, and build the appropriate attribute. Like you've pointed out for sv.WireOp, which is defined here:

class WireOp(WireOp):
.

We simply don't have any convenience helper around the default generated Python operation builder for hw.WireOp, so the user is required to manually construct the appropriate attributes. I think it would be very reasonable to have this for hw.WireOp, so the user can supply inner_sym as a Python string, and the helper would construct the appropriate InnerSymAttr.

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

2 participants