chipsalliance / chipsalliance/chisel

[Feature Request] Raise an error if a property path is not hierarchically underneath the same owning module from Chisel

Open
#3,939 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Scala
Stars
4.8k
Forks
658
Avg merge
18h 59m
Merged PRs (30d)
14

Description

Minimum reproducible example

```scala
import chisel3._
import chisel3.properties._
import chisel3.experimental.hierarchy.{instantiable, public, Definition, Instance}

@instantiable
class OM extends Class {
val path = IO(Output(Property[Path]()))
@public val pathIn = IO(Input(Property[Path]()))
path := pathIn
}

class Sub extends Module {}

class Top extends Module {
val omDef = Definition(new OM)
val omIns = Instance(omDef)
val sub = Module(new Sub)
omIns.pathIn := Property(sub)
}

class TopWrapper extends Module {
val top = Module(new Top)
}
```

CIRCT Firtool reports an error `unable to resolve path relative to owning module "Top"` for the outputs of `emitCHIRRTL(new TopWrapper)`, but works fine with the outputs of `emitCHIRRTL(new Top)`.

Thanks to @mikeurbach for explaining further information about that on Discord

> The rule is the paths in the OM dialect need to be hierarchically underneath the same "owning module" as the entities they target. https://github.com/llvm/circt/blob/6914bc6e0d11468c3fb11dfda74091f6e2e0306d/include/circt/Dialect/FIRRTL/OwningModuleCache.h#L18-L22.

However, the error will be reported by CIRCT Firtool, it appeared a bit late. It would be better if there is a possibility to check and report a more friendly error on Chisel.

CC @sequencer

Contributor guide

Open the contributing guide

Research direction

Start with the minimal reproducer and the emitCHIRRTL(new TopWrapper) entry point, comparing it with emitCHIRRTL(new Top). Trace where property paths and owning modules are handled, then verify that the invalid hierarchy produces a friendly Chisel error before CIRCT Firtool reports it.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
compilers
Issue type
Feature
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.