llvm / llvm/circt

[FIRRTL, SV] Broken mux pragmas when hw.array_get is CSEd

Open
#4,163 0 comments 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

```scala
circuit Foo:
module Foo:
input clock: Clock
input d: UInt<1>[8]
input sel: UInt<3>
output q: UInt<1>

q <= mux(lt(sel,UInt<3>(4)), d[add(sel, UInt<3>(4))], d[sub(sel, UInt<3>(4))])
```

The current output is:
```
wire [7:0] _GEN = {{d_7}, {d_6}, {d_5}, {d_4}, {d_3}, {d_2}, {d_1}, {d_0}};
wire _GEN_0;
wire _GEN_1 = _GEN[sel - 3'h4] /* cadence map_to_mux */;
/* synopsys infer_mux_override */
assign _GEN_0 = _GEN_1;
wire _GEN_2;
/* synopsys infer_mux_override */
assign _GEN_2 = _GEN_1;
assign q = sel[2] ? _GEN_2 : _GEN_0;
endmodule
```

`/* synopsys infer_mux_override */` must be annotated to `_GEN[sel - 3'h4]` but it's spilled to a wire because of CSE.

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 with the FIRRTL circuit reproducer in the issue and inspect the generated SystemVerilog around hw.array_get common-subexpression elimination and mux pragma emission. Compare the current output with the required placement of /* synopsys infer_mux_override */; done means the annotation remains on the array access rather than a spilled wire, with a regression test covering the reproducer.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.