Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChiselSim does not properly support views (e.g. FlatIO) #4106

Closed
jackkoenig opened this issue May 28, 2024 · 0 comments · Fixed by #4107
Closed

ChiselSim does not properly support views (e.g. FlatIO) #4106

jackkoenig opened this issue May 28, 2024 · 0 comments · Fixed by #4107

Comments

@jackkoenig
Copy link
Contributor

Type of issue: Bug Report

Please provide the steps to reproduce the problem:

Try the following code:

//> using scala "2.13.12"
//> using dep "org.chipsalliance::chisel:6.3.0"
//> using plugin "org.chipsalliance:::chisel-plugin:6.3.0"
//> using options "-unchecked", "-deprecation", "-language:reflectiveCalls", "-feature", "-Xcheckinit", "-Xfatal-warnings", "-Ywarn-dead-code", "-Ywarn-unused", "-Ymacro-annotations"

import chisel3._
import chisel3.simulator.EphemeralSimulator._
// _root_ disambiguates from package chisel3.util.circt if user imports chisel3.util._
import _root_.circt.stage.ChiselStage

class Foo extends Module {
  val io = FlatIO(new Bundle {
    val in = Input(UInt(8.W))
    val out = Output(UInt(8.W))
  })

  val delay = RegNext(io.in)
  io.out := delay
}

object Main extends App {
  println(
    ChiselStage.emitSystemVerilog(
      gen = new Foo,
      firtoolOpts = Array("-disable-all-randomization", "-strip-debug-info")
    )
  )
  simulate(new Foo) { c =>
    c.io.in.poke(12.U)
    c.clock.step()
    c.io.out.peek()
  }
}

What is the current behavior?

Verilog generates just fine, but ChiselSim throws an exception:

Exception in thread "main" java.util.NoSuchElementException: key not found: Foo.in: IO[UInt<8>]
        at scala.collection.immutable.Map$Map4.apply(Map.scala:535)
        at chisel3.simulator.package$AnySimulatedModule.port(package.scala:36)
        at chisel3.simulator.PeekPokeAPI$testableData.poke(PeekPokeAPI.scala:116)
        at chisel3.simulator.PeekPokeAPI$testableData.poke(PeekPokeAPI.scala:111)

What is the expected behavior?

This should work just fine

Please tell us about your environment:

Other Information

Derived from question on Gitter1.

What is the use case for changing the behavior?

Correct behavior

Footnotes

  1. https://matrix.to/#/!jSbgpvvpsPbLpsLZOC:matrix.org/$a1ygVO22ceENy_lUNaTNuqOv-cGaM1oa2IxVSsRKPQ8?via=matrix.org&via=gitter.im&via=mumblingdrunkard.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant