llvm / llvm/circt

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

Open
#6,954 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

The move to using `InnerSymAttr` in https://github.com/llvm/circt/pull/5703 broke a somewhat obscure usage of the Python API for creating `hw.WireOp`s directly.

The old code used to look like this:

```python
op = hw.ConstantOp(ir.BoolAttr.get(True))
wire_name = "Example"
wire = hw.WireOp(op, name=wire_name, inner_sym=wire_name)
```
Now we have:
```python
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:
```python
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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the Python API entry points for hw.WireOp and sv.WireOp, focusing on their inner_sym and sym_name parameters and the InnerSymAttr construction shown in the issue. Check whether other hw operations expose the same inconvenient pattern; done means WireOp accepts the simpler string form and any broader scope is addressed consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.