llvm / llvm/circt

[FIRRTL][CheckCombLoops] Support aggregates with flips

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

Nobody has claimed this yet.

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

Description

This is not an issue as long as this executes after LowerTypes, as it will break apart bundles with flips. So prioritize accordingly.

Anyway, example input:

```mlir
firrtl.circuit "Check" {
firrtl.module private @Child(in %in: !firrtl.bundle, y flip: uint<5>>, out %out: !firrtl.bundle, y flip: uint<5>>) {
%0 = firrtl.subfield %out[x] : !firrtl.bundle, y flip: uint<5>>
%1 = firrtl.subfield %in[x] : !firrtl.bundle, y flip: uint<5>>
firrtl.strictconnect %0, %1 : !firrtl.uint<5>
%2 = firrtl.subfield %out[y] : !firrtl.bundle, y flip: uint<5>>
%3 = firrtl.subfield %in[y] : !firrtl.bundle, y flip: uint<5>>
firrtl.strictconnect %3, %2 : !firrtl.uint<5>
}
firrtl.module @Check() attributes {convention = #firrtl} {
%c_in, %c_out = firrtl.instance c @Child(in in: !firrtl.bundle, y flip: uint<5>>, out out: !firrtl.bundle, y flip: uint<5>>)
%0 = firrtl.subfield %c_in[x] : !firrtl.bundle, y flip: uint<5>>
%1 = firrtl.subfield %c_in[y] : !firrtl.bundle, y flip: uint<5>>
%2 = firrtl.subfield %c_out[y] : !firrtl.bundle, y flip: uint<5>>
firrtl.strictconnect %2, %1 : !firrtl.uint<5>
%c5_ui3 = firrtl.constant 5 : !firrtl.uint<3>
firrtl.connect %0, %c5_ui3 : !firrtl.uint<5>, !firrtl.uint<3>
}
}
```

Original FIRRTL input FWIW:
```firrtl
circuit Check:
module Child:
input in : { x : UInt<5>, flip y : UInt<5> }
output out : { x : UInt<5>, flip y : UInt<5> }

out <= in

module Check:
inst c of Child

c.out.y <= c.in.y
c.in.x <= UInt(5)
```

Noticed reviewing code where Direction of port is used, but with flips there may be more to the story.

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 CheckCombLoops implementation, especially the code that uses port Direction, and reproduce the issue with the aggregate-with-flips MLIR example in the report. Done means CheckCombLoops correctly handles bundles containing flipped fields, including the provided Child and Check modules, without relying on LowerTypes to split them first.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.