chipsalliance / chipsalliance/chisel

FlatIO Error for Function Generator Argument

Open
#3,177 0 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

The following `Bundle` `Bar` errors if the `tieoff` method is used when created as a `FlatIO`. I'm currently getting:

```
Exception in thread "main" chisel3.package$ExpectedHardwareException: data to be connected 'Bool' must be hardware, not a bare Chisel type. Perhaps you forgot to wrap it in Wire(_) or IO(_)?
at ... ()
at Bar.tieoff(FlatIOMethod.scala:13)
at Foo.(FlatIOMethod.scala:25)
at Main$.$anonfun$new$1(FlatIOMethod.scala:29)
at ... ()
at ... (Stack trace trimmed to user code only. Rerun with --full-stacktrace to see the full stack trace)
```

Example code which can be run with `scala-cli Foo.scala`:

```scala
//> using scala "2.13.10"
//> using repository "https://s01.oss.sonatype.org/content/repositories/snapshots"
//> using lib "org.chipsalliance::chisel::5.0.0-M1+32-baed66d4-SNAPSHOT"
//> using plugin "org.chipsalliance:::chisel-plugin::5.0.0-M1+32-baed66d4-SNAPSHOT"
//> using options "-Ymacro-annotations"

import chisel3._
import chisel3.experimental.FlatIO
import circt.stage.ChiselStage

class Bar[A <: Data](gen: => A, default: A) extends Bundle {
val a = gen
def tieoff() = a := default
}

class Foo extends Module {
val io = IO(new Bar(Bool(), false.B))
io.tieoff() // <- This works!
val io2 = FlatIO(new Bar(Bool(), false.B))
io2.tieoff() // <- This errors!
}

object Main extends App {
println(ChiselStage.emitCHIRRTL(new Foo))
}
```

Contributor guide

Open the contributing guide

Research direction

Start by running the provided FlatIOMethod.scala reproducer with scala-cli and inspect the FlatIO usage, Bar.tieoff, and the Foo constructor locations named in the stack trace. Compare the working IO case with the failing FlatIO case; done means the example elaborates without ExpectedHardwareException and emits CHIRRTL.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
embedded-iot
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.