llvm / llvm/circt

[FIRRTLToHW] Conversion failure of invalidated wire of clock type

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

Nobody has claimed this yet.

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

Description

The following fails verification after `circt-opt -lower-firrtl-to-hw`:

``` mlir
firrtl.circuit "Foo" {
firrtl.module private @Foo() {
%a = firrtl.wire : !firrtl.clock
%b = firrtl.invalidvalue : !firrtl.clock
firrtl.strictconnect %a, %b : !firrtl.clock
}
}
```

This fails with:

```
Titan.mlir:4:10: error: 'hw.bitcast' op result #0 must be Type wherein the bitwidth in hardware is known, but got '!seq.clock'
%b = firrtl.invalidvalue : !firrtl.clock
^
Titan.mlir:4:10: note: see current operation: %2 = "hw.bitcast"(%0) : (i1) -> !seq.clock
```

The illegal MLIR being produced is:

``` mlir
"builtin.module"() ({
"hw.module"() ({
%0 = "hw.constant"() {value = false} : () -> i1
%1 = "hw.wire"(%2) {name = "a"} : (!seq.clock) -> !seq.clock
%2 = "hw.bitcast"(%0) : (i1) -> !seq.clock
"hw.output"() : () -> ()
}) {comment = "", module_type = !hw.modty<>, parameters = [], per_port_attrs = [], result_locs = [], sym_name = "Foo", sym_visibility = "private"} : () -> ()
}) : () -> ()
```

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

Reproduce the failure with the provided FIRRTL module and `circt-opt -lower-firrtl-to-hw`. Start at the FIRRTL-to-HW lowering path and inspect how an invalidated `!firrtl.clock` becomes the shown `hw.bitcast` to `!seq.clock`; done means the conversion produces legal MLIR and verification succeeds.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
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.